# nikhilsharma201/requiem-26 architecture

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

- Interactive diagram: https://gitdiagram.com/nikhilsharma201/requiem-26
- Repository: https://github.com/nikhilsharma201/requiem-26

## Overview

The product is an investment risk and portfolio optimization platform. Its primary workflow is a Streamlit user submitting portfolio weights, risk preference, benchmark, and forecast horizon to FastAPI; the analytics endpoint fetches market prices, calculates risk and strategy outputs, and returns results for dashboard visualization. Separate API branches support portfolio persistence and market-price/history retrieval. README-described backtesting, stress testing, and asset-map capabilities are included, but their detailed implementations were not sampled, so their links are documented rather than inferred from source. (The README describes PostgreSQL; the sampled database configuration selects its URL from the environment.)

Main entry points: [`backend/app/routers/analytics.py`](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/analytics.py) (Portfolio evaluation), [`frontend/app.py`](https://github.com/nikhilsharma201/requiem-26/blob/main/frontend/app.py) (Streamlit dashboard), [`backend/app/database.py`](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/database.py) (Database session), [`backend/app/main.py`](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Dashboard"]
  node_dashboard["Streamlit dashboard<br/>[app.py]"]
  node_dashboard_features["Charts and scenarios<br/>[app.py]"]
end

subgraph group_api["API"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_analytics_api["Portfolio evaluation<br/>[analytics.py]"]
  node_market_api["Market endpoints<br/>[market.py]"]
  node_portfolio_api["Portfolio endpoints<br/>[portfolios.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
end

subgraph group_engines["Analysis"]
  node_market_data["Market data ingestion<br/>[market_data.py]"]
  node_quant_analytics["Portfolio metrics<br/>[analytics.py]"]
  node_risk_engine["Risk scoring<br/>[risk_engine.py]"]
  node_allocation_engine["Allocation recommendations"]
  node_ai_intelligence["Qualitative insights<br/>[ai_intelligence.py]"]
  node_forecasting["ARIMA forecast<br/>[forecasting.py]"]
  node_backtesting["Strategy backtesting<br/>[analytics.py]"]
  node_stress_map["Stress tests and asset map<br/>[analytics.py]"]
end

subgraph group_persistence["Data"]
  node_db_config["Database session<br/>[database.py]"]
  node_models["Portfolio and cache models<br/>[models.py]"]
  node_database[("Relational database")]
end

node_investor(("Investor"))
node_market_provider["Yahoo Finance"]

node_investor -->|"sets inputs"| node_dashboard
node_dashboard -->|"submits evaluation"| node_analytics_api
node_analytics_api -->|"returns analysis"| node_dashboard
node_dashboard -->|"renders results"| node_dashboard_features
node_api_app -->|"registers route"| node_analytics_api
node_api_app -->|"registers route"| node_market_api
node_api_app -->|"registers route"| node_portfolio_api
node_api_app -->|"creates tables"| node_db_config
node_analytics_api -->|"fetches prices"| node_market_data
node_analytics_api -->|"calculates metrics"| node_quant_analytics
node_analytics_api -->|"scores risk"| node_risk_engine
node_analytics_api -->|"recommends weights"| node_allocation_engine
node_analytics_api -->|"generates insights"| node_ai_intelligence
node_analytics_api -->|"forecasts growth"| node_forecasting
node_analytics_api -->|"computes strategies"| node_backtesting
node_dashboard -.->|"presents capabilities"| node_stress_map
node_market_api -->|"fetches history"| node_market_data
node_market_data -->|"downloads prices"| node_market_provider
node_market_api -->|"gets session"| node_db_config
node_market_data -->|"caches records"| node_models
node_portfolio_api -->|"gets session"| node_db_config
node_portfolio_api -->|"reads and writes"| node_models
node_portfolio_api -->|"validates payloads"| node_schemas
node_market_api -->|"validates responses"| node_schemas
node_models -->|"uses base"| node_db_config
node_db_config -.->|"connects to"| node_database

click node_dashboard "https://github.com/nikhilsharma201/requiem-26/blob/main/frontend/app.py"
click node_dashboard_features "https://github.com/nikhilsharma201/requiem-26/blob/main/frontend/app.py"
click node_api_app "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/main.py"
click node_analytics_api "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/analytics.py"
click node_market_api "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/market.py"
click node_portfolio_api "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/portfolios.py"
click node_schemas "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/schemas.py"
click node_market_data "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/market_data.py"
click node_quant_analytics "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/analytics.py"
click node_risk_engine "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/risk_engine.py"
click node_allocation_engine "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/allocation_engine.py"
click node_ai_intelligence "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/ai_intelligence.py"
click node_forecasting "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/forecasting.py"
click node_backtesting "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/analytics.py"
click node_stress_map "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/analytics.py"
click node_db_config "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/database.py"
click node_models "https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/models.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_dashboard,node_dashboard_features toneBlue
class node_api_app,node_analytics_api,node_market_api,node_portfolio_api,node_schemas toneAmber
class node_market_data,node_quant_analytics,node_risk_engine,node_allocation_engine,node_ai_intelligence,node_forecasting,node_backtesting,node_stress_map toneMint
class node_db_config,node_models,node_database toneRose
class node_investor,node_market_provider toneIndigo
```

## Components

### Dashboard

- [Streamlit dashboard](https://github.com/nikhilsharma201/requiem-26/blob/main/frontend/app.py): `frontend/app.py`
- [Charts and scenarios](https://github.com/nikhilsharma201/requiem-26/blob/main/frontend/app.py): `frontend/app.py`

### API

- [FastAPI app](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/main.py): `backend/app/main.py`
- [Portfolio evaluation](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/analytics.py): `backend/app/routers/analytics.py`
- [Market endpoints](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/market.py): `backend/app/routers/market.py`
- [Portfolio endpoints](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/portfolios.py): `backend/app/routers/portfolios.py`
- [Request schemas](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/schemas.py): `backend/app/schemas.py`

### Analysis

- [Market data ingestion](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/market_data.py): `backend/app/services/market_data.py`
- [Portfolio metrics](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/analytics.py): `backend/app/services/analytics.py`
- [Risk scoring](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/risk_engine.py): `backend/app/services/risk_engine.py`
- [Allocation recommendations](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/allocation_engine.py): `backend/app/services/allocation_engine.py`
- [Qualitative insights](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/ai_intelligence.py): `backend/app/services/ai_intelligence.py`
- [ARIMA forecast](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/services/forecasting.py): `backend/app/services/forecasting.py`
- [Strategy backtesting](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/analytics.py): `backend/app/routers/analytics.py`
- [Stress tests and asset map](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/routers/analytics.py): `backend/app/routers/analytics.py`

### Data

- [Database session](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/database.py): `backend/app/database.py`
- [Portfolio and cache models](https://github.com/nikhilsharma201/requiem-26/blob/main/backend/app/models.py): `backend/app/models.py`
- **Relational database**

### Other components

- **Investor**
- **Yahoo Finance**

## Connections

- Investor → Streamlit dashboard: sets inputs (evidence: `Readme.md`)
- Streamlit dashboard → Portfolio evaluation: submits evaluation (evidence: `Readme.md`)
- Portfolio evaluation → Streamlit dashboard: returns analysis (evidence: `Readme.md`)
- Streamlit dashboard → Charts and scenarios: renders results (evidence: `Readme.md`)
- FastAPI app → Portfolio evaluation: registers route (evidence: `backend/app/main.py`)
- FastAPI app → Market endpoints: registers route (evidence: `backend/app/main.py`)
- FastAPI app → Portfolio endpoints: registers route (evidence: `backend/app/main.py`)
- FastAPI app → Database session: creates tables (evidence: `backend/app/main.py`)
- Portfolio evaluation → Market data ingestion: fetches prices (evidence: `backend/app/routers/analytics.py`)
- Portfolio evaluation → Portfolio metrics: calculates metrics (evidence: `backend/app/routers/analytics.py`)
- Portfolio evaluation → Risk scoring: scores risk (evidence: `backend/app/routers/analytics.py`)
- Portfolio evaluation → Allocation recommendations: recommends weights (evidence: `backend/app/routers/analytics.py`)
- Portfolio evaluation → Qualitative insights: generates insights (evidence: `backend/app/routers/analytics.py`)
- Portfolio evaluation → ARIMA forecast: forecasts growth (evidence: `backend/app/routers/analytics.py`)
- Portfolio evaluation → Strategy backtesting: computes strategies (evidence: `backend/app/routers/analytics.py`)
- Streamlit dashboard → Stress tests and asset map: presents capabilities (evidence: `Readme.md`)
- Market endpoints → Market data ingestion: fetches history (evidence: `backend/app/routers/market.py`)
- Market data ingestion → Yahoo Finance: downloads prices (evidence: `backend/app/services/market_data.py`)
- Market endpoints → Database session: gets session (evidence: `backend/app/routers/market.py`)
- Market data ingestion → Portfolio and cache models: caches records (evidence: `backend/app/services/market_data.py`)
- Portfolio endpoints → Database session: gets session (evidence: `backend/app/routers/portfolios.py`)
- Portfolio endpoints → Portfolio and cache models: reads and writes (evidence: `backend/app/routers/portfolios.py`)
- Portfolio endpoints → Request schemas: validates payloads (evidence: `backend/app/routers/portfolios.py`)
- Market endpoints → Request schemas: validates responses (evidence: `backend/app/routers/market.py`)
- Portfolio and cache models → Database session: uses base (evidence: `backend/app/models.py`)
- Database session → Relational database: connects to (evidence: `Readme.md`)
