# aana123/syntra architecture

> Architecture diagram of the GitHub repository aana123/syntra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aana123/syntra
- Repository: https://github.com/aana123/syntra

## Overview

Syntra is a personal digital-twin platform: users establish a profile, ingest health/financial/career data, review scores and AI reflections, execute goals, and test scenarios. The map includes documented capabilities such as Google Fit, document extraction, gamification, and chat. Route-to-service links are shown where excerpts or the README support them; unsampled internals are represented conservatively.

Main entry points: [`src/app/api/log/route.ts`](https://github.com/aana123/syntra/blob/main/src/app/api/log/route.ts) (Daily Logging), [`src/app/ingestion/page.tsx`](https://github.com/aana123/syntra/blob/main/src/app/ingestion/page.tsx) (Ingestion UI), [`src/app/api/ingestion/upload/route.ts`](https://github.com/aana123/syntra/blob/main/src/app/api/ingestion/upload/route.ts) (Document Extraction), [`src/app/api/simulate/route.ts`](https://github.com/aana123/syntra/blob/main/src/app/api/simulate/route.ts) (Scenario Simulator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_onboarding["Onboarding<br/>[page.tsx]"]
  node_dashboard["Twin Dashboard<br/>[page.tsx]"]
  node_chat["Twin Chat<br/>[ChatWidget.tsx]"]
  node_networth["Net Worth View<br/>[NetWorthPanel.tsx]"]
end

subgraph group_ingestion["Data Ingestion"]
  node_ingestion_ui["Ingestion UI<br/>[page.tsx]"]
  node_uploader["Document Uploader<br/>[Uploader.tsx]"]
  node_document_ingest["Document Extraction<br/>[route.ts]"]
  node_batch_import["Batch Import<br/>[route.ts]"]
  node_fit_sync["Google Fit Sync<br/>[googleFitSync.ts]"]
  node_prototype_sync["Prototype Sync<br/>[route.ts]"]
end

subgraph group_twin["Twin Intelligence"]
  node_log_api["Daily Logging<br/>[route.ts]"]
  node_dashboard_api["Dashboard API<br/>[route.ts]"]
  node_dashboard_service["Dashboard Assembly"]
  node_snapshot["Twin Reflection<br/>[snapshotService.ts]"]
  node_context["Context Builder"]
  node_drift["Drift Analysis<br/>[driftEngine.ts]"]
  node_gemini["Gemini Service<br/>[gemini.ts]"]
end

subgraph group_execution["Goals and Simulation"]
  node_goals["Goal Execution<br/>[route.ts]"]
  node_gamification["Gamification<br/>[route.ts]"]
  node_simulator["Scenario Simulator<br/>[route.ts]"]
end

subgraph group_platform["Identity and Data"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_user_model["User Profile Model<br/>[User.ts]"]
  node_log_model["Telemetry Log Model<br/>[Log.ts]"]
  node_asset_model["Asset Model<br/>[AssetLiability.ts]"]
  node_mongo[("MongoDB<br/>[mongodb.ts]")]
end

node_user(("User"))

node_user -->|"sets baseline"| node_onboarding
node_user -->|"uploads or syncs"| node_ingestion_ui
node_user -->|"reviews twin"| node_dashboard
node_user -->|"sets goals"| node_goals
node_user -->|"tests scenarios"| node_simulator
node_ingestion_ui -->|"offers upload"| node_uploader
node_uploader -.->|"submits document"| node_document_ingest
node_document_ingest -->|"connects database"| node_mongo
node_document_ingest -->|"checks and writes logs"| node_log_model
node_document_ingest -->|"loads and saves user"| node_user_model
node_document_ingest -->|"schedules reflection"| node_snapshot
node_ingestion_ui -.->|"connects Google Fit"| node_fit_sync
node_ingestion_ui -.->|"imports CSV or Excel"| node_batch_import
node_ingestion_ui -.->|"syncs sample sources"| node_prototype_sync
node_log_api -->|"authenticates"| node_auth
node_log_api -->|"connects database"| node_mongo
node_log_api -->|"loads and updates"| node_user_model
node_log_api -->|"records log"| node_log_model
node_log_api -->|"schedules reflection"| node_snapshot
node_dashboard -.->|"requests twin data"| node_dashboard_api
node_dashboard_api -.->|"serves dashboard"| node_dashboard_service
node_dashboard_service -->|"connects database"| node_mongo
node_dashboard_service -->|"loads profile"| node_user_model
node_dashboard_service -->|"loads recent logs"| node_log_model
node_chat -->|"supports coaching"| node_user
node_snapshot -->|"builds twin context"| node_context
node_snapshot -->|"analyzes divergence"| node_drift
node_snapshot -->|"generates reflection"| node_gemini
node_goals -.->|"tracks rewards"| node_gamification
node_simulator -->|"connects database"| node_mongo
node_simulator -->|"loads user goals"| node_user_model
node_simulator -->|"uses financial state"| node_asset_model
node_simulator -.->|"requests insight"| node_gemini
node_auth -.->|"authenticates accounts"| node_user_model

click node_onboarding "https://github.com/aana123/syntra/blob/main/src/app/onboarding/page.tsx"
click node_dashboard "https://github.com/aana123/syntra/blob/main/src/app/dashboard/page.tsx"
click node_chat "https://github.com/aana123/syntra/blob/main/src/components/ChatWidget.tsx"
click node_networth "https://github.com/aana123/syntra/blob/main/src/components/NetWorthPanel.tsx"
click node_ingestion_ui "https://github.com/aana123/syntra/blob/main/src/app/ingestion/page.tsx"
click node_uploader "https://github.com/aana123/syntra/blob/main/src/components/Uploader.tsx"
click node_document_ingest "https://github.com/aana123/syntra/blob/main/src/app/api/ingestion/upload/route.ts"
click node_batch_import "https://github.com/aana123/syntra/blob/main/src/app/api/upload/csv/route.ts"
click node_fit_sync "https://github.com/aana123/syntra/blob/main/src/lib/services/googleFitSync.ts"
click node_prototype_sync "https://github.com/aana123/syntra/blob/main/src/app/api/ingestion/sync-prototype/route.ts"
click node_log_api "https://github.com/aana123/syntra/blob/main/src/app/api/log/route.ts"
click node_dashboard_api "https://github.com/aana123/syntra/blob/main/src/app/api/dashboard/route.ts"
click node_dashboard_service "https://github.com/aana123/syntra/blob/main/src/services/dashboardService.ts"
click node_snapshot "https://github.com/aana123/syntra/blob/main/src/lib/services/snapshotService.ts"
click node_context "https://github.com/aana123/syntra/blob/main/src/lib/services/aiContextBuilder.ts"
click node_drift "https://github.com/aana123/syntra/blob/main/src/lib/logic/driftEngine.ts"
click node_gemini "https://github.com/aana123/syntra/blob/main/src/lib/services/gemini.ts"
click node_goals "https://github.com/aana123/syntra/blob/main/src/app/api/goals/route.ts"
click node_gamification "https://github.com/aana123/syntra/blob/main/src/app/api/goals/gamification/route.ts"
click node_simulator "https://github.com/aana123/syntra/blob/main/src/app/api/simulate/route.ts"
click node_auth "https://github.com/aana123/syntra/blob/main/src/lib/auth.ts"
click node_user_model "https://github.com/aana123/syntra/blob/main/src/models/User.ts"
click node_log_model "https://github.com/aana123/syntra/blob/main/src/models/Log.ts"
click node_asset_model "https://github.com/aana123/syntra/blob/main/src/models/AssetLiability.ts"
click node_mongo "https://github.com/aana123/syntra/blob/main/src/lib/database/mongodb.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_onboarding,node_dashboard,node_chat,node_networth,node_user toneBlue
class node_ingestion_ui,node_uploader,node_document_ingest,node_batch_import,node_fit_sync,node_prototype_sync toneAmber
class node_log_api,node_dashboard_api,node_dashboard_service,node_snapshot,node_context,node_drift,node_gemini toneMint
class node_goals,node_gamification,node_simulator toneRose
class node_auth,node_user_model,node_log_model,node_asset_model,node_mongo toneIndigo
```

## Components

### User Experience

- [Onboarding](https://github.com/aana123/syntra/blob/main/src/app/onboarding/page.tsx): `src/app/onboarding/page.tsx`
- [Twin Dashboard](https://github.com/aana123/syntra/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Twin Chat](https://github.com/aana123/syntra/blob/main/src/components/ChatWidget.tsx): `src/components/ChatWidget.tsx`
- [Net Worth View](https://github.com/aana123/syntra/blob/main/src/components/NetWorthPanel.tsx): `src/components/NetWorthPanel.tsx`

### Data Ingestion

- [Ingestion UI](https://github.com/aana123/syntra/blob/main/src/app/ingestion/page.tsx): `src/app/ingestion/page.tsx`
- [Document Uploader](https://github.com/aana123/syntra/blob/main/src/components/Uploader.tsx): `src/components/Uploader.tsx`
- [Document Extraction](https://github.com/aana123/syntra/blob/main/src/app/api/ingestion/upload/route.ts): `src/app/api/ingestion/upload/route.ts`
- [Batch Import](https://github.com/aana123/syntra/blob/main/src/app/api/upload/csv/route.ts): `src/app/api/upload/csv/route.ts`
- [Google Fit Sync](https://github.com/aana123/syntra/blob/main/src/lib/services/googleFitSync.ts): `src/lib/services/googleFitSync.ts`
- [Prototype Sync](https://github.com/aana123/syntra/blob/main/src/app/api/ingestion/sync-prototype/route.ts): `src/app/api/ingestion/sync-prototype/route.ts`

### Twin Intelligence

- [Daily Logging](https://github.com/aana123/syntra/blob/main/src/app/api/log/route.ts): `src/app/api/log/route.ts`
- [Dashboard API](https://github.com/aana123/syntra/blob/main/src/app/api/dashboard/route.ts): `src/app/api/dashboard/route.ts`
- [Dashboard Assembly](https://github.com/aana123/syntra/blob/main/src/services/dashboardService.ts): `src/services/dashboardService.ts`
- [Twin Reflection](https://github.com/aana123/syntra/blob/main/src/lib/services/snapshotService.ts): `src/lib/services/snapshotService.ts`
- [Context Builder](https://github.com/aana123/syntra/blob/main/src/lib/services/aiContextBuilder.ts): `src/lib/services/aiContextBuilder.ts`
- [Drift Analysis](https://github.com/aana123/syntra/blob/main/src/lib/logic/driftEngine.ts): `src/lib/logic/driftEngine.ts`
- [Gemini Service](https://github.com/aana123/syntra/blob/main/src/lib/services/gemini.ts): `src/lib/services/gemini.ts`

### Goals and Simulation

- [Goal Execution](https://github.com/aana123/syntra/blob/main/src/app/api/goals/route.ts): `src/app/api/goals/route.ts`
- [Gamification](https://github.com/aana123/syntra/blob/main/src/app/api/goals/gamification/route.ts): `src/app/api/goals/gamification/route.ts`
- [Scenario Simulator](https://github.com/aana123/syntra/blob/main/src/app/api/simulate/route.ts): `src/app/api/simulate/route.ts`

### Identity and Data

- [Authentication](https://github.com/aana123/syntra/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [User Profile Model](https://github.com/aana123/syntra/blob/main/src/models/User.ts): `src/models/User.ts`
- [Telemetry Log Model](https://github.com/aana123/syntra/blob/main/src/models/Log.ts): `src/models/Log.ts`
- [Asset Model](https://github.com/aana123/syntra/blob/main/src/models/AssetLiability.ts): `src/models/AssetLiability.ts`
- [MongoDB](https://github.com/aana123/syntra/blob/main/src/lib/database/mongodb.ts): `src/lib/database/mongodb.ts`

### Other components

- **User**

## Connections

- User → Onboarding: sets baseline
- User → Ingestion UI: uploads or syncs
- User → Twin Dashboard: reviews twin
- User → Goal Execution: sets goals
- User → Scenario Simulator: tests scenarios
- Ingestion UI → Document Uploader: offers upload
- Document Uploader → Document Extraction: submits document
- Document Extraction → MongoDB: connects database (evidence: `src/app/api/ingestion/upload/route.ts`)
- Document Extraction → Telemetry Log Model: checks and writes logs (evidence: `src/app/api/ingestion/upload/route.ts`)
- Document Extraction → User Profile Model: loads and saves user (evidence: `src/app/api/ingestion/upload/route.ts`)
- Document Extraction → Twin Reflection: schedules reflection (evidence: `src/app/api/ingestion/upload/route.ts`)
- Ingestion UI → Google Fit Sync: connects Google Fit
- Ingestion UI → Batch Import: imports CSV or Excel
- Ingestion UI → Prototype Sync: syncs sample sources
- Daily Logging → Authentication: authenticates (evidence: `src/app/api/log/route.ts`)
- Daily Logging → MongoDB: connects database (evidence: `src/app/api/log/route.ts`)
- Daily Logging → User Profile Model: loads and updates (evidence: `src/app/api/log/route.ts`)
- Daily Logging → Telemetry Log Model: records log (evidence: `src/app/api/log/route.ts`)
- Daily Logging → Twin Reflection: schedules reflection (evidence: `src/app/api/log/route.ts`)
- Twin Dashboard → Dashboard API: requests twin data
- Dashboard API → Dashboard Assembly: serves dashboard
- Dashboard Assembly → MongoDB: connects database (evidence: `src/services/dashboardService.ts`)
- Dashboard Assembly → User Profile Model: loads profile (evidence: `src/services/dashboardService.ts`)
- Dashboard Assembly → Telemetry Log Model: loads recent logs (evidence: `src/services/dashboardService.ts`)
- Twin Chat → User: supports coaching
- Twin Reflection → Context Builder: builds twin context (evidence: `src/lib/services/snapshotService.ts`)
- Twin Reflection → Drift Analysis: analyzes divergence (evidence: `src/lib/services/snapshotService.ts`)
- Twin Reflection → Gemini Service: generates reflection (evidence: `src/lib/services/snapshotService.ts`)
- Goal Execution → Gamification: tracks rewards
- Scenario Simulator → MongoDB: connects database (evidence: `src/app/api/simulate/route.ts`)
- Scenario Simulator → User Profile Model: loads user goals (evidence: `src/app/api/simulate/route.ts`)
- Scenario Simulator → Asset Model: uses financial state (evidence: `src/app/api/simulate/route.ts`)
- Scenario Simulator → Gemini Service: requests insight
- Authentication → User Profile Model: authenticates accounts
