# akashdeep-bit-gif/aegis-risk-terminal architecture

> Architecture diagram of the GitHub repository akashdeep-bit-gif/aegis-risk-terminal, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akashdeep-bit-gif/aegis-risk-terminal
- Repository: https://github.com/akashdeep-bit-gif/aegis-risk-terminal

## Overview

This is a portfolio-risk dashboard with a backend that periodically reads holdings and wallet data, calculates portfolio risk, and broadcasts metrics to a React UI. Users inspect live risk indicators and portfolio composition, then explore shock and hedge scenarios. The sampled code supports the backend calculation and broadcast flow and the UI’s analytics views; the exact frontend event subscription and database schema are not shown, so that connection is marked unverified.

Main entry points: [`frontend/src/components/RiskDashboard.jsx`](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/components/RiskDashboard.jsx) (Risk dashboard), [`backend/riskstream.js`](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/riskstream.js) (Metrics poller), [`backend/db.js`](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/db.js) (MySQL pool), [`frontend/src/App.jsx`](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/App.jsx) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Dashboard"]
  node_app["App shell<br/>[App.jsx]"]
  node_dashboard["Risk dashboard<br/>[RiskDashboard.jsx]"]
  node_risk_views["Risk indicators<br/>[RiskDashboard.jsx]"]
  node_scenario_lab["Shock simulator<br/>[RiskDashboard.jsx]"]
  node_portfolio_views["Portfolio views<br/>[RiskDashboard.jsx]"]
end

subgraph group_streaming["Live Metrics"]
  node_server["Socket server<br/>[server.js]"]
  node_riskstream["Metrics poller<br/>[riskstream.js]"]
end

subgraph group_analytics["Risk Analytics"]
  node_riskengine["Risk calculations<br/>[riskengine.js]"]
end

subgraph group_persistence["Portfolio Data"]
  node_db_pool["MySQL pool<br/>[db.js]"]
end

node_user(("Portfolio user"))
node_mysql[("MySQL database")]

node_user -->|"explores"| node_dashboard
node_app -->|"renders"| node_dashboard
node_dashboard -->|"presents"| node_risk_views
node_dashboard -->|"simulates"| node_scenario_lab
node_dashboard -->|"shows"| node_portfolio_views
node_server -->|"starts"| node_riskstream
node_riskstream -->|"queries"| node_db_pool
node_db_pool -.->|"connects"| node_mysql
node_riskstream -->|"calculates with"| node_riskengine
node_riskstream -.->|"broadcasts metrics"| node_dashboard

click node_app "https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/App.jsx"
click node_dashboard "https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/components/RiskDashboard.jsx"
click node_risk_views "https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/components/RiskDashboard.jsx"
click node_scenario_lab "https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/components/RiskDashboard.jsx"
click node_portfolio_views "https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/components/RiskDashboard.jsx"
click node_server "https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/server.js"
click node_riskstream "https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/riskstream.js"
click node_riskengine "https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/riskengine.js"
click node_db_pool "https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/db.js"

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_dashboard,node_risk_views,node_scenario_lab,node_portfolio_views,node_user toneBlue
class node_server,node_riskstream,node_mysql toneAmber
class node_riskengine toneMint
class node_db_pool toneRose
```

## Components

### Dashboard

- [App shell](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Risk dashboard](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/components/RiskDashboard.jsx): `frontend/src/components/RiskDashboard.jsx`
- [Risk indicators](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/components/RiskDashboard.jsx): `frontend/src/components/RiskDashboard.jsx`
- [Shock simulator](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/components/RiskDashboard.jsx): `frontend/src/components/RiskDashboard.jsx`
- [Portfolio views](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/frontend/src/components/RiskDashboard.jsx): `frontend/src/components/RiskDashboard.jsx`

### Live Metrics

- [Socket server](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/server.js): `backend/server.js`
- [Metrics poller](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/riskstream.js): `backend/riskstream.js`

### Risk Analytics

- [Risk calculations](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/riskengine.js): `backend/riskengine.js`

### Portfolio Data

- [MySQL pool](https://github.com/akashdeep-bit-gif/aegis-risk-terminal/blob/main/backend/db.js): `backend/db.js`

### Other components

- **Portfolio user**
- **MySQL database**

## Connections

- Portfolio user → Risk dashboard: explores (evidence: `frontend/src/components/RiskDashboard.jsx`)
- App shell → Risk dashboard: renders (evidence: `frontend/src/App.jsx`)
- Risk dashboard → Risk indicators: presents (evidence: `frontend/src/components/RiskDashboard.jsx`)
- Risk dashboard → Shock simulator: simulates (evidence: `frontend/src/components/RiskDashboard.jsx`)
- Risk dashboard → Portfolio views: shows (evidence: `frontend/src/components/RiskDashboard.jsx`)
- Socket server → Metrics poller: starts (evidence: `backend/server.js`)
- Metrics poller → MySQL pool: queries (evidence: `backend/riskstream.js`)
- MySQL pool → MySQL database: connects
- Metrics poller → Risk calculations: calculates with (evidence: `backend/riskstream.js`)
- Metrics poller → Risk dashboard: broadcasts metrics
