# osaidsheikh1509-wq/cyber_risk architecture

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

- Interactive diagram: https://gitdiagram.com/osaidsheikh1509-wq/cyber_risk
- Repository: https://github.com/osaidsheikh1509-wq/cyber_risk

## Overview

Cyber Risk Tracker supports analyst workflows for threat registration, risk assessment, investigation timelines, and multilingual voice/audio intelligence. The main path runs from the React dashboard through typed API requests into FastAPI endpoints, repository selection, and persistent storage; AI and Sarvam services handle assessment and briefings. Edges reflect README statements or shown source references and calls; several storage and endpoint internals were not sampled, so those links are documented or conservatively omitted.

Main entry points: [`backend/app/main.py`](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/main.py) (FastAPI Router), [`frontend/src/services/threatApi.ts`](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/frontend/src/services/threatApi.ts) (Threat API Client), [`backend/app/api/v1/endpoints/threats.py`](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/api/v1/endpoints/threats.py) (Threat Operations), [`backend/app/repositories/mongo_repo.py`](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/repositories/mongo_repo.py) (Mongo Repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Analyst Interface"]
  node_app["Threat Dashboard<br/>[App.tsx]"]
  node_detail["Threat Detail"]
  node_briefing_ui["Briefing Player"]
  node_client["Threat API Client<br/>[threatApi.ts]"]
end

subgraph group_api["API Workflows"]
  node_api_app["FastAPI Router<br/>[main.py]"]
  node_threat_routes["Threat Operations<br/>[threats.py]"]
  node_stats_routes["Threat Statistics<br/>[stats.py]"]
  node_ai_routes["AI Assessment Route<br/>[ai.py]"]
  node_voice_routes["Voice Intake Route<br/>[voice.py]"]
end

subgraph group_domain["Risk Intelligence"]
  node_risk_model["Risk Model Providers<br/>[risk_model.py]"]
  node_sarvam["Sarvam Services<br/>[sarvam.py]"]
  node_risk_calc["Risk Scoring<br/>[risk_calculator.py]"]
  node_cache["Briefing Cache<br/>[briefing_cache.py]"]
end

subgraph group_data["Persistence"]
  node_repository["Repository Selection<br/>[dependencies.py]"]
  node_sqlite_repo["SQLite Repositories<br/>[sqlite_repo.py]"]
  node_mongo_repo["Mongo Repositories<br/>[mongo_repo.py]"]
  node_sqlite[("SQLite Database<br/>[database.py]")]
  node_mongo[("MongoDB<br/>[mongo.py]")]
  node_models["Threat Models<br/>[threat.py]"]
end

node_analyst(("Security Analyst"))
node_ai_provider["AI Model Service"]

node_analyst -->|"uses"| node_app
node_app -->|"requests data"| node_client
node_detail -->|"requests timeline"| node_client
node_briefing_ui -->|"requests briefing"| node_client
node_client -->|"HTTP requests"| node_threat_routes
node_client -->|"assesses threat"| node_ai_routes
node_client -.->|"submits voice"| node_voice_routes
node_api_app -->|"mounts routes"| node_threat_routes
node_api_app -->|"mounts routes"| node_stats_routes
node_api_app -->|"mounts routes"| node_ai_routes
node_api_app -->|"mounts routes"| node_voice_routes
node_threat_routes -->|"uses repositories"| node_repository
node_stats_routes -->|"uses repositories"| node_repository
node_threat_routes -->|"calculates risk"| node_risk_calc
node_threat_routes -->|"generates briefing"| node_sarvam
node_ai_routes -->|"assesses event"| node_risk_model
node_ai_routes -->|"calculates score"| node_risk_calc
node_voice_routes -->|"transcribes audio"| node_sarvam
node_voice_routes -->|"assesses transcript"| node_risk_model
node_risk_model -->|"calls provider"| node_sarvam
node_risk_model -.->|"optional model"| node_ai_provider
node_repository -->|"selects backend"| node_sqlite_repo
node_repository -->|"selects backend"| node_mongo_repo
node_sqlite_repo -.->|"reads and writes"| node_sqlite
node_mongo_repo -.->|"reads and writes"| node_mongo
node_mongo_repo -->|"calculates risk"| node_risk_calc
node_mongo_repo -->|"uses cache"| node_cache
node_api_app -->|"initializes models"| node_models
node_api_app -->|"creates tables"| node_sqlite

click node_app "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/frontend/src/App.tsx"
click node_detail "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/frontend/src/components/ThreatDetailPage.tsx"
click node_briefing_ui "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/frontend/src/components/SpokenBriefingModal.tsx"
click node_client "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/frontend/src/services/threatApi.ts"
click node_api_app "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/main.py"
click node_threat_routes "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/api/v1/endpoints/threats.py"
click node_stats_routes "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/api/v1/endpoints/stats.py"
click node_ai_routes "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/api/v1/endpoints/ai.py"
click node_voice_routes "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/api/v1/endpoints/voice.py"
click node_risk_model "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/services/risk_model.py"
click node_sarvam "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/services/sarvam.py"
click node_risk_calc "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/core/risk_calculator.py"
click node_cache "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/services/briefing_cache.py"
click node_repository "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/repositories/dependencies.py"
click node_sqlite_repo "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/repositories/sqlite_repo.py"
click node_mongo_repo "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/repositories/mongo_repo.py"
click node_sqlite "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/core/database.py"
click node_mongo "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/core/mongo.py"
click node_models "https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/models/threat.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_detail,node_briefing_ui,node_client toneBlue
class node_api_app,node_threat_routes,node_stats_routes,node_ai_routes,node_voice_routes toneAmber
class node_risk_model,node_sarvam,node_risk_calc,node_cache toneMint
class node_repository,node_sqlite_repo,node_mongo_repo,node_sqlite,node_mongo,node_models toneRose
class node_analyst,node_ai_provider toneIndigo
```

## Components

### Analyst Interface

- [Threat Dashboard](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Threat Detail](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/frontend/src/components/ThreatDetailPage.tsx): `frontend/src/components/ThreatDetailPage.tsx`
- [Briefing Player](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/frontend/src/components/SpokenBriefingModal.tsx): `frontend/src/components/SpokenBriefingModal.tsx`
- [Threat API Client](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/frontend/src/services/threatApi.ts): `frontend/src/services/threatApi.ts`

### API Workflows

- [FastAPI Router](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/main.py): `backend/app/main.py`
- [Threat Operations](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/api/v1/endpoints/threats.py): `backend/app/api/v1/endpoints/threats.py`
- [Threat Statistics](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/api/v1/endpoints/stats.py): `backend/app/api/v1/endpoints/stats.py`
- [AI Assessment Route](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/api/v1/endpoints/ai.py): `backend/app/api/v1/endpoints/ai.py`
- [Voice Intake Route](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/api/v1/endpoints/voice.py): `backend/app/api/v1/endpoints/voice.py`

### Risk Intelligence

- [Risk Model Providers](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/services/risk_model.py): `backend/app/services/risk_model.py`
- [Sarvam Services](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/services/sarvam.py): `backend/app/services/sarvam.py`
- [Risk Scoring](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/core/risk_calculator.py): `backend/app/core/risk_calculator.py`
- [Briefing Cache](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/services/briefing_cache.py): `backend/app/services/briefing_cache.py`

### Persistence

- [Repository Selection](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/repositories/dependencies.py): `backend/app/repositories/dependencies.py`
- [SQLite Repositories](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/repositories/sqlite_repo.py): `backend/app/repositories/sqlite_repo.py`
- [Mongo Repositories](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/repositories/mongo_repo.py): `backend/app/repositories/mongo_repo.py`
- [SQLite Database](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/core/database.py): `backend/app/core/database.py`
- [MongoDB](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/core/mongo.py): `backend/app/core/mongo.py`
- [Threat Models](https://github.com/osaidsheikh1509-wq/cyber_risk/blob/main/backend/app/models/threat.py): `backend/app/models/threat.py`

### Other components

- **Security Analyst**
- **AI Model Service**

## Connections

- Security Analyst → Threat Dashboard: uses (evidence: `README.md`)
- Threat Dashboard → Threat API Client: requests data (evidence: `frontend/src/App.tsx`)
- Threat Detail → Threat API Client: requests timeline (evidence: `frontend/src/components/ThreatDetailPage.tsx`)
- Briefing Player → Threat API Client: requests briefing (evidence: `frontend/src/components/SpokenBriefingModal.tsx`)
- Threat API Client → Threat Operations: HTTP requests (evidence: `frontend/src/services/threatApi.ts`)
- Threat API Client → AI Assessment Route: assesses threat (evidence: `frontend/src/services/threatApi.ts`)
- Threat API Client → Voice Intake Route: submits voice (evidence: `README.md`)
- FastAPI Router → Threat Operations: mounts routes (evidence: `backend/app/main.py`)
- FastAPI Router → Threat Statistics: mounts routes (evidence: `backend/app/main.py`)
- FastAPI Router → AI Assessment Route: mounts routes (evidence: `backend/app/main.py`)
- FastAPI Router → Voice Intake Route: mounts routes (evidence: `backend/app/main.py`)
- Threat Operations → Repository Selection: uses repositories (evidence: `backend/app/api/v1/endpoints/threats.py`)
- Threat Statistics → Repository Selection: uses repositories (evidence: `backend/app/api/v1/endpoints/stats.py`)
- Threat Operations → Risk Scoring: calculates risk (evidence: `backend/app/api/v1/endpoints/threats.py`)
- Threat Operations → Sarvam Services: generates briefing (evidence: `backend/app/api/v1/endpoints/threats.py`)
- AI Assessment Route → Risk Model Providers: assesses event (evidence: `backend/app/api/v1/endpoints/ai.py`)
- AI Assessment Route → Risk Scoring: calculates score (evidence: `backend/app/api/v1/endpoints/ai.py`)
- Voice Intake Route → Sarvam Services: transcribes audio (evidence: `backend/app/api/v1/endpoints/voice.py`)
- Voice Intake Route → Risk Model Providers: assesses transcript (evidence: `backend/app/api/v1/endpoints/voice.py`)
- Risk Model Providers → Sarvam Services: calls provider (evidence: `backend/app/services/risk_model.py`)
- Risk Model Providers → AI Model Service: optional model (evidence: `README.md`)
- Repository Selection → SQLite Repositories: selects backend (evidence: `backend/app/repositories/dependencies.py`)
- Repository Selection → Mongo Repositories: selects backend (evidence: `backend/app/repositories/dependencies.py`)
- SQLite Repositories → SQLite Database: reads and writes
- Mongo Repositories → MongoDB: reads and writes
- Mongo Repositories → Risk Scoring: calculates risk (evidence: `backend/app/repositories/mongo_repo.py`)
- Mongo Repositories → Briefing Cache: uses cache (evidence: `backend/app/repositories/mongo_repo.py`)
- FastAPI Router → Threat Models: initializes models (evidence: `backend/app/main.py`)
- FastAPI Router → SQLite Database: creates tables (evidence: `backend/app/main.py`)
