# rajput-devyansh/wealth-copilot architecture

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

- Interactive diagram: https://gitdiagram.com/rajput-devyansh/wealth-copilot
- Repository: https://github.com/rajput-devyansh/wealth-copilot

## Overview

Wealth Copilot is a digital wealth-management app: customers select a demo profile or create a persona, then explore financial dashboards, goals, insights, profile settings, and an AI copilot. The backend serves those domains from local JSON-backed state, computes financial metrics and recommendations, and offers text and streaming voice AI. The graph preserves the documented multilingual voice, risk-profiling, proactive-insight, and adaptive-theme capabilities. Some page-to-API wiring is not shown in the sampled source, so those relationships are omitted.

Main entry points: [`frontend/src/App.tsx`](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/App.tsx) (App and routing), [`backend/src/db/database.ts`](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/db/database.ts) (State persistence), [`backend/src/server.ts`](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/server.ts) (Express server), [`backend/src/services/financials.ts`](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/services/financials.ts) (Financial calculations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Customer experience"]
  node_app["App and routing<br/>[App.tsx]"]
  node_login["Demo login<br/>[Login.tsx]"]
  node_persona["Persona setup<br/>[CreatePersona.tsx]"]
  node_layout["App layout<br/>[AppLayout.tsx]"]
  node_dashboard_ui["Dashboard view<br/>[Dashboard.tsx]"]
  node_goals_ui["Goals view<br/>[Goals.tsx]"]
  node_insights_ui["Insights view<br/>[Insights.tsx]"]
  node_profile_ui["Profile settings<br/>[Profile.tsx]"]
  node_copilot_ui["Copilot interface<br/>[Copilot.tsx]"]
  node_avatar["Voice avatar<br/>[Avatar.tsx]"]
end

subgraph group_planning["Financial planning"]
  node_dashboard_api["Dashboard routes<br/>[dashboard.ts]"]
  node_goals_api["Goals routes<br/>[goals.ts]"]
  node_portfolio_api["Portfolio routes<br/>[portfolio.ts]"]
  node_profile_api["Profile routes<br/>[profile.ts]"]
  node_financials["Financial calculations<br/>[financials.ts]"]
end

subgraph group_intelligence["AI assistance"]
  node_copilot_api["Copilot routes<br/>[copilot.ts]"]
  node_voice["Voice streaming<br/>[voice.ts]"]
  node_gemini_service["Gemini text service<br/>[gemini.ts]"]
end

subgraph group_platform["Backend platform"]
  node_auth["Authentication routes<br/>[auth.ts]"]
  node_server["Express server<br/>[server.ts]"]
  node_database["State persistence<br/>[database.ts]"]
  node_state_file[("Local JSON state<br/>[db_state.json]")]
end

node_customer(("Customer"))
node_gemini{{"Google Gemini"}}

node_customer -->|"uses"| node_app
node_app -->|"renders"| node_login
node_app -->|"renders"| node_persona
node_app -->|"renders"| node_layout
node_app -->|"renders"| node_dashboard_ui
node_app -->|"renders"| node_goals_ui
node_app -->|"renders"| node_insights_ui
node_app -->|"renders"| node_profile_ui
node_app -->|"renders"| node_copilot_ui
node_copilot_ui -->|"uses"| node_avatar
node_app -->|"requests demo login"| node_auth
node_server -->|"mounts"| node_auth
node_server -->|"mounts"| node_profile_api
node_server -->|"mounts"| node_goals_api
node_server -->|"mounts"| node_dashboard_api
node_server -->|"mounts"| node_copilot_api
node_server -->|"mounts"| node_portfolio_api
node_server -->|"sets up"| node_voice
node_auth -->|"reads and reseeds"| node_database
node_profile_api -->|"uses state"| node_database
node_goals_api -->|"uses state"| node_database
node_dashboard_api -->|"reads state"| node_database
node_dashboard_api -->|"computes metrics"| node_financials
node_portfolio_api -->|"uses state"| node_database
node_portfolio_api -->|"computes metrics"| node_financials
node_copilot_api -->|"reads user context"| node_database
node_copilot_api -->|"computes recommendations"| node_financials
node_copilot_api -->|"generates response"| node_gemini_service
node_voice -->|"reads user state"| node_database
node_voice -->|"computes context"| node_financials
node_voice -->|"streams audio session"| node_gemini
node_gemini_service -->|"calls model"| node_gemini
node_financials -->|"reads financial data"| node_database
node_database -->|"loads and saves"| node_state_file

click node_app "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/App.tsx"
click node_login "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Login.tsx"
click node_persona "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/CreatePersona.tsx"
click node_layout "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/components/AppLayout.tsx"
click node_dashboard_ui "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Dashboard.tsx"
click node_goals_ui "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Goals.tsx"
click node_insights_ui "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Insights.tsx"
click node_profile_ui "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Profile.tsx"
click node_copilot_ui "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Copilot.tsx"
click node_avatar "https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/components/Avatar.tsx"
click node_auth "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/auth.ts"
click node_dashboard_api "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/dashboard.ts"
click node_goals_api "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/goals.ts"
click node_portfolio_api "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/portfolio.ts"
click node_profile_api "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/profile.ts"
click node_financials "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/services/financials.ts"
click node_copilot_api "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/copilot.ts"
click node_voice "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/websocket/voice.ts"
click node_gemini_service "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/services/gemini.ts"
click node_server "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/server.ts"
click node_database "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/db/database.ts"
click node_state_file "https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/db/db_state.json"

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_login,node_persona,node_layout,node_dashboard_ui,node_goals_ui,node_insights_ui,node_profile_ui,node_copilot_ui,node_avatar toneBlue
class node_dashboard_api,node_goals_api,node_portfolio_api,node_profile_api,node_financials toneAmber
class node_copilot_api,node_voice,node_gemini_service toneMint
class node_auth,node_server,node_database,node_state_file toneRose
class node_customer,node_gemini toneIndigo
```

## Components

### Customer experience

- [App and routing](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Demo login](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Login.tsx): `frontend/src/pages/Login.tsx`
- [Persona setup](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/CreatePersona.tsx): `frontend/src/pages/CreatePersona.tsx`
- [App layout](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/components/AppLayout.tsx): `frontend/src/components/AppLayout.tsx`
- [Dashboard view](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [Goals view](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Goals.tsx): `frontend/src/pages/Goals.tsx`
- [Insights view](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Insights.tsx): `frontend/src/pages/Insights.tsx`
- [Profile settings](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Profile.tsx): `frontend/src/pages/Profile.tsx`
- [Copilot interface](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/pages/Copilot.tsx): `frontend/src/pages/Copilot.tsx`
- [Voice avatar](https://github.com/rajput-devyansh/wealth-copilot/blob/main/frontend/src/components/Avatar.tsx): `frontend/src/components/Avatar.tsx`

### Financial planning

- [Dashboard routes](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/dashboard.ts): `backend/src/routes/dashboard.ts`
- [Goals routes](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/goals.ts): `backend/src/routes/goals.ts`
- [Portfolio routes](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/portfolio.ts): `backend/src/routes/portfolio.ts`
- [Profile routes](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/profile.ts): `backend/src/routes/profile.ts`
- [Financial calculations](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/services/financials.ts): `backend/src/services/financials.ts`

### AI assistance

- [Copilot routes](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/copilot.ts): `backend/src/routes/copilot.ts`
- [Voice streaming](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/websocket/voice.ts): `backend/src/websocket/voice.ts`
- [Gemini text service](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/services/gemini.ts): `backend/src/services/gemini.ts`

### Backend platform

- [Authentication routes](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/routes/auth.ts): `backend/src/routes/auth.ts`
- [Express server](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/server.ts): `backend/src/server.ts`
- [State persistence](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/db/database.ts): `backend/src/db/database.ts`
- [Local JSON state](https://github.com/rajput-devyansh/wealth-copilot/blob/main/backend/src/db/db_state.json): `backend/src/db/db_state.json`

### Other components

- **Customer**
- **Google Gemini**

## Connections

- Customer → App and routing: uses
- App and routing → Demo login: renders (evidence: `frontend/src/App.tsx`)
- App and routing → Persona setup: renders (evidence: `frontend/src/App.tsx`)
- App and routing → App layout: renders (evidence: `frontend/src/App.tsx`)
- App and routing → Dashboard view: renders (evidence: `frontend/src/App.tsx`)
- App and routing → Goals view: renders (evidence: `frontend/src/App.tsx`)
- App and routing → Insights view: renders (evidence: `frontend/src/App.tsx`)
- App and routing → Profile settings: renders (evidence: `frontend/src/App.tsx`)
- App and routing → Copilot interface: renders (evidence: `frontend/src/App.tsx`)
- Copilot interface → Voice avatar: uses (evidence: `frontend/src/pages/Copilot.tsx`)
- App and routing → Authentication routes: requests demo login (evidence: `frontend/src/App.tsx`)
- Express server → Authentication routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Profile routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Goals routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Dashboard routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Copilot routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Portfolio routes: mounts (evidence: `backend/src/server.ts`)
- Express server → Voice streaming: sets up (evidence: `backend/src/server.ts`)
- Authentication routes → State persistence: reads and reseeds (evidence: `backend/src/routes/auth.ts`)
- Profile routes → State persistence: uses state (evidence: `backend/src/routes/profile.ts`)
- Goals routes → State persistence: uses state (evidence: `backend/src/routes/goals.ts`)
- Dashboard routes → State persistence: reads state (evidence: `backend/src/routes/dashboard.ts`)
- Dashboard routes → Financial calculations: computes metrics (evidence: `backend/src/routes/dashboard.ts`)
- Portfolio routes → State persistence: uses state (evidence: `backend/src/routes/portfolio.ts`)
- Portfolio routes → Financial calculations: computes metrics (evidence: `backend/src/routes/portfolio.ts`)
- Copilot routes → State persistence: reads user context (evidence: `backend/src/routes/copilot.ts`)
- Copilot routes → Financial calculations: computes recommendations (evidence: `backend/src/routes/copilot.ts`)
- Copilot routes → Gemini text service: generates response (evidence: `backend/src/routes/copilot.ts`)
- Voice streaming → State persistence: reads user state (evidence: `backend/src/websocket/voice.ts`)
- Voice streaming → Financial calculations: computes context (evidence: `backend/src/websocket/voice.ts`)
- Voice streaming → Google Gemini: streams audio session (evidence: `backend/src/websocket/voice.ts`)
- Gemini text service → Google Gemini: calls model (evidence: `backend/src/services/gemini.ts`)
- Financial calculations → State persistence: reads financial data (evidence: `backend/src/services/financials.ts`)
- State persistence → Local JSON state: loads and saves (evidence: `backend/src/db/database.ts`)
