# yogeshwanth2005/finance architecture

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

- Interactive diagram: https://gitdiagram.com/yogeshwanth2005/finance
- Repository: https://github.com/yogeshwanth2005/finance

## Overview

Fin (SurakshaCFO) is a personal-finance and insurance-gap application. A family submits a profile, receives protection and investment estimates, browses published insurance plans, and can ask a multilingual advisor questions grounded in its profile and indexed policy documents. Admins upload documents, review extracted plan-card drafts, and publish cards. The graph includes the documented fund-data and account capabilities; some frontend-to-API links are dashed because the relevant page implementations were not sampled.

Main entry points: [`backend/routers/profile.py`](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/profile.py) (Family profile), [`backend/routers/chat.py`](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/chat.py) (Advisor chat), [`frontend/src/lib/api.ts`](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/lib/api.ts) (Typed API client), [`frontend/src/App.tsx`](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/App.tsx) (Page routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Family interface"]
  node_app["Page routing<br/>[App.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_insurance["Insurance browser<br/>[Insurance.tsx]"]
  node_investments["Investments page<br/>[Investments.tsx]"]
  node_admin_ui["Document manager<br/>[AdminDocuments.tsx]"]
  node_api_client["Typed API client<br/>[api.ts]"]
end

subgraph group_accounts["Accounts and profiles"]
  node_auth_routes["Authentication<br/>[auth.py]"]
  node_auth_core["Session security<br/>[auth.py]"]
  node_profile_routes["Family profile<br/>[profile.py]"]
  node_profile_models["Profile models<br/>[profile.py]"]
end

subgraph group_advice["Advice and plans"]
  node_chat_routes["Advisor chat<br/>[chat.py]"]
  node_chat_context["Chat context<br/>[chat_context.py]"]
  node_rag["Policy retrieval<br/>[rag.py]"]
  node_llm["LLM adapter<br/>[llm.py]"]
  node_admin_routes["Document administration<br/>[admin.py]"]
  node_extract["Plan extraction<br/>[plan_extract.py]"]
  node_plan_routes["Published plans<br/>[plans.py]"]
  node_plan_models["Plan and chat models<br/>[rag.py]"]
end

subgraph group_funds["Funds and estimates"]
  node_allocation["Allocation estimates<br/>[allocation.py]"]
  node_finance_config["Finance assumptions<br/>[finance_config.py]"]
  node_fund_routes["Fund API<br/>[funds.py]"]
  node_fund_store["Fund catalog and refresh<br/>[fund_store.py]"]
  node_fund_repo["Fund persistence<br/>[fund_repo.py]"]
end

node_family(("Family user"))
node_admin(("Admin user"))
node_mongo[("MongoDB")]
node_groq["Groq API"]
node_amfi["AMFI data"]

node_family -->|"uses"| node_app
node_admin -->|"manages documents"| node_admin_ui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_insurance
node_app -->|"routes to"| node_investments
node_dashboard -.->|"requests data"| node_api_client
node_insurance -.->|"requests plans"| node_api_client
node_investments -.->|"requests funds"| node_api_client
node_admin_ui -.->|"manages documents"| node_api_client
node_api_client -.->|"calls API"| node_auth_routes
node_auth_routes -->|"uses security"| node_auth_core
node_auth_routes -->|"reads and writes"| node_mongo
node_auth_core -->|"reads users"| node_mongo
node_profile_routes -->|"reads and writes"| node_mongo
node_profile_routes -->|"computes estimates"| node_allocation
node_profile_routes -->|"validates profile"| node_profile_models
node_chat_routes -->|"reads and writes"| node_mongo
node_chat_routes -->|"retrieves policy text"| node_rag
node_chat_routes -->|"builds answer context"| node_chat_context
node_chat_routes -->|"streams answers"| node_llm
node_rag -->|"reads indexed chunks"| node_mongo
node_rag -->|"ranks document chunks"| node_chat_context
node_llm -->|"requests completions"| node_groq
node_admin_routes -->|"manages documents"| node_mongo
node_admin_routes -->|"indexes documents"| node_rag
node_admin_routes -->|"drafts plan cards"| node_extract
node_extract -->|"extracts plan fields"| node_llm
node_extract -->|"validates plan fields"| node_plan_models
node_plan_routes -->|"reads published plans"| node_mongo
node_family -.->|"submits finances"| node_profile_routes
node_family -->|"asks advisor"| node_chat_routes
node_family -->|"browses plans"| node_plan_routes
node_profile_routes -->|"uses assumptions"| node_finance_config
node_fund_routes -->|"serves fund data"| node_fund_store
node_fund_store -->|"persists fund rows"| node_fund_repo
node_fund_repo -->|"stores fund rows"| node_mongo
node_fund_store -->|"refreshes NAV data"| node_amfi
node_family -.->|"explores funds"| node_fund_routes

click node_app "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/App.tsx"
click node_dashboard "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/pages/Dashboard.tsx"
click node_insurance "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/pages/Insurance.tsx"
click node_investments "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/pages/Investments.tsx"
click node_admin_ui "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/pages/AdminDocuments.tsx"
click node_api_client "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/lib/api.ts"
click node_auth_routes "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/auth.py"
click node_auth_core "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/auth.py"
click node_profile_routes "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/profile.py"
click node_profile_models "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/models/profile.py"
click node_chat_routes "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/chat.py"
click node_chat_context "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/chat_context.py"
click node_rag "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/rag.py"
click node_llm "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/llm.py"
click node_admin_routes "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/admin.py"
click node_extract "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/plan_extract.py"
click node_plan_routes "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/plans.py"
click node_plan_models "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/models/rag.py"
click node_allocation "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/allocation.py"
click node_finance_config "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/finance_config.py"
click node_fund_routes "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/funds.py"
click node_fund_store "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/fund_store.py"
click node_fund_repo "https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/fund_repo.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_app,node_dashboard,node_insurance,node_investments,node_admin_ui,node_api_client,node_family,node_admin toneBlue
class node_auth_routes,node_auth_core,node_profile_routes,node_profile_models,node_mongo toneAmber
class node_chat_routes,node_chat_context,node_rag,node_llm,node_admin_routes,node_extract,node_plan_routes,node_plan_models,node_groq toneMint
class node_allocation,node_finance_config,node_fund_routes,node_fund_store,node_fund_repo toneRose
class node_amfi toneIndigo
```

## Components

### Family interface

- [Page routing](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Dashboard](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [Insurance browser](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/pages/Insurance.tsx): `frontend/src/pages/Insurance.tsx`
- [Investments page](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/pages/Investments.tsx): `frontend/src/pages/Investments.tsx`
- [Document manager](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/pages/AdminDocuments.tsx): `frontend/src/pages/AdminDocuments.tsx`
- [Typed API client](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### Accounts and profiles

- [Authentication](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/auth.py): `backend/routers/auth.py`
- [Session security](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/auth.py): `backend/lib/auth.py`
- [Family profile](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/profile.py): `backend/routers/profile.py`
- [Profile models](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/models/profile.py): `backend/models/profile.py`

### Advice and plans

- [Advisor chat](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/chat.py): `backend/routers/chat.py`
- [Chat context](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/chat_context.py): `backend/lib/chat_context.py`
- [Policy retrieval](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/rag.py): `backend/lib/rag.py`
- [LLM adapter](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/llm.py): `backend/lib/llm.py`
- [Document administration](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/admin.py): `backend/routers/admin.py`
- [Plan extraction](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/plan_extract.py): `backend/lib/plan_extract.py`
- [Published plans](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/plans.py): `backend/routers/plans.py`
- [Plan and chat models](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/models/rag.py): `backend/models/rag.py`

### Funds and estimates

- [Allocation estimates](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/allocation.py): `backend/lib/allocation.py`
- [Finance assumptions](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/finance_config.py): `backend/lib/finance_config.py`
- [Fund API](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/routers/funds.py): `backend/routers/funds.py`
- [Fund catalog and refresh](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/fund_store.py): `backend/lib/fund_store.py`
- [Fund persistence](https://github.com/yogeshwanth2005/finance/blob/feature/fin-v2-implementation/backend/lib/fund_repo.py): `backend/lib/fund_repo.py`

### Other components

- **Family user**
- **Admin user**
- **MongoDB**
- **Groq API**
- **AMFI data**

## Connections

- Family user → Page routing: uses (evidence: `README.md`)
- Admin user → Document manager: manages documents (evidence: `README.md`)
- Page routing → Dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Page routing → Insurance browser: routes to (evidence: `frontend/src/App.tsx`)
- Page routing → Investments page: routes to (evidence: `frontend/src/App.tsx`)
- Dashboard → Typed API client: requests data
- Insurance browser → Typed API client: requests plans
- Investments page → Typed API client: requests funds
- Document manager → Typed API client: manages documents
- Typed API client → Authentication: calls API
- Authentication → Session security: uses security (evidence: `backend/routers/auth.py`)
- Authentication → MongoDB: reads and writes (evidence: `backend/routers/auth.py`)
- Session security → MongoDB: reads users (evidence: `backend/lib/auth.py`)
- Family profile → MongoDB: reads and writes (evidence: `backend/routers/profile.py`)
- Family profile → Allocation estimates: computes estimates (evidence: `backend/routers/profile.py`)
- Family profile → Profile models: validates profile (evidence: `backend/routers/profile.py`)
- Advisor chat → MongoDB: reads and writes (evidence: `backend/routers/chat.py`)
- Advisor chat → Policy retrieval: retrieves policy text (evidence: `README.md`)
- Advisor chat → Chat context: builds answer context (evidence: `README.md`)
- Advisor chat → LLM adapter: streams answers (evidence: `README.md`)
- Policy retrieval → MongoDB: reads indexed chunks (evidence: `backend/lib/rag.py`)
- Policy retrieval → Chat context: ranks document chunks (evidence: `backend/lib/rag.py`)
- LLM adapter → Groq API: requests completions (evidence: `backend/lib/llm.py`)
- Document administration → MongoDB: manages documents (evidence: `README.md`)
- Document administration → Policy retrieval: indexes documents (evidence: `README.md`)
- Document administration → Plan extraction: drafts plan cards (evidence: `README.md`)
- Plan extraction → LLM adapter: extracts plan fields (evidence: `backend/lib/plan_extract.py`)
- Plan extraction → Plan and chat models: validates plan fields (evidence: `backend/lib/plan_extract.py`)
- Published plans → MongoDB: reads published plans (evidence: `README.md`)
- Family user → Family profile: submits finances
- Family user → Advisor chat: asks advisor (evidence: `README.md`)
- Family user → Published plans: browses plans (evidence: `README.md`)
- Family profile → Finance assumptions: uses assumptions (evidence: `backend/routers/profile.py`)
- Fund API → Fund catalog and refresh: serves fund data (evidence: `README.md`)
- Fund catalog and refresh → Fund persistence: persists fund rows (evidence: `backend/lib/fund_store.py`)
- Fund persistence → MongoDB: stores fund rows (evidence: `backend/lib/fund_repo.py`)
- Fund catalog and refresh → AMFI data: refreshes NAV data
- Family user → Fund API: explores funds
