# donkena-saiteja/ai-powered-porfolio-risk-analyzer architecture

> Architecture diagram of the GitHub repository donkena-saiteja/ai-powered-porfolio-risk-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer
- Repository: https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer

## Overview

This is a full-stack portfolio risk analysis application. An investor signs in, selects or manages holdings, and views risk analytics; the React app requests the FastAPI service and falls back to deterministic browser analytics when the service is unavailable. The dashboard also supports what-if rebalancing, Monte Carlo projections, a grounded risk assistant, and PDF report export. The graph preserves these documented capabilities, but some links to unsampled UI components are omitted where the excerpts do not establish their invocation.

Main entry points: [`frontend/src/App.jsx`](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/App.jsx) (Dashboard app), [`frontend/src/services/api.js`](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/services/api.js) (Analytics API client), [`backend/main.py`](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/backend/main.py) (FastAPI routes), [`frontend/src/components/WhatIfSimulator.jsx`](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/WhatIfSimulator.jsx) (What-if simulator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Portfolio interface"]
  node_app["Dashboard app<br/>[App.jsx]"]
  node_login["Demo login<br/>[LoginPage.jsx]"]
  node_navigation["Dashboard navigation<br/>[Sidebar.jsx]"]
  node_navbar["Portfolio controls<br/>[Navbar.jsx]"]
  node_holdings["Holdings manager<br/>[HoldingsTable.jsx]"]
  node_portfolio_modal["Portfolio editor<br/>[PortfolioModal.jsx]"]
  node_metrics["Metric cards<br/>[MetricCards.jsx]"]
  node_risk_score["Risk score<br/>[RiskScoreCard.jsx]"]
  node_risk_breakdown["Risk breakdown"]
  node_risk_contributions["Risk contributions"]
  node_correlation["Correlation heatmap"]
  node_hidden_correlation["Correlation alert"]
  node_sector["Sector exposure"]
  node_performance["Performance chart"]
  node_whatif["What-if simulator"]
  node_monte_carlo["Monte Carlo chart"]
  node_assistant_ui["Risk assistant"]
  node_export["PDF report export"]
end

subgraph group_client["Client analytics"]
  node_sample_data["Sample portfolios"]
  node_api_client["Analytics API client<br/>[api.js]"]
  node_engine["Browser analytics engine<br/>[financialEngine.js]"]
end

subgraph group_backend["Analytics service"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_models["Request models<br/>[models.py]"]
  node_analytics["Portfolio analytics<br/>[analytics.py]"]
  node_advisor["Risk response logic<br/>[ai_advisor.py]"]
end

node_investor(("Investor"))

node_investor -->|"signs in"| node_login
node_investor -->|"uses dashboard"| node_app
node_app -->|"shows when unauthenticated"| node_login
node_app -->|"renders"| node_navigation
node_app -->|"renders"| node_navbar
node_app -->|"renders"| node_holdings
node_app -->|"renders"| node_portfolio_modal
node_app -->|"renders"| node_metrics
node_app -->|"renders"| node_risk_score
node_app -->|"renders"| node_risk_breakdown
node_app -->|"renders"| node_risk_contributions
node_app -->|"renders"| node_correlation
node_app -->|"renders"| node_hidden_correlation
node_app -->|"renders"| node_sector
node_app -->|"renders"| node_performance
node_app -->|"renders"| node_whatif
node_app -->|"renders"| node_monte_carlo
node_app -->|"renders"| node_assistant_ui
node_app -->|"renders"| node_export
node_app -->|"requests risk metrics"| node_api_client
node_app -->|"computes fallback metrics"| node_engine
node_app -.->|"offers examples"| node_sample_data
node_whatif -->|"requests simulation"| node_api_client
node_whatif -->|"uses local simulation"| node_engine
node_monte_carlo -->|"requests projection"| node_api_client
node_assistant_ui -->|"sends questions"| node_api_client
node_api_client -->|"posts analytics requests"| node_api
node_api_client -->|"falls back on failure"| node_engine
node_api -->|"validates requests"| node_models
node_api -->|"calls calculations"| node_analytics
node_api -->|"calls assistant logic"| node_advisor
node_analytics -.->|"returns analytics results"| node_app

click node_app "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/LoginPage.jsx"
click node_navigation "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/Sidebar.jsx"
click node_navbar "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/Navbar.jsx"
click node_holdings "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/HoldingsTable.jsx"
click node_portfolio_modal "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/PortfolioModal.jsx"
click node_metrics "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/MetricCards.jsx"
click node_risk_score "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/RiskScoreCard.jsx"
click node_risk_breakdown "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/RiskBreakdownModal.jsx"
click node_risk_contributions "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/RiskContributionChart.jsx"
click node_correlation "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/CorrelationHeatmap.jsx"
click node_hidden_correlation "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/HiddenCorrelationBanner.jsx"
click node_sector "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/SectorConcentrationChart.jsx"
click node_performance "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/PerformanceChart.jsx"
click node_whatif "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/WhatIfSimulator.jsx"
click node_monte_carlo "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/MonteCarloChart.jsx"
click node_assistant_ui "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/AiRiskAssistant.jsx"
click node_export "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/ExportReportModal.jsx"
click node_sample_data "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/data/samplePortfolios.js"
click node_api_client "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/services/api.js"
click node_engine "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/services/financialEngine.js"
click node_api "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/backend/main.py"
click node_models "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/backend/models.py"
click node_analytics "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/backend/analytics.py"
click node_advisor "https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/backend/ai_advisor.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_login,node_navigation,node_navbar,node_holdings,node_portfolio_modal,node_metrics,node_risk_score,node_risk_breakdown,node_risk_contributions,node_correlation,node_hidden_correlation,node_sector,node_performance,node_whatif,node_monte_carlo,node_assistant_ui,node_export toneBlue
class node_sample_data,node_api_client,node_engine toneAmber
class node_api,node_models,node_analytics,node_advisor toneMint
class node_investor toneIndigo
```

## Components

### Portfolio interface

- [Dashboard app](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Demo login](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/LoginPage.jsx): `frontend/src/components/LoginPage.jsx`
- [Dashboard navigation](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Portfolio controls](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Holdings manager](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/HoldingsTable.jsx): `frontend/src/components/HoldingsTable.jsx`
- [Portfolio editor](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/PortfolioModal.jsx): `frontend/src/components/PortfolioModal.jsx`
- [Metric cards](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/MetricCards.jsx): `frontend/src/components/MetricCards.jsx`
- [Risk score](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/RiskScoreCard.jsx): `frontend/src/components/RiskScoreCard.jsx`
- [Risk breakdown](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/RiskBreakdownModal.jsx): `frontend/src/components/RiskBreakdownModal.jsx`
- [Risk contributions](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/RiskContributionChart.jsx): `frontend/src/components/RiskContributionChart.jsx`
- [Correlation heatmap](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/CorrelationHeatmap.jsx): `frontend/src/components/CorrelationHeatmap.jsx`
- [Correlation alert](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/HiddenCorrelationBanner.jsx): `frontend/src/components/HiddenCorrelationBanner.jsx`
- [Sector exposure](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/SectorConcentrationChart.jsx): `frontend/src/components/SectorConcentrationChart.jsx`
- [Performance chart](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/PerformanceChart.jsx): `frontend/src/components/PerformanceChart.jsx`
- [What-if simulator](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/WhatIfSimulator.jsx): `frontend/src/components/WhatIfSimulator.jsx`
- [Monte Carlo chart](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/MonteCarloChart.jsx): `frontend/src/components/MonteCarloChart.jsx`
- [Risk assistant](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/AiRiskAssistant.jsx): `frontend/src/components/AiRiskAssistant.jsx`
- [PDF report export](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/components/ExportReportModal.jsx): `frontend/src/components/ExportReportModal.jsx`

### Client analytics

- [Sample portfolios](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/data/samplePortfolios.js): `frontend/src/data/samplePortfolios.js`
- [Analytics API client](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Browser analytics engine](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/frontend/src/services/financialEngine.js): `frontend/src/services/financialEngine.js`

### Analytics service

- [FastAPI routes](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/backend/main.py): `backend/main.py`
- [Request models](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/backend/models.py): `backend/models.py`
- [Portfolio analytics](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/backend/analytics.py): `backend/analytics.py`
- [Risk response logic](https://github.com/donkena-saiteja/ai-powered-porfolio-risk-analyzer/blob/main/backend/ai_advisor.py): `backend/ai_advisor.py`

### Other components

- **Investor**

## Connections

- Investor → Demo login: signs in (evidence: `README.md`)
- Investor → Dashboard app: uses dashboard (evidence: `README.md`)
- Dashboard app → Demo login: shows when unauthenticated (evidence: `frontend/src/App.jsx`)
- Dashboard app → Dashboard navigation: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Portfolio controls: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Holdings manager: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Portfolio editor: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Metric cards: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Risk score: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Risk breakdown: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Risk contributions: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Correlation heatmap: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Correlation alert: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Sector exposure: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Performance chart: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → What-if simulator: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Monte Carlo chart: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Risk assistant: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → PDF report export: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Analytics API client: requests risk metrics (evidence: `frontend/src/App.jsx`)
- Dashboard app → Browser analytics engine: computes fallback metrics (evidence: `frontend/src/App.jsx`)
- Dashboard app → Sample portfolios: offers examples (evidence: `README.md`)
- What-if simulator → Analytics API client: requests simulation (evidence: `frontend/src/services/api.js`)
- What-if simulator → Browser analytics engine: uses local simulation (evidence: `frontend/src/components/WhatIfSimulator.jsx`)
- Monte Carlo chart → Analytics API client: requests projection (evidence: `frontend/src/services/api.js`)
- Risk assistant → Analytics API client: sends questions (evidence: `frontend/src/components/AiRiskAssistant.jsx`)
- Analytics API client → FastAPI routes: posts analytics requests (evidence: `README.md`)
- Analytics API client → Browser analytics engine: falls back on failure (evidence: `frontend/src/services/api.js`)
- FastAPI routes → Request models: validates requests (evidence: `backend/main.py`)
- FastAPI routes → Portfolio analytics: calls calculations (evidence: `backend/main.py`)
- FastAPI routes → Risk response logic: calls assistant logic (evidence: `backend/main.py`)
- Portfolio analytics → Dashboard app: returns analytics results (evidence: `README.md`)
