Skip to main content

Source Map

All paths are relative to the pivot repo root unless otherwise stated. Branch of record: development-2.

Repo locations on this machine​

RepoPath
pivot (main)/Users/alexandresauvedeguise/Dev/pivotteam/pivot
pivot-mia-docs (this site)/Users/alexandresauvedeguise/Dev/pivotteam/pivot-mia-docs
Pivotmobile/Users/alexandresauvedeguise/Dev/pivotteam/Pivotmobile

There is no standalone mia-tips or pivot-agent repo / folder. Earlier docs referenced these — they were wrong.

Backend (Firebase Functions, modular monolith)​

AreaPathNotes
Architecture conventionsCLAUDE.mdModule boundaries, layer import rules, OOP/functional split. Always re-read before refactoring.
AI memory modulefunctions/modules/ai-memory/Profile, rules, cron tasks.
Router (mounted)functions/modules/ai-memory/endpoints/apis/router.ts
Sub-router (ai-memory)functions/modules/ai-memory/endpoints/apis/ai-memory.router.ts
Temporal scheduler servicefunctions/modules/ai-memory/services/temporal-scheduler.service.tsMirrors cron tasks to Temporal.
Chat module (employee messaging)functions/modules/chat/Not the AI chat.
Companies modulefunctions/modules/companies/Includes ai-tips-rules, ai-usage, ai-config sub-routers.
AI usage + config endpointsfunctions/modules/companies/endpoints/apis/ai-usage.router.ts/companies/:id/ai-usage, /ai-usage/all, /ai-config/*. Admin-gated via inline isAdmin(), not companyScopeMiddleware.
AI tip rules endpointsfunctions/modules/companies/endpoints/apis/ai-tips-rules.router.ts/companies/:id/ai-tips-rules*.
Docs modulefunctions/modules/docs/OpenAPI spec generator + Scalar UI. Now self-registered (/openapi.json, /docs, /).
OpenAPI registryfunctions/modules/docs/logic/registry.tsSingle source of truth for the API spec. Live: 20 tag groups, 88 paths (17 modules + auth + integration-engine, plus roles as a sub-tag of companies).
Docs routerfunctions/modules/docs/endpoints/apis/docs.router.ts/openapi.json, /docs, /.
Calculator modulefunctions/modules/calculator/Deterministic arithmetic primitive. Mounted as calculatorApi.
Onboarding modulefunctions/modules/onboarding/Session-state endpoints. Auth via x-user-token header.
Requests modulefunctions/modules/requests/Shift-request CRUD.
POS-sync modulefunctions/modules/pos-sync/Roster sync glue.
Auth systemfunctions/systems/auth/Password reset, signup, invitations, impersonation. Hono router; outside modules/ but registered in OpenAPI. DTOs: common/dtos/auth/.
Integration enginefunctions/integration-engine/Generic plugin sync engine (connect, disconnect, trigger sync, OpenTable partner flow). Distinct from the integrations module (which is the catalog).
Shared middlewarefunctions/shared/middleware/Auth, scope, claim, logger, trace, errorHandler.
Auth middlewarefunctions/shared/middleware/auth.middleware.ts
Company-scope middlewarefunctions/shared/middleware/company-scope.middleware.ts
Request context builderfunctions/shared/infrastructure/request-context-from-token.ts

AI service (Cloud Run)​

AreaPath
Service rootfunctions/pivotAiAgent/
Express entrypointfunctions/pivotAiAgent/index.ts
Intent classifierfunctions/pivotAiAgent/intent.ts
Tool-loop pipelinefunctions/pivotAiAgent/pipeline.ts
Chat-path responderfunctions/pivotAiAgent/chat.ts
Onboarding pipeline (also handles MIA Tips)functions/pivotAiAgent/onboarding-pipeline.ts
Onboarding promptsfunctions/pivotAiAgent/onboarding-prompts.ts
Onboarding intentfunctions/pivotAiAgent/onboarding-intent.ts
AI config resolutionfunctions/pivotAiAgent/ai-config.ts
Pricing/usagefunctions/pivotAiAgent/pricing.ts
Firebase Admin token helpersfunctions/pivotAiAgent/firebase-admin-token.ts
globalThis.fetch interceptor for RTDBfunctions/pivotAiAgent/firebase.ts

AI service — its own internal docs​

The AI service has its own docs folder (separate from this site, much older, still uses the "Finn" name throughout). Useful for legacy context but treat with skepticism — much of it predates the modular monolith.

FilePath
Architecture overview (Finn-named)functions/pivotAiAgent/ARCHITECTURE.md
Firebase schema notesfunctions/pivotAiAgent/FIREBASE_SCHEMA.md
Migration planfunctions/pivotAiAgent/FIREBASE_MIGRATION.md
In-service docs folderfunctions/pivotAiAgent/docs/ — 01-ai-agent-architecture.md, 03-temporal.md, 04-dashboard-layout-and-modals.md, etc.

AI service — tools​

AreaPath
Tools registry + dispatcherfunctions/pivotAiAgent/tools/index.ts (TOOL_CATALOG, executeTool)
Endpoint URL builder + auth headersfunctions/pivotAiAgent/tools/_endpoints.ts
Per-category tool implementationsfunctions/pivotAiAgent/tools/<category>/<tool>.ts

Tool categories (folders): ai-memory, applicants, attendance, calculator, chat, company, documents, employees, onboarding, posts, requests, research, sales, schedule, tips-rules, weather.

AI service — providers​

AreaPath
Provider dispatcherfunctions/pivotAiAgent/providers/index.ts
Anthropic adapterfunctions/pivotAiAgent/providers/anthropic.ts
OpenRouter adapterfunctions/pivotAiAgent/providers/openrouter.ts

AI service — temporal​

AreaPath
Workerfunctions/pivotAiAgent/temporal/worker.ts
Workflowsfunctions/pivotAiAgent/temporal/workflows.ts
Activitiesfunctions/pivotAiAgent/temporal/activities.ts
Scheduled reminderfunctions/pivotAiAgent/temporal/scheduled-reminder.ts

Frontend​

SurfacePath
Main chatsrc/routes/PivotAiAgentDashboard/
MIA Tipssrc/routes/MiaTips/
AI Onboardingsrc/routes/AIOnboarding/
Settingssrc/routes/AccountSettings/PivotAiAgent/

Data store rules​

FileOwns
firestore.rulesFirestore access (mostly read-only to clients).
database.rules.jsonRTDB access.
firestore.indexes.jsonFirestore composite indexes.

Build / deploy​

FilePurpose
MakefileLocal dev orchestration (emulators, Temporal, AI service).
.firebasercProject aliases (default, development-2, staging, production).
firebase.jsonHosting + functions deploy config.
functions/build.jsesbuild bundling per module entry point.
functions/package.jsonnpm scripts for build/test/deploy.