# platypus12345/allowanceai architecture

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

- Interactive diagram: https://gitdiagram.com/platypus12345/allowanceai
- Repository: https://github.com/platypus12345/allowanceai

## Overview

AllowanceAI is a student personal-finance assistant, currently rebuilding its core on PostgreSQL and pgvector. The main journey is account setup and allowance entry, transaction capture by hand, Android SMS, or Setu Account Aggregator, duplicate-aware persistence, a safe-to-spend dashboard, then plain-English questions answered with transaction citations and SQL-grounded totals. The map also preserves reporting, live updates, and hybrid retrieval. Relationships across unsampled routes and mobile screens rely on README documentation; source excerpts confirm ingestion and dashboard internals, but not every UI-to-API call.

Main entry points: [`server/routes/ingest.js`](https://github.com/platypus12345/allowanceai/blob/main/server/routes/ingest.js) (Ingestion routes), [`ai-service/rag/api.py`](https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/api.py) (RAG API), [`client/src/App.jsx`](https://github.com/platypus12345/allowanceai/blob/main/client/src/App.jsx) (Web app routes), [`server/services/dashboardService.js`](https://github.com/platypus12345/allowanceai/blob/main/server/services/dashboardService.js) (Dashboard aggregates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web experience"]
  node_web["Web app routes<br/>[App.jsx]"]
  node_auth["Authentication<br/>[AuthContext.jsx]"]
  node_dashboard_ui["Dashboard UI"]
  node_reports_ui["Monthly reports"]
end

subgraph group_server["Finance API"]
  node_api["Express API<br/>[index.js]"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_ingest_route["Ingestion routes<br/>[ingest.js]"]
  node_ingest_service["Parse and deduplicate<br/>[ingestService.js]"]
  node_dashboard_service["Dashboard aggregates"]
  node_health["Safe-to-spend health<br/>[financialHealth.js]"]
  node_realtime["Live updates<br/>[realtime.js]"]
  node_assistant_client["Assistant bridge<br/>[assistantClient.js]"]
end

subgraph group_assistant["Grounded assistant"]
  node_rag_api["RAG API<br/>[api.py]"]
  node_indexer["Transaction indexing<br/>[indexer.py]"]
  node_embeddings["Local embeddings<br/>[embeddings.py]"]
  node_retrieval["Hybrid retrieval<br/>[retrieval.py]"]
  node_rag_graph["Answer workflow<br/>[graph.py]"]
  node_llm["LLM provider<br/>[llm.py]"]
end

subgraph group_mobile["Mobile ingestion"]
  node_mobile_ui["Mobile screens<br/>[index.tsx]"]
  node_sms_capture["SMS capture<br/>[smsParser.ts]"]
  node_sms_client["Ingest client<br/>[ingestClient.ts]"]
end

subgraph group_state["Shared state"]
  node_transactions[("Transaction records<br/>[Expense.js]")]
  node_postgres[("PostgreSQL + pgvector")]
end

node_student(("Student"))
node_sms_source(("Bank SMS"))
node_setu{{"Setu Account Aggregator"}}

node_student -->|"opens app"| node_web
node_web -->|"provides auth"| node_auth
node_web -->|"routes to"| node_dashboard_ui
node_web -->|"routes to"| node_reports_ui
node_student -->|"uses"| node_mobile_ui
node_sms_source -->|"provides messages"| node_sms_capture
node_sms_capture -.->|"submits parsed data"| node_sms_client
node_sms_client -->|"sends transactions"| node_ingest_route
node_setu -->|"supplies bank data"| node_ingest_route
node_student -->|"enters transactions"| node_ingest_route
node_api -->|"mounts routes"| node_auth_routes
node_api -->|"mounts routes"| node_ingest_route
node_ingest_route -->|"delegates ingestion"| node_ingest_service
node_ingest_service -->|"writes deduplicated rows"| node_transactions
node_transactions -->|"stored in"| node_postgres
node_ingest_route -->|"invalidates summary"| node_dashboard_service
node_ingest_route -->|"publishes update"| node_realtime
node_ingest_route -->|"requests indexing"| node_assistant_client
node_dashboard_ui -->|"loads summary"| node_dashboard_service
node_dashboard_service -->|"uses health logic"| node_health
node_dashboard_service -->|"aggregates transactions"| node_postgres
node_realtime -->|"pushes updates"| node_dashboard_ui
node_assistant_client -->|"calls assistant"| node_rag_api
node_rag_api -->|"indexes transactions"| node_indexer
node_indexer -.->|"embeds records"| node_embeddings
node_rag_api -->|"retrieves evidence"| node_retrieval
node_retrieval -->|"embeds queries"| node_embeddings
node_retrieval -->|"searches vectors and text"| node_postgres
node_rag_api -.->|"runs answer workflow"| node_rag_graph
node_rag_graph -.->|"generates answer"| node_llm
node_rag_api -->|"returns cited answer"| node_student
node_reports_ui -.->|"shows report"| node_student

click node_web "https://github.com/platypus12345/allowanceai/blob/main/client/src/App.jsx"
click node_auth "https://github.com/platypus12345/allowanceai/blob/main/client/src/context/AuthContext.jsx"
click node_dashboard_ui "https://github.com/platypus12345/allowanceai/blob/main/client/src/pages/DashboardV2Page.jsx"
click node_reports_ui "https://github.com/platypus12345/allowanceai/blob/main/client/src/pages/MonthReportPage.jsx"
click node_mobile_ui "https://github.com/platypus12345/allowanceai/blob/main/mobile/app/(tabs)/index.tsx"
click node_sms_capture "https://github.com/platypus12345/allowanceai/blob/main/mobile/src/services/smsParser.ts"
click node_sms_client "https://github.com/platypus12345/allowanceai/blob/main/mobile/src/api/ingestClient.ts"
click node_api "https://github.com/platypus12345/allowanceai/blob/main/server/index.js"
click node_auth_routes "https://github.com/platypus12345/allowanceai/blob/main/server/routes/auth.js"
click node_ingest_route "https://github.com/platypus12345/allowanceai/blob/main/server/routes/ingest.js"
click node_ingest_service "https://github.com/platypus12345/allowanceai/blob/main/server/services/ingestService.js"
click node_transactions "https://github.com/platypus12345/allowanceai/blob/main/server/models/Expense.js"
click node_dashboard_service "https://github.com/platypus12345/allowanceai/blob/main/server/services/dashboardService.js"
click node_health "https://github.com/platypus12345/allowanceai/blob/main/server/utils/financialHealth.js"
click node_realtime "https://github.com/platypus12345/allowanceai/blob/main/server/services/realtime.js"
click node_assistant_client "https://github.com/platypus12345/allowanceai/blob/main/server/services/assistantClient.js"
click node_rag_api "https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/api.py"
click node_indexer "https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/indexer.py"
click node_embeddings "https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/embeddings.py"
click node_retrieval "https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/retrieval.py"
click node_rag_graph "https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/graph.py"
click node_llm "https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/llm.py"

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_web,node_auth,node_dashboard_ui,node_reports_ui toneBlue
class node_api,node_auth_routes,node_ingest_route,node_ingest_service,node_dashboard_service,node_health,node_realtime,node_assistant_client toneAmber
class node_rag_api,node_indexer,node_embeddings,node_retrieval,node_rag_graph,node_llm toneMint
class node_mobile_ui,node_sms_capture,node_sms_client toneRose
class node_transactions,node_postgres,node_student,node_sms_source,node_setu toneIndigo
```

## Components

### Web experience

- [Web app routes](https://github.com/platypus12345/allowanceai/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Authentication](https://github.com/platypus12345/allowanceai/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Dashboard UI](https://github.com/platypus12345/allowanceai/blob/main/client/src/pages/DashboardV2Page.jsx): `client/src/pages/DashboardV2Page.jsx`
- [Monthly reports](https://github.com/platypus12345/allowanceai/blob/main/client/src/pages/MonthReportPage.jsx): `client/src/pages/MonthReportPage.jsx`

### Finance API

- [Express API](https://github.com/platypus12345/allowanceai/blob/main/server/index.js): `server/index.js`
- [Auth routes](https://github.com/platypus12345/allowanceai/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [Ingestion routes](https://github.com/platypus12345/allowanceai/blob/main/server/routes/ingest.js): `server/routes/ingest.js`
- [Parse and deduplicate](https://github.com/platypus12345/allowanceai/blob/main/server/services/ingestService.js): `server/services/ingestService.js`
- [Dashboard aggregates](https://github.com/platypus12345/allowanceai/blob/main/server/services/dashboardService.js): `server/services/dashboardService.js`
- [Safe-to-spend health](https://github.com/platypus12345/allowanceai/blob/main/server/utils/financialHealth.js): `server/utils/financialHealth.js`
- [Live updates](https://github.com/platypus12345/allowanceai/blob/main/server/services/realtime.js): `server/services/realtime.js`
- [Assistant bridge](https://github.com/platypus12345/allowanceai/blob/main/server/services/assistantClient.js): `server/services/assistantClient.js`

### Grounded assistant

- [RAG API](https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/api.py): `ai-service/rag/api.py`
- [Transaction indexing](https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/indexer.py): `ai-service/rag/indexer.py`
- [Local embeddings](https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/embeddings.py): `ai-service/rag/embeddings.py`
- [Hybrid retrieval](https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/retrieval.py): `ai-service/rag/retrieval.py`
- [Answer workflow](https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/graph.py): `ai-service/rag/graph.py`
- [LLM provider](https://github.com/platypus12345/allowanceai/blob/main/ai-service/rag/llm.py): `ai-service/rag/llm.py`

### Mobile ingestion

- [Mobile screens](https://github.com/platypus12345/allowanceai/blob/main/mobile/app/(tabs)/index.tsx): `mobile/app/(tabs)/index.tsx`
- [SMS capture](https://github.com/platypus12345/allowanceai/blob/main/mobile/src/services/smsParser.ts): `mobile/src/services/smsParser.ts`
- [Ingest client](https://github.com/platypus12345/allowanceai/blob/main/mobile/src/api/ingestClient.ts): `mobile/src/api/ingestClient.ts`

### Shared state

- [Transaction records](https://github.com/platypus12345/allowanceai/blob/main/server/models/Expense.js): `server/models/Expense.js`
- **PostgreSQL + pgvector**

### Other components

- **Student**
- **Bank SMS**
- **Setu Account Aggregator**

## Connections

- Student → Web app routes: opens app (evidence: `client/src/App.jsx`)
- Web app routes → Authentication: provides auth (evidence: `client/src/App.jsx`)
- Web app routes → Dashboard UI: routes to (evidence: `client/src/App.jsx`)
- Web app routes → Monthly reports: routes to (evidence: `client/src/App.jsx`)
- Student → Mobile screens: uses (evidence: `README.md`)
- Bank SMS → SMS capture: provides messages (evidence: `README.md`)
- SMS capture → Ingest client: submits parsed data
- Ingest client → Ingestion routes: sends transactions (evidence: `README.md`)
- Setu Account Aggregator → Ingestion routes: supplies bank data (evidence: `README.md`)
- Student → Ingestion routes: enters transactions (evidence: `README.md`)
- Express API → Auth routes: mounts routes (evidence: `server/index.js`)
- Express API → Ingestion routes: mounts routes (evidence: `server/index.js`)
- Ingestion routes → Parse and deduplicate: delegates ingestion (evidence: `server/routes/ingest.js`)
- Parse and deduplicate → Transaction records: writes deduplicated rows (evidence: `server/services/ingestService.js`)
- Transaction records → PostgreSQL + pgvector: stored in (evidence: `README.md`)
- Ingestion routes → Dashboard aggregates: invalidates summary (evidence: `server/routes/ingest.js`)
- Ingestion routes → Live updates: publishes update (evidence: `server/routes/ingest.js`)
- Ingestion routes → Assistant bridge: requests indexing (evidence: `server/routes/ingest.js`)
- Dashboard UI → Dashboard aggregates: loads summary (evidence: `README.md`)
- Dashboard aggregates → Safe-to-spend health: uses health logic (evidence: `server/services/dashboardService.js`)
- Dashboard aggregates → PostgreSQL + pgvector: aggregates transactions (evidence: `server/services/dashboardService.js`)
- Live updates → Dashboard UI: pushes updates (evidence: `README.md`)
- Assistant bridge → RAG API: calls assistant (evidence: `README.md`)
- RAG API → Transaction indexing: indexes transactions (evidence: `ai-service/rag/api.py`)
- Transaction indexing → Local embeddings: embeds records
- RAG API → Hybrid retrieval: retrieves evidence (evidence: `ai-service/rag/api.py`)
- Hybrid retrieval → Local embeddings: embeds queries (evidence: `ai-service/rag/retrieval.py`)
- Hybrid retrieval → PostgreSQL + pgvector: searches vectors and text (evidence: `README.md`)
- RAG API → Answer workflow: runs answer workflow (evidence: `ai-service/rag/api.py`)
- Answer workflow → LLM provider: generates answer
- RAG API → Student: returns cited answer (evidence: `README.md`)
- Monthly reports → Student: shows report
