Think of this as the “who owns what” reference. Every entry links back to the
folders you touch during feature work so new contributors can orient quickly.
Request-facing services
Auth (`src/services/auth`)
Auth (`src/services/auth`)
- Routes:
/api/v1/auth/*for OTP, passwordless login, refresh, Google token exchange, and sign-out. Webhook handlers under/api/v1/auth/webhooks/*receive Auth0 Actions (post-registration/login). - Controllers wire
auth0JwtMiddleware,webhookSecretMiddleware, and the MongouserRepositoryso JWT subjects are mirrored in our database. - Services handle OTP generation/verification, device binding, session revocation, and Auth0 Management API calls when credentials are present.
- Docs to cross-reference:
/docs/api-reference/auth*plusWEB_GOOGLE_AUTH_GUIDE.mdandMOBILE_GOOGLE_AUTH_GUIDE.md.
AI chat (`src/services/ai`)
AI chat (`src/services/ai`)
- Routes:
/api/v1/ai/chat(sync + streaming),/api/v1/ai/health. ChatOrchestrationServicecoordinates conversation creation,MessageRepository,MemoryService(SuperMemory + Mongo), thellmServiceabstraction around OpenAI/Anthropic,usageTrackingService, andprePromptService.- File attachments flow through
file-attachment.helper.ts, which resolves inline uploads or stored files before they hit the LLM. - Every completion is traced via Langfuse (
instrumentation.ts) and respects per-user quotas.
RAG (`src/services/rag`)
RAG (`src/services/rag`)
- Routes:
/api/v1/rag/*for retrieval-augmented answers and tooling around Pinecone / SuperMemory indices. - Uses
ai.config.tsto decide which vector store/provider to fan out to and shares the Redis cache helpers for dedup + hydration. - RAG responses are logged with the same
X-Request-IDplus Langfuse spans so you can replay failing traces.
Context Manager (`src/services/contextManager`)
Context Manager (`src/services/contextManager`)
- Owns onboarding context, user memory slots, and syncs with SuperMemory.
- Routes:
/api/v1/context/*for CRUD on profile facets, document attachments, and preference toggles. - Services like
MemoryService,ContextService, andProfileSyncServicereuse the shared repositories and Redis caching to hydrate chat sessions.
Conversations (`src/services/conversations`)
Conversations (`src/services/conversations`)
- Routes under
/api/v1/user/conversations*give clients list/search/detail, archive/restore/delete, and message pagination. - Controllers use
ConversationRepository+MessageRepositorydirectly, reusing the same schema as the chat orchestrator so histories stay in sync. - All endpoints require
auth0JwtMiddlewareand return the sharedsuccessResponseenvelope.
Chat Share (`src/services/chatShare`)
Chat Share (`src/services/chatShare`)
File uploads (`src/services/fileUpload`)
File uploads (`src/services/fileUpload`)
- Routes:
/api/v1/files/upload|get|list|delete. gcs-storage.service.tsorchestrates Google Cloud Storage buckets whenGCS_PROJECT_ID/GCS_BUCKET_NAMEare set; otherwise the service gracefully degrades and blocks uploads.- Files can be attached to chats (see
ai/utils/file-attachment.helper.ts) and are automatically scanned for metadata before being persisted.
Profile (`src/services/profile`)
Profile (`src/services/profile`)
- Routes:
/api/v1/profile/*for retrieving/updating user-level metadata (names, communication preferences, linked brokerage accounts, etc.). - Heavily reuses
userRepositoryandprofile.service.tsto ensure updates stay consistent with the Auth0-backed identity model.
App bootstrap (`src/services/app`)
App bootstrap (`src/services/app`)
- Routes:
/app/launchand/app/health, consumed by the mobile clients before hitting the authenticated APIs. appController.launchstitches together device headers, user/profile data, feature flags, social links, and free-tier thresholds so the app can decide whether onboarding is required.- This path touches MongoDB, Redis, and the
usageTrackingService, so keep those services healthy before debugging app issues.
Preprompts (`src/services/preprompts`)
Preprompts (`src/services/preprompts`)
- Routes:
/api/v1/preprompts/*for CRUD + public listings. - Drives both chat orchestration (via
prePromptService) and the Langfuse prompt manager. Every preprompt is versioned and can be exposed publicly for marketing/SEO use cases.
Supporting packages
src/services/database– typed repositories and interfaces for users, conversations, messages, shares, files, etc. Repositories own index creation and run duringstartupConfig.initialize()so Mongo stays optimized.src/shared/promptManager– webhook receivers and sync scripts that keep Langfuse prompt definitions aligned with the preprompt store.src/services/brokers– integrations with Groww and Zerodha for account linking plus trade history ingest.src/services/ingestor– connectors that pull statements/SMS into the context store for downstream analysis.src/services/insights– higher-level analytics and notification logic built on top of context, conversations, and RAG results.src/shared/services– cross-cutting helpers such asusage-tracking.service.ts, rate-limit utilities, and AI tracing.infra/terraform+infra/k8s– infrastructure-as-code for Cloud Run, VPC, secret management, and (optional) Kubernetes deployments.
How to add a new surface
- Scaffold
src/services/<name>/{controllers,routes,services,types}following the existing verticals. - Register the router in
server.tsunder a clear prefix (/api/v1/<name>or/app/<name>). - Leverage repositories in
src/services/databaseinstead of re-querying MongoDB directly. - Update
/docs/api-referenceand the relevant/docs/codebase/*page so the Mintlify sidebar stays trustworthy (Mintlify recommends keeping guides concise and task-focused, see their style guide).