# hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system architecture

> Architecture diagram of the GitHub repository hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system
- Repository: https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system

## Overview

This Next.js financial advisory app takes users from sign-in and portfolio setup into account tracking and AI-assisted advice, planning, risk assessment, financial-health scoring, spending analysis, investment suggestions, and curated news. Route handlers mediate requests, while MongoDB models persist user and financial records; Redux persists client user state. README documents the major advisory capabilities, but several handlers and dashboard pages were not excerpted, so those feature links are documented rather than inferred from implementation details.

Main entry points: [`app/api/utils/db.ts`](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/utils/db.ts) (Mongo connection), [`app/api/utils/env-config.ts`](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/utils/env-config.ts) (Environment config), [`app/api/auth/login/route.ts`](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/auth/login/route.ts) (Authentication API), [`app/api/auth/google/route.ts`](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/auth/google/route.ts) (Google sign-in API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_public["Public site<br/>[page.tsx]"]
  node_login["Sign in<br/>[page.tsx]"]
  node_portfolio["Portfolio dashboard<br/>[page.tsx]"]
  node_account_ui["Account setup"]
  node_transactions_ui["Transactions<br/>[page.tsx]"]
  node_client_state["Persisted user state<br/>[store.ts]"]
  node_user_slice["User state slice<br/>[UserSlice.ts]"]
end

subgraph group_advisory["Financial advisory"]
  node_ai_chat_ui["AI advisor chat<br/>[page.tsx]"]
  node_risk_ui["Risk assessment<br/>[page.tsx]"]
  node_goals_ui["Goal planning<br/>[page.tsx]"]
  node_health_ui["Financial health<br/>[page.tsx]"]
  node_spending_ui["Spending insights<br/>[page.tsx]"]
  node_news_ui["News and alerts<br/>[page.tsx]"]
  node_investment_ui["Investment suggestions<br/>[route.ts]"]
end

subgraph group_backend["Application services"]
  node_auth_api["Authentication API<br/>[route.ts]"]
  node_google_auth["Google sign-in API<br/>[route.ts]"]
  node_account_api["Account API<br/>[route.ts]"]
  node_ai_chat_api["Advisor API<br/>[route.ts]"]
  node_risk_api["Risk API<br/>[route.ts]"]
  node_goals_api["Planning API<br/>[route.ts]"]
  node_health_api["Health score API<br/>[route.ts]"]
  node_spend_api["Spending API<br/>[route.ts]"]
  node_news_api["News summary API<br/>[route.ts]"]
  node_config["Environment config<br/>[env-config.ts]"]
end

subgraph group_data["Persistence"]
  node_db_connect["Mongo connection<br/>[db.ts]"]
  node_user_model[("User records<br/>[User.ts]")]
  node_account_model[("Account records<br/>[Account.ts]")]
  node_notification_model[("Notifications<br/>[Notification.ts]")]
  node_financial_models[("Financial records<br/>[Transaction.ts]")]
  node_conversation_model[("Chat history<br/>[Conservation.ts]")]
end

node_investor(("Investor"))
node_llm{{"Financial LLM"}}
node_mongo[("MongoDB")]
node_firebase[("Firebase")]

node_investor -->|"visits"| node_public
node_investor -->|"signs in"| node_login
node_login -->|"submits credentials"| node_auth_api
node_login -.->|"Google sign-in"| node_google_auth
node_auth_api -.->|"updates user"| node_client_state
node_client_state -->|"persists state"| node_user_slice
node_investor -.->|"manages finances"| node_portfolio
node_portfolio -.->|"sets up account"| node_account_ui
node_account_ui -.->|"submits details"| node_account_api
node_account_api -->|"connects"| node_db_connect
node_db_connect -->|"reads settings"| node_config
node_db_connect -->|"connects"| node_mongo
node_account_api -->|"writes account"| node_account_model
node_account_api -->|"creates alerts"| node_notification_model
node_investor -.->|"reviews activity"| node_transactions_ui
node_investor -.->|"asks advisor"| node_ai_chat_ui
node_ai_chat_ui -.->|"sends prompt"| node_ai_chat_api
node_ai_chat_api -->|"connects"| node_db_connect
node_ai_chat_api -->|"stores conversation"| node_conversation_model
node_ai_chat_api -.->|"requests advice"| node_llm
node_investor -.->|"assesses risk"| node_risk_ui
node_risk_ui -.->|"requests assessment"| node_risk_api
node_risk_api -->|"reads settings"| node_config
node_risk_api -.->|"requests analysis"| node_llm
node_investor -.->|"plans goals"| node_goals_ui
node_goals_ui -.->|"requests plan"| node_goals_api
node_goals_api -->|"reads settings"| node_config
node_goals_api -.->|"requests plan"| node_llm
node_investor -.->|"checks wellbeing"| node_health_ui
node_health_ui -.->|"requests score"| node_health_api
node_health_api -->|"reads settings"| node_config
node_health_api -.->|"requests scoring"| node_llm
node_investor -.->|"reviews spending"| node_spending_ui
node_spending_ui -.->|"requests insights"| node_spend_api
node_spend_api -->|"reads settings"| node_config
node_spend_api -.->|"requests analysis"| node_llm
node_investor -.->|"reads updates"| node_news_ui
node_news_ui -.->|"requests summary"| node_news_api
node_news_api -.->|"curates news"| node_llm
node_investor -.->|"seeks suggestions"| node_investment_ui
node_investment_ui -.->|"requests suggestions"| node_llm
node_auth_api -->|"connects"| node_db_connect
node_auth_api -->|"reads user"| node_user_model
node_google_auth -->|"connects"| node_db_connect
node_google_auth -->|"reads or creates"| node_user_model
node_google_auth -->|"creates alert"| node_notification_model
node_investor -.->|"uses services"| node_firebase

click node_public "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/page.tsx"
click node_login "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(public)/login/page.tsx"
click node_portfolio "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/page.tsx"
click node_account_ui "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/components/app/AccountDetailsForm.tsx"
click node_transactions_ui "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/transactions/page.tsx"
click node_ai_chat_ui "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/ai-assistant/page.tsx"
click node_risk_ui "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/risk-assessment/page.tsx"
click node_goals_ui "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/goal-based-planning/page.tsx"
click node_health_ui "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/financial-health-score/page.tsx"
click node_spending_ui "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/spendings/page.tsx"
click node_news_ui "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/news/page.tsx"
click node_investment_ui "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/stock-investment-suggestion/route.ts"
click node_auth_api "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/auth/login/route.ts"
click node_google_auth "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/auth/google/route.ts"
click node_account_api "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/user/account-details/route.ts"
click node_ai_chat_api "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/ai-assistant/route.ts"
click node_risk_api "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/risk-assessment/route.ts"
click node_goals_api "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/goal-based-planning/route.ts"
click node_health_api "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/financial-health-score/route.ts"
click node_spend_api "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/spendings/route.ts"
click node_news_api "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/news-summary/route.ts"
click node_db_connect "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/utils/db.ts"
click node_config "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/utils/env-config.ts"
click node_user_model "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/User.ts"
click node_account_model "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/Account.ts"
click node_notification_model "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/Notification.ts"
click node_financial_models "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/Transaction.ts"
click node_conversation_model "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/Conservation.ts"
click node_client_state "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/lib/store.ts"
click node_user_slice "https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/lib/features/user/UserSlice.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_public,node_login,node_portfolio,node_account_ui,node_transactions_ui,node_client_state,node_user_slice toneBlue
class node_ai_chat_ui,node_risk_ui,node_goals_ui,node_health_ui,node_spending_ui,node_news_ui,node_investment_ui,node_mongo,node_firebase toneAmber
class node_auth_api,node_google_auth,node_account_api,node_ai_chat_api,node_risk_api,node_goals_api,node_health_api,node_spend_api,node_news_api,node_config toneMint
class node_db_connect,node_user_model,node_account_model,node_notification_model,node_financial_models,node_conversation_model toneRose
class node_investor,node_llm toneIndigo
```

## Components

### User experience

- [Public site](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/page.tsx): `app/page.tsx`
- [Sign in](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(public)/login/page.tsx): `app/(public)/login/page.tsx`
- [Portfolio dashboard](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/page.tsx): `app/(admin)/app/page.tsx`
- [Account setup](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/components/app/AccountDetailsForm.tsx): `app/(admin)/components/app/AccountDetailsForm.tsx`
- [Transactions](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/transactions/page.tsx): `app/(admin)/app/transactions/page.tsx`
- [Persisted user state](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/lib/store.ts): `lib/store.ts`
- [User state slice](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/lib/features/user/UserSlice.ts): `lib/features/user/UserSlice.ts`

### Financial advisory

- [AI advisor chat](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/ai-assistant/page.tsx): `app/(admin)/app/ai-assistant/page.tsx`
- [Risk assessment](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/risk-assessment/page.tsx): `app/(admin)/app/risk-assessment/page.tsx`
- [Goal planning](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/goal-based-planning/page.tsx): `app/(admin)/app/goal-based-planning/page.tsx`
- [Financial health](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/financial-health-score/page.tsx): `app/(admin)/app/financial-health-score/page.tsx`
- [Spending insights](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/spendings/page.tsx): `app/(admin)/app/spendings/page.tsx`
- [News and alerts](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/(admin)/app/news/page.tsx): `app/(admin)/app/news/page.tsx`
- [Investment suggestions](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/stock-investment-suggestion/route.ts): `app/api/ai/stock-investment-suggestion/route.ts`

### Application services

- [Authentication API](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/auth/login/route.ts): `app/api/auth/login/route.ts`
- [Google sign-in API](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/auth/google/route.ts): `app/api/auth/google/route.ts`
- [Account API](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/user/account-details/route.ts): `app/api/user/account-details/route.ts`
- [Advisor API](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/ai-assistant/route.ts): `app/api/ai/ai-assistant/route.ts`
- [Risk API](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/risk-assessment/route.ts): `app/api/ai/risk-assessment/route.ts`
- [Planning API](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/goal-based-planning/route.ts): `app/api/ai/goal-based-planning/route.ts`
- [Health score API](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/financial-health-score/route.ts): `app/api/ai/financial-health-score/route.ts`
- [Spending API](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/spendings/route.ts): `app/api/ai/spendings/route.ts`
- [News summary API](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/ai/news-summary/route.ts): `app/api/ai/news-summary/route.ts`
- [Environment config](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/utils/env-config.ts): `app/api/utils/env-config.ts`

### Persistence

- [Mongo connection](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/api/utils/db.ts): `app/api/utils/db.ts`
- [User records](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/User.ts): `app/model/User.ts`
- [Account records](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/Account.ts): `app/model/Account.ts`
- [Notifications](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/Notification.ts): `app/model/Notification.ts`
- [Financial records](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/Transaction.ts): `app/model/Transaction.ts`
- [Chat history](https://github.com/hamza-fullstackdev/ai-powered-financial-and-investment-advisory-system/blob/main/app/model/Conservation.ts): `app/model/Conservation.ts`

### Other components

- **Investor**
- **Financial LLM**
- **MongoDB**
- **Firebase**

## Connections

- Investor → Public site: visits (evidence: `app/page.tsx`)
- Investor → Sign in: signs in (evidence: `app/(public)/login/page.tsx`)
- Sign in → Authentication API: submits credentials (evidence: `app/(public)/login/page.tsx`)
- Sign in → Google sign-in API: Google sign-in (evidence: `app/(public)/login/page.tsx`)
- Authentication API → Persisted user state: updates user
- Persisted user state → User state slice: persists state (evidence: `lib/store.ts`)
- Investor → Portfolio dashboard: manages finances (evidence: `README.md`)
- Portfolio dashboard → Account setup: sets up account (evidence: `README.md`)
- Account setup → Account API: submits details (evidence: `README.md`)
- Account API → Mongo connection: connects (evidence: `app/api/user/account-details/route.ts`)
- Mongo connection → Environment config: reads settings (evidence: `app/api/utils/db.ts`)
- Mongo connection → MongoDB: connects (evidence: `app/api/utils/db.ts`)
- Account API → Account records: writes account (evidence: `app/api/user/account-details/route.ts`)
- Account API → Notifications: creates alerts (evidence: `app/api/user/account-details/route.ts`)
- Investor → Transactions: reviews activity (evidence: `README.md`)
- Investor → AI advisor chat: asks advisor (evidence: `README.md`)
- AI advisor chat → Advisor API: sends prompt (evidence: `README.md`)
- Advisor API → Mongo connection: connects (evidence: `app/api/ai/ai-assistant/route.ts`)
- Advisor API → Chat history: stores conversation (evidence: `app/api/ai/ai-assistant/route.ts`)
- Advisor API → Financial LLM: requests advice (evidence: `README.md`)
- Investor → Risk assessment: assesses risk (evidence: `README.md`)
- Risk assessment → Risk API: requests assessment (evidence: `README.md`)
- Risk API → Environment config: reads settings (evidence: `app/api/ai/risk-assessment/route.ts`)
- Risk API → Financial LLM: requests analysis (evidence: `README.md`)
- Investor → Goal planning: plans goals (evidence: `README.md`)
- Goal planning → Planning API: requests plan (evidence: `README.md`)
- Planning API → Environment config: reads settings (evidence: `app/api/ai/goal-based-planning/route.ts`)
- Planning API → Financial LLM: requests plan (evidence: `README.md`)
- Investor → Financial health: checks wellbeing (evidence: `README.md`)
- Financial health → Health score API: requests score (evidence: `README.md`)
- Health score API → Environment config: reads settings (evidence: `app/api/ai/financial-health-score/route.ts`)
- Health score API → Financial LLM: requests scoring (evidence: `README.md`)
- Investor → Spending insights: reviews spending (evidence: `README.md`)
- Spending insights → Spending API: requests insights (evidence: `README.md`)
- Spending API → Environment config: reads settings (evidence: `app/api/ai/spendings/route.ts`)
- Spending API → Financial LLM: requests analysis (evidence: `README.md`)
- Investor → News and alerts: reads updates (evidence: `README.md`)
- News and alerts → News summary API: requests summary (evidence: `README.md`)
- News summary API → Financial LLM: curates news (evidence: `README.md`)
- Investor → Investment suggestions: seeks suggestions (evidence: `README.md`)
- Investment suggestions → Financial LLM: requests suggestions (evidence: `README.md`)
- Authentication API → Mongo connection: connects (evidence: `app/api/auth/login/route.ts`)
- Authentication API → User records: reads user (evidence: `app/api/auth/login/route.ts`)
- Google sign-in API → Mongo connection: connects (evidence: `app/api/auth/google/route.ts`)
- Google sign-in API → User records: reads or creates (evidence: `app/api/auth/google/route.ts`)
- Google sign-in API → Notifications: creates alert (evidence: `app/api/auth/google/route.ts`)
- Investor → Firebase: uses services (evidence: `README.md`)
