# rohit25-git/pravaah architecture

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

- Interactive diagram: https://gitdiagram.com/rohit25-git/pravaah
- Repository: https://github.com/rohit25-git/pravaah

## Overview

PRAVAAH forecasts ATM cash-out risk from transaction, complaint, and ATM observations, then turns elevated predictions into alerts and operational intelligence for law-enforcement and banking users. The frontend provides command, map, prediction, investigation, graph, case, report, and bank workflows through an API client; the backend exposes these through FastAPI and persists domain records. The prediction and alert path is supported by sampled source; other capability branches are documented in the README and their detailed implementation was not sampled.

Main entry points: [`backend/app/services/prediction_service.py`](https://github.com/rohit25-git/pravaah/blob/main/backend/app/services/prediction_service.py) (Prediction runner), [`backend/app/database/session.py`](https://github.com/rohit25-git/pravaah/blob/main/backend/app/database/session.py) (PostGIS database), [`backend/app/main.py`](https://github.com/rohit25-git/pravaah/blob/main/backend/app/main.py) (FastAPI app), [`frontend/src/services/api.ts`](https://github.com/rohit25-git/pravaah/blob/main/frontend/src/services/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User console"]
  node_frontend["Portal shell<br/>[App.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
  node_graph_ui["Graph explorer"]
  node_map_ui["GIS heatmap<br/>[LeafletMap.tsx]"]
end

subgraph group_api["Backend API"]
  node_backend["FastAPI app<br/>[main.py]"]
  node_routes["V1 endpoints"]
end

subgraph group_intelligence["Risk intelligence"]
  node_prediction_runner["Prediction runner"]
  node_ml_engine["ML scoring pipeline"]
  node_features["Feature engineering<br/>[features.py]"]
  node_risk_scoring["Weighted risk scoring<br/>[scoring.py]"]
  node_graph_service["Network intelligence<br/>[network_service.py]"]
end

subgraph group_operations["Response workflows"]
  node_alerts["Alert evaluation<br/>[engine.py]"]
  node_notifications["Live notifications<br/>[notification.py]"]
  node_ai["AI copilot<br/>[copilot.py]"]
  node_reports["Intelligence reports<br/>[report_service.py]"]
  node_simulation["Activity simulation"]
end

subgraph group_persistence["Domain storage"]
  node_database[("PostGIS database<br/>[session.py]")]
  node_transactions["Transactions &amp; complaints<br/>[transaction.py]"]
  node_predictions["Predictions &amp; risk factors<br/>[prediction.py]"]
  node_cases_evidence["Cases &amp; evidence<br/>[case.py]"]
  node_identity["Users &amp; audit records<br/>[user.py]"]
end

node_users(("Analysts &amp; officers"))

node_users -->|"uses"| node_frontend
node_frontend -.->|"requests data"| node_api_client
node_frontend -->|"renders"| node_graph_ui
node_graph_ui -->|"loads graph data"| node_api_client
node_map_ui -.->|"uses map data"| node_api_client
node_api_client -->|"calls HTTP &amp; WebSocket"| node_backend
node_backend -->|"mounts routers"| node_routes
node_routes -.->|"dispatches predictions"| node_prediction_runner
node_prediction_runner -->|"reads observations"| node_transactions
node_prediction_runner -->|"builds features"| node_features
node_prediction_runner -->|"scores risk"| node_risk_scoring
node_prediction_runner -->|"writes predictions"| node_predictions
node_prediction_runner -->|"evaluates alerts"| node_alerts
node_ml_engine -->|"calculates features"| node_features
node_ml_engine -->|"calculates composite score"| node_risk_scoring
node_alerts -->|"broadcasts alerts"| node_notifications
node_backend -->|"serves alert socket"| node_notifications
node_backend -.->|"initializes storage"| node_database
node_transactions -->|"maps tables"| node_database
node_predictions -->|"maps tables"| node_database
node_identity -->|"maps tables"| node_database
node_cases_evidence -.->|"maps tables"| node_database
node_graph_service -->|"uses case relations"| node_cases_evidence
node_ai -->|"grounds answers"| node_predictions
node_ai -->|"grounds answers"| node_cases_evidence
node_reports -->|"reads intelligence"| node_predictions
node_reports -->|"reads case evidence"| node_cases_evidence
node_simulation -->|"creates activity"| node_transactions
node_simulation -->|"evaluates alerts"| node_alerts
node_users -.->|"asks decision support"| node_ai
node_users -.->|"generates bulletins"| node_reports
node_users -.->|"traces entities"| node_graph_service
node_users -.->|"triggers simulation"| node_simulation

click node_frontend "https://github.com/rohit25-git/pravaah/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/rohit25-git/pravaah/blob/main/frontend/src/services/api.ts"
click node_graph_ui "https://github.com/rohit25-git/pravaah/blob/main/frontend/src/pages/GraphIntelligencePage.tsx"
click node_map_ui "https://github.com/rohit25-git/pravaah/blob/main/frontend/src/components/LeafletMap.tsx"
click node_backend "https://github.com/rohit25-git/pravaah/blob/main/backend/app/main.py"
click node_routes "https://github.com/rohit25-git/pravaah/tree/main/backend/app/api/v1"
click node_prediction_runner "https://github.com/rohit25-git/pravaah/blob/main/backend/app/services/prediction_service.py"
click node_ml_engine "https://github.com/rohit25-git/pravaah/blob/main/backend/app/ml/prediction_service.py"
click node_features "https://github.com/rohit25-git/pravaah/blob/main/backend/app/ml/features.py"
click node_risk_scoring "https://github.com/rohit25-git/pravaah/blob/main/backend/app/ml/scoring.py"
click node_graph_service "https://github.com/rohit25-git/pravaah/blob/main/backend/app/graph/network_service.py"
click node_alerts "https://github.com/rohit25-git/pravaah/blob/main/backend/app/alerts/engine.py"
click node_notifications "https://github.com/rohit25-git/pravaah/blob/main/backend/app/alerts/notification.py"
click node_ai "https://github.com/rohit25-git/pravaah/blob/main/backend/app/ai/copilot.py"
click node_reports "https://github.com/rohit25-git/pravaah/blob/main/backend/app/services/report_service.py"
click node_simulation "https://github.com/rohit25-git/pravaah/blob/main/backend/app/services/simulation_service.py"
click node_database "https://github.com/rohit25-git/pravaah/blob/main/backend/app/database/session.py"
click node_transactions "https://github.com/rohit25-git/pravaah/blob/main/backend/app/models/transaction.py"
click node_predictions "https://github.com/rohit25-git/pravaah/blob/main/backend/app/models/prediction.py"
click node_cases_evidence "https://github.com/rohit25-git/pravaah/blob/main/backend/app/models/case.py"
click node_identity "https://github.com/rohit25-git/pravaah/blob/main/backend/app/models/user.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_frontend,node_api_client,node_graph_ui,node_map_ui toneBlue
class node_backend,node_routes toneAmber
class node_prediction_runner,node_ml_engine,node_features,node_risk_scoring,node_graph_service toneMint
class node_alerts,node_notifications,node_ai,node_reports,node_simulation toneRose
class node_database,node_transactions,node_predictions,node_cases_evidence,node_identity,node_users toneIndigo
```

## Components

### User console

- [Portal shell](https://github.com/rohit25-git/pravaah/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/rohit25-git/pravaah/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [Graph explorer](https://github.com/rohit25-git/pravaah/blob/main/frontend/src/pages/GraphIntelligencePage.tsx): `frontend/src/pages/GraphIntelligencePage.tsx`
- [GIS heatmap](https://github.com/rohit25-git/pravaah/blob/main/frontend/src/components/LeafletMap.tsx): `frontend/src/components/LeafletMap.tsx`

### Backend API

- [FastAPI app](https://github.com/rohit25-git/pravaah/blob/main/backend/app/main.py): `backend/app/main.py`
- [V1 endpoints](https://github.com/rohit25-git/pravaah/tree/main/backend/app/api/v1): `backend/app/api/v1`

### Risk intelligence

- [Prediction runner](https://github.com/rohit25-git/pravaah/blob/main/backend/app/services/prediction_service.py): `backend/app/services/prediction_service.py`
- [ML scoring pipeline](https://github.com/rohit25-git/pravaah/blob/main/backend/app/ml/prediction_service.py): `backend/app/ml/prediction_service.py`
- [Feature engineering](https://github.com/rohit25-git/pravaah/blob/main/backend/app/ml/features.py): `backend/app/ml/features.py`
- [Weighted risk scoring](https://github.com/rohit25-git/pravaah/blob/main/backend/app/ml/scoring.py): `backend/app/ml/scoring.py`
- [Network intelligence](https://github.com/rohit25-git/pravaah/blob/main/backend/app/graph/network_service.py): `backend/app/graph/network_service.py`

### Response workflows

- [Alert evaluation](https://github.com/rohit25-git/pravaah/blob/main/backend/app/alerts/engine.py): `backend/app/alerts/engine.py`
- [Live notifications](https://github.com/rohit25-git/pravaah/blob/main/backend/app/alerts/notification.py): `backend/app/alerts/notification.py`
- [AI copilot](https://github.com/rohit25-git/pravaah/blob/main/backend/app/ai/copilot.py): `backend/app/ai/copilot.py`
- [Intelligence reports](https://github.com/rohit25-git/pravaah/blob/main/backend/app/services/report_service.py): `backend/app/services/report_service.py`
- [Activity simulation](https://github.com/rohit25-git/pravaah/blob/main/backend/app/services/simulation_service.py): `backend/app/services/simulation_service.py`

### Domain storage

- [PostGIS database](https://github.com/rohit25-git/pravaah/blob/main/backend/app/database/session.py): `backend/app/database/session.py`
- [Transactions & complaints](https://github.com/rohit25-git/pravaah/blob/main/backend/app/models/transaction.py): `backend/app/models/transaction.py`
- [Predictions & risk factors](https://github.com/rohit25-git/pravaah/blob/main/backend/app/models/prediction.py): `backend/app/models/prediction.py`
- [Cases & evidence](https://github.com/rohit25-git/pravaah/blob/main/backend/app/models/case.py): `backend/app/models/case.py`
- [Users & audit records](https://github.com/rohit25-git/pravaah/blob/main/backend/app/models/user.py): `backend/app/models/user.py`

### Other components

- **Analysts & officers**

## Connections

- Analysts & officers → Portal shell: uses
- Portal shell → API client: requests data (evidence: `frontend/src/App.tsx`)
- Portal shell → Graph explorer: renders (evidence: `frontend/src/App.tsx`)
- Graph explorer → API client: loads graph data (evidence: `frontend/src/pages/GraphIntelligencePage.tsx`)
- GIS heatmap → API client: uses map data
- API client → FastAPI app: calls HTTP & WebSocket (evidence: `frontend/src/services/api.ts`)
- FastAPI app → V1 endpoints: mounts routers (evidence: `backend/app/main.py`)
- V1 endpoints → Prediction runner: dispatches predictions
- Prediction runner → Transactions & complaints: reads observations (evidence: `backend/app/services/prediction_service.py`)
- Prediction runner → Feature engineering: builds features (evidence: `backend/app/services/prediction_service.py`)
- Prediction runner → Weighted risk scoring: scores risk (evidence: `backend/app/services/prediction_service.py`)
- Prediction runner → Predictions & risk factors: writes predictions (evidence: `backend/app/services/prediction_service.py`)
- Prediction runner → Alert evaluation: evaluates alerts (evidence: `backend/app/services/prediction_service.py`)
- ML scoring pipeline → Feature engineering: calculates features (evidence: `backend/app/ml/prediction_service.py`)
- ML scoring pipeline → Weighted risk scoring: calculates composite score (evidence: `backend/app/ml/prediction_service.py`)
- Alert evaluation → Live notifications: broadcasts alerts (evidence: `backend/app/alerts/engine.py`)
- FastAPI app → Live notifications: serves alert socket (evidence: `backend/app/main.py`)
- FastAPI app → PostGIS database: initializes storage (evidence: `backend/app/main.py`)
- Transactions & complaints → PostGIS database: maps tables (evidence: `backend/app/models/transaction.py`)
- Predictions & risk factors → PostGIS database: maps tables (evidence: `backend/app/models/prediction.py`)
- Users & audit records → PostGIS database: maps tables (evidence: `backend/app/models/user.py`)
- Cases & evidence → PostGIS database: maps tables (evidence: `backend/app/models/case.py`)
- Network intelligence → Cases & evidence: uses case relations (evidence: `backend/app/graph/network_service.py`)
- AI copilot → Predictions & risk factors: grounds answers (evidence: `backend/app/ai/copilot.py`)
- AI copilot → Cases & evidence: grounds answers (evidence: `backend/app/ai/copilot.py`)
- Intelligence reports → Predictions & risk factors: reads intelligence (evidence: `backend/app/services/report_service.py`)
- Intelligence reports → Cases & evidence: reads case evidence (evidence: `backend/app/services/report_service.py`)
- Activity simulation → Transactions & complaints: creates activity (evidence: `backend/app/services/simulation_service.py`)
- Activity simulation → Alert evaluation: evaluates alerts (evidence: `backend/app/services/simulation_service.py`)
- Analysts & officers → AI copilot: asks decision support
- Analysts & officers → Intelligence reports: generates bulletins
- Analysts & officers → Network intelligence: traces entities
- Analysts & officers → Activity simulation: triggers simulation
