# smbb639/finverse architecture

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

- Interactive diagram: https://gitdiagram.com/smbb639/finverse
- Repository: https://github.com/smbb639/finverse

## Overview

Finverse is a personal-finance web application: users authenticate, record expenses and investments, and view portfolio, budget, and spending insights, with supporting goals, market/news, calculators, chat, and export capabilities. The frontend is a Next.js app backed by an Express API and MongoDB models. The graph emphasizes documented routes and excerpted calls; several feature-specific route/controller links and frontend request paths are unsampled, so those links are not inferred.

Main entry points: [`backend/src/index.ts`](https://github.com/smbb639/finverse/blob/main/backend/src/index.ts) (API server), [`backend/src/services/dashboard.services.ts`](https://github.com/smbb639/finverse/blob/main/backend/src/services/dashboard.services.ts) (Analytics), [`backend/src/controller/investment.controller.ts`](https://github.com/smbb639/finverse/blob/main/backend/src/controller/investment.controller.ts) (Portfolio management), [`backend/src/services/expense.services.ts`](https://github.com/smbb639/finverse/blob/main/backend/src/services/expense.services.ts) (Expense management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Finance interface"]
  node_dashboard_ui["Dashboard<br/>[page.tsx]"]
  node_expense_ui["Expenses<br/>[page.tsx]"]
  node_investment_ui["Portfolio<br/>[page.tsx]"]
  node_goals_ui["Goals<br/>[page.tsx]"]
  node_news_ui["Financial news<br/>[page.tsx]"]
  node_calculators_ui["Calculators<br/>[page.tsx]"]
  node_chat_ui["Chat assistant<br/>[Chatbot.tsx]"]
  node_dashboard_hook["Dashboard query<br/>[useDashboard.ts]"]
  node_dashboard_client["Dashboard API client<br/>[dashboard.ts]"]
end

subgraph group_api["Backend API"]
  node_server["API server<br/>[index.ts]"]
  node_auth_routes["Authentication routes<br/>[auth.route.ts]"]
  node_expense_routes["Expense routes<br/>[expense.route.ts]"]
  node_dashboard_routes["Dashboard routes<br/>[dashboard.route.ts]"]
  node_chat_routes["Chat routes<br/>[chat.routes.ts]"]
end

subgraph group_domain["Finance services"]
  node_auth_service["Authentication<br/>[auth.services.ts]"]
  node_expense_service["Expense management"]
  node_dashboard_service["Analytics"]
  node_investment_controller["Portfolio management"]
  node_market_pricing["Market pricing"]
  node_goal_service["Goal management<br/>[goal.services.ts]"]
  node_metrics_service["Metrics<br/>[metrics.service.ts]"]
  node_chat_controller["Chat handling<br/>[chat.controller.ts]"]
  node_gemini_service["Gemini integration<br/>[gemini.service.ts]"]
  node_expense_controller["Expense handling"]
  node_dashboard_controller["Dashboard handling"]
  node_auth_controller["Auth handling<br/>[auth.controller.ts]"]
end

subgraph group_storage["MongoDB records"]
  node_expense_model[("Expenses<br/>[Expense.ts]")]
  node_investment_model[("Investments<br/>[Investment.ts]")]
  node_history_model[("Investment history")]
  node_user_model[("User accounts<br/>[User.ts]")]
end

node_user(("User"))
node_market_service_external["Market data provider"]
node_database[("MongoDB")]

node_user -->|"views"| node_dashboard_ui
node_user -->|"records"| node_expense_ui
node_user -->|"tracks"| node_investment_ui
node_dashboard_hook -->|"queries"| node_dashboard_client
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_expense_routes
node_server -->|"mounts"| node_dashboard_routes
node_server -->|"mounts"| node_chat_routes
node_dashboard_routes -->|"routes to"| node_dashboard_controller
node_expense_routes -->|"routes to"| node_expense_controller
node_chat_routes -->|"routes to"| node_chat_controller
node_expense_controller -->|"delegates"| node_expense_service
node_dashboard_controller -->|"queries"| node_dashboard_service
node_auth_controller -.->|"delegates"| node_auth_service
node_chat_controller -->|"calls"| node_gemini_service
node_chat_controller -->|"uses"| node_metrics_service
node_expense_service -->|"reads/writes"| node_expense_model
node_expense_service -->|"updates"| node_user_model
node_dashboard_controller -->|"aggregates"| node_expense_model
node_dashboard_service -->|"aggregates"| node_expense_model
node_dashboard_service -->|"reads"| node_investment_model
node_dashboard_service -->|"reads"| node_user_model
node_investment_controller -->|"reads/writes"| node_investment_model
node_investment_controller -->|"records sales"| node_history_model
node_investment_controller -->|"fetches prices"| node_market_pricing
node_dashboard_service -->|"fetches prices"| node_market_pricing
node_market_pricing -.->|"requests quotes"| node_market_service_external
node_auth_service -->|"creates/finds"| node_user_model
node_server -->|"connects"| node_database
node_user -->|"reads"| node_news_ui
node_user -->|"sets goals"| node_goals_ui
node_user -->|"calculates"| node_calculators_ui
node_user -->|"asks"| node_chat_ui

click node_dashboard_ui "https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/page.tsx"
click node_expense_ui "https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/expenses/page.tsx"
click node_investment_ui "https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/investments/page.tsx"
click node_goals_ui "https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/goals/page.tsx"
click node_news_ui "https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/news/page.tsx"
click node_calculators_ui "https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/calculators/page.tsx"
click node_chat_ui "https://github.com/smbb639/finverse/blob/main/frontend/components/Chatbot.tsx"
click node_dashboard_hook "https://github.com/smbb639/finverse/blob/main/frontend/lib/useDashboard.ts"
click node_dashboard_client "https://github.com/smbb639/finverse/blob/main/frontend/lib/dashboard.ts"
click node_server "https://github.com/smbb639/finverse/blob/main/backend/src/index.ts"
click node_auth_routes "https://github.com/smbb639/finverse/blob/main/backend/src/routes/auth.route.ts"
click node_expense_routes "https://github.com/smbb639/finverse/blob/main/backend/src/routes/expense.route.ts"
click node_dashboard_routes "https://github.com/smbb639/finverse/blob/main/backend/src/routes/dashboard.route.ts"
click node_chat_routes "https://github.com/smbb639/finverse/blob/main/backend/src/routes/chat.routes.ts"
click node_auth_service "https://github.com/smbb639/finverse/blob/main/backend/src/services/auth.services.ts"
click node_expense_service "https://github.com/smbb639/finverse/blob/main/backend/src/services/expense.services.ts"
click node_dashboard_service "https://github.com/smbb639/finverse/blob/main/backend/src/services/dashboard.services.ts"
click node_investment_controller "https://github.com/smbb639/finverse/blob/main/backend/src/controller/investment.controller.ts"
click node_market_pricing "https://github.com/smbb639/finverse/blob/main/backend/src/services/marketPrice.services.ts"
click node_goal_service "https://github.com/smbb639/finverse/blob/main/backend/src/services/goal.services.ts"
click node_metrics_service "https://github.com/smbb639/finverse/blob/main/backend/src/services/metrics.service.ts"
click node_chat_controller "https://github.com/smbb639/finverse/blob/main/backend/src/controller/chat.controller.ts"
click node_gemini_service "https://github.com/smbb639/finverse/blob/main/backend/src/services/gemini.service.ts"
click node_expense_controller "https://github.com/smbb639/finverse/blob/main/backend/src/controller/expense.controller.ts"
click node_dashboard_controller "https://github.com/smbb639/finverse/blob/main/backend/src/controller/dashboard.controller.ts"
click node_auth_controller "https://github.com/smbb639/finverse/blob/main/backend/src/controller/auth.controller.ts"
click node_expense_model "https://github.com/smbb639/finverse/blob/main/backend/src/models/Expense.ts"
click node_investment_model "https://github.com/smbb639/finverse/blob/main/backend/src/models/Investment.ts"
click node_history_model "https://github.com/smbb639/finverse/blob/main/backend/src/models/InvestmentHistory.ts"
click node_user_model "https://github.com/smbb639/finverse/blob/main/backend/src/models/User.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_dashboard_ui,node_expense_ui,node_investment_ui,node_goals_ui,node_news_ui,node_calculators_ui,node_chat_ui,node_dashboard_hook,node_dashboard_client,node_user toneBlue
class node_server,node_auth_routes,node_expense_routes,node_dashboard_routes,node_chat_routes,node_database toneAmber
class node_auth_service,node_expense_service,node_dashboard_service,node_investment_controller,node_market_pricing,node_goal_service,node_metrics_service,node_chat_controller,node_gemini_service,node_expense_controller,node_dashboard_controller,node_auth_controller toneMint
class node_expense_model,node_investment_model,node_history_model,node_user_model toneRose
class node_market_service_external toneIndigo
```

## Components

### Finance interface

- [Dashboard](https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/page.tsx): `frontend/app/dashboard/page.tsx`
- [Expenses](https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/expenses/page.tsx): `frontend/app/dashboard/expenses/page.tsx`
- [Portfolio](https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/investments/page.tsx): `frontend/app/dashboard/investments/page.tsx`
- [Goals](https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/goals/page.tsx): `frontend/app/dashboard/goals/page.tsx`
- [Financial news](https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/news/page.tsx): `frontend/app/dashboard/news/page.tsx`
- [Calculators](https://github.com/smbb639/finverse/blob/main/frontend/app/dashboard/calculators/page.tsx): `frontend/app/dashboard/calculators/page.tsx`
- [Chat assistant](https://github.com/smbb639/finverse/blob/main/frontend/components/Chatbot.tsx): `frontend/components/Chatbot.tsx`
- [Dashboard query](https://github.com/smbb639/finverse/blob/main/frontend/lib/useDashboard.ts): `frontend/lib/useDashboard.ts`
- [Dashboard API client](https://github.com/smbb639/finverse/blob/main/frontend/lib/dashboard.ts): `frontend/lib/dashboard.ts`

### Backend API

- [API server](https://github.com/smbb639/finverse/blob/main/backend/src/index.ts): `backend/src/index.ts`
- [Authentication routes](https://github.com/smbb639/finverse/blob/main/backend/src/routes/auth.route.ts): `backend/src/routes/auth.route.ts`
- [Expense routes](https://github.com/smbb639/finverse/blob/main/backend/src/routes/expense.route.ts): `backend/src/routes/expense.route.ts`
- [Dashboard routes](https://github.com/smbb639/finverse/blob/main/backend/src/routes/dashboard.route.ts): `backend/src/routes/dashboard.route.ts`
- [Chat routes](https://github.com/smbb639/finverse/blob/main/backend/src/routes/chat.routes.ts): `backend/src/routes/chat.routes.ts`

### Finance services

- [Authentication](https://github.com/smbb639/finverse/blob/main/backend/src/services/auth.services.ts): `backend/src/services/auth.services.ts`
- [Expense management](https://github.com/smbb639/finverse/blob/main/backend/src/services/expense.services.ts): `backend/src/services/expense.services.ts`
- [Analytics](https://github.com/smbb639/finverse/blob/main/backend/src/services/dashboard.services.ts): `backend/src/services/dashboard.services.ts`
- [Portfolio management](https://github.com/smbb639/finverse/blob/main/backend/src/controller/investment.controller.ts): `backend/src/controller/investment.controller.ts`
- [Market pricing](https://github.com/smbb639/finverse/blob/main/backend/src/services/marketPrice.services.ts): `backend/src/services/marketPrice.services.ts`
- [Goal management](https://github.com/smbb639/finverse/blob/main/backend/src/services/goal.services.ts): `backend/src/services/goal.services.ts`
- [Metrics](https://github.com/smbb639/finverse/blob/main/backend/src/services/metrics.service.ts): `backend/src/services/metrics.service.ts`
- [Chat handling](https://github.com/smbb639/finverse/blob/main/backend/src/controller/chat.controller.ts): `backend/src/controller/chat.controller.ts`
- [Gemini integration](https://github.com/smbb639/finverse/blob/main/backend/src/services/gemini.service.ts): `backend/src/services/gemini.service.ts`
- [Expense handling](https://github.com/smbb639/finverse/blob/main/backend/src/controller/expense.controller.ts): `backend/src/controller/expense.controller.ts`
- [Dashboard handling](https://github.com/smbb639/finverse/blob/main/backend/src/controller/dashboard.controller.ts): `backend/src/controller/dashboard.controller.ts`
- [Auth handling](https://github.com/smbb639/finverse/blob/main/backend/src/controller/auth.controller.ts): `backend/src/controller/auth.controller.ts`

### MongoDB records

- [Expenses](https://github.com/smbb639/finverse/blob/main/backend/src/models/Expense.ts): `backend/src/models/Expense.ts`
- [Investments](https://github.com/smbb639/finverse/blob/main/backend/src/models/Investment.ts): `backend/src/models/Investment.ts`
- [Investment history](https://github.com/smbb639/finverse/blob/main/backend/src/models/InvestmentHistory.ts): `backend/src/models/InvestmentHistory.ts`
- [User accounts](https://github.com/smbb639/finverse/blob/main/backend/src/models/User.ts): `backend/src/models/User.ts`

### Other components

- **User**
- **Market data provider**
- **MongoDB**

## Connections

- User → Dashboard: views
- User → Expenses: records
- User → Portfolio: tracks
- Dashboard query → Dashboard API client: queries (evidence: `frontend/lib/useDashboard.ts`)
- API server → Authentication routes: mounts (evidence: `backend/src/index.ts`)
- API server → Expense routes: mounts (evidence: `backend/src/index.ts`)
- API server → Dashboard routes: mounts (evidence: `backend/src/index.ts`)
- API server → Chat routes: mounts (evidence: `backend/src/index.ts`)
- Dashboard routes → Dashboard handling: routes to (evidence: `backend/src/routes/dashboard.route.ts`)
- Expense routes → Expense handling: routes to (evidence: `backend/src/routes/expense.route.ts`)
- Chat routes → Chat handling: routes to (evidence: `backend/src/routes/chat.routes.ts`)
- Expense handling → Expense management: delegates (evidence: `backend/src/controller/expense.controller.ts`)
- Dashboard handling → Analytics: queries (evidence: `backend/src/controller/dashboard.controller.ts`)
- Auth handling → Authentication: delegates
- Chat handling → Gemini integration: calls (evidence: `backend/src/controller/chat.controller.ts`)
- Chat handling → Metrics: uses (evidence: `backend/src/controller/chat.controller.ts`)
- Expense management → Expenses: reads/writes (evidence: `backend/src/services/expense.services.ts`)
- Expense management → User accounts: updates (evidence: `backend/src/services/expense.services.ts`)
- Dashboard handling → Expenses: aggregates (evidence: `backend/src/controller/dashboard.controller.ts`)
- Analytics → Expenses: aggregates (evidence: `backend/src/services/dashboard.services.ts`)
- Analytics → Investments: reads (evidence: `backend/src/services/dashboard.services.ts`)
- Analytics → User accounts: reads (evidence: `backend/src/services/dashboard.services.ts`)
- Portfolio management → Investments: reads/writes (evidence: `backend/src/controller/investment.controller.ts`)
- Portfolio management → Investment history: records sales (evidence: `backend/src/controller/investment.controller.ts`)
- Portfolio management → Market pricing: fetches prices (evidence: `backend/src/controller/investment.controller.ts`)
- Analytics → Market pricing: fetches prices (evidence: `backend/src/services/dashboard.services.ts`)
- Market pricing → Market data provider: requests quotes
- Authentication → User accounts: creates/finds (evidence: `backend/src/services/auth.services.ts`)
- API server → MongoDB: connects (evidence: `backend/src/index.ts`)
- User → Financial news: reads
- User → Goals: sets goals
- User → Calculators: calculates
- User → Chat assistant: asks
