# harshitkumar135267/pravaah architecture

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

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

## Overview

PRAVAAH is a disaster-intelligence and early-warning platform for rainfall, floods, river hazards, and landslides. Authorities and other users explore risk and telemetry in the web command center; the frontend obtains dashboard, hazard, history, and ML information through the FastAPI API. Ingestion accepts weather, river, and infrastructure data, while alerting and simulation support warnings and real-time updates. The graph includes the documented capability areas, but unsampled endpoint implementations and frontend API wiring limit which internal connections can be verified.

Main entry points: [`backend/app/api/v1/router.py`](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/router.py) (API route registry), [`backend/app/main.py`](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/main.py) (API and WebSocket app), [`backend/app/websocket/manager.py`](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/websocket/manager.py) (WebSocket manager), [`frontend/app/dashboard/page.tsx`](https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/dashboard/page.tsx) (Web command center)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Command Center"]
  node_command["Web command center<br/>[page.tsx]"]
  node_gis["GIS and risk map<br/>[MapComponent.tsx]"]
  node_hazard_pages["Hazard pages<br/>[page.tsx]"]
  node_rainfall_page["Rainfall page<br/>[page.tsx]"]
  node_analytics_page["Analytics page<br/>[page.tsx]"]
  node_history_page["Event history<br/>[page.tsx]"]
  node_admin_page["Admin console<br/>[page.tsx]"]
  node_websocket_hook["Alert WebSocket hook"]
end

subgraph group_api["API and Operations"]
  node_app_entry["API and WebSocket app<br/>[main.py]"]
  node_api_router["API route registry<br/>[router.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_alert_api["Alert endpoints<br/>[alerts.py]"]
  node_ingestion_api["Ingestion endpoints<br/>[ingestion.py]"]
  node_hazard_apis["Hazard and telemetry APIs"]
  node_analytics_api["Analytics endpoint<br/>[analytics.py]"]
  node_ml_api["ML endpoints<br/>[ml.py]"]
  node_simulation_api["Disaster simulation<br/>[simulation.py]"]
end

subgraph group_domain["Risk and Response"]
  node_ingestion_service["Telemetry ingestion"]
  node_ml_service["Risk prediction<br/>[ml_service.py]"]
  node_alert_service["Alert lifecycle<br/>[alert_service.py]"]
end

subgraph group_data["Data Layer"]
  node_models["Domain records"]
  node_schemas["API contracts"]
  node_database[("Relational database<br/>[database.py]")]
  node_config["Runtime configuration<br/>[config.py]"]
  node_seed["Demo data seeding<br/>[seed_data.py]"]
end

subgraph group_realtime["Live Updates"]
  node_ws_manager["WebSocket manager<br/>[manager.py]"]
end

node_authorities(("Authorities and users"))
node_browser(("Browser user"))

node_authorities -->|"explores risks"| node_command
node_command -->|"navigates to"| node_hazard_pages
node_browser -->|"uses API"| node_app_entry
node_app_entry -->|"mounts routes"| node_api_router
node_api_router -->|"registers"| node_auth
node_api_router -->|"registers"| node_alert_api
node_api_router -->|"registers"| node_ingestion_api
node_api_router -->|"registers"| node_hazard_apis
node_api_router -->|"registers"| node_analytics_api
node_api_router -->|"registers"| node_ml_api
node_api_router -->|"registers"| node_simulation_api
node_ingestion_api -->|"processes telemetry"| node_ingestion_service
node_ingestion_service -->|"writes observations"| node_models
node_ml_api -->|"requests predictions"| node_ml_service
node_ml_service -->|"uses contracts"| node_schemas
node_alert_api -->|"manages alerts"| node_alert_service
node_analytics_api -->|"queries records"| node_models
node_app_entry -->|"creates schema"| node_database
node_database -->|"uses settings"| node_config
node_app_entry -->|"seeds database"| node_seed
node_app_entry -->|"connects clients"| node_ws_manager
node_browser -->|"receives warnings"| node_websocket_hook
node_websocket_hook -.->|"opens alert socket"| node_app_entry
node_simulation_api -.->|"broadcasts warning"| node_ws_manager
node_alert_service -.->|"broadcasts alerts"| node_ws_manager

click node_command "https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/dashboard/page.tsx"
click node_gis "https://github.com/harshitkumar135267/pravaah/blob/master/frontend/components/MapComponent.tsx"
click node_hazard_pages "https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/flood-risk/page.tsx"
click node_rainfall_page "https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/rainfall/page.tsx"
click node_analytics_page "https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/analytics/page.tsx"
click node_history_page "https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/history/page.tsx"
click node_admin_page "https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/admin/page.tsx"
click node_websocket_hook "https://github.com/harshitkumar135267/pravaah/blob/master/frontend/hooks/useAlertWebSocket.ts"
click node_app_entry "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/main.py"
click node_api_router "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/router.py"
click node_auth "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/auth.py"
click node_alert_api "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/alerts.py"
click node_ingestion_api "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/ingestion.py"
click node_hazard_apis "https://github.com/harshitkumar135267/pravaah/tree/master/backend/app/api/v1/endpoints"
click node_analytics_api "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/analytics.py"
click node_ml_api "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/ml.py"
click node_simulation_api "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/simulation.py"
click node_ingestion_service "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/services/ingestion_service.py"
click node_ml_service "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/services/ml_service.py"
click node_alert_service "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/services/alert_service.py"
click node_models "https://github.com/harshitkumar135267/pravaah/tree/master/backend/app/models"
click node_schemas "https://github.com/harshitkumar135267/pravaah/tree/master/backend/app/schemas"
click node_database "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/core/database.py"
click node_config "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/core/config.py"
click node_seed "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/seed_data.py"
click node_ws_manager "https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/websocket/manager.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_command,node_gis,node_hazard_pages,node_rainfall_page,node_analytics_page,node_history_page,node_admin_page,node_websocket_hook,node_authorities,node_browser toneBlue
class node_app_entry,node_api_router,node_auth,node_alert_api,node_ingestion_api,node_hazard_apis,node_analytics_api,node_ml_api,node_simulation_api toneAmber
class node_ingestion_service,node_ml_service,node_alert_service toneMint
class node_models,node_schemas,node_database,node_config,node_seed toneRose
class node_ws_manager toneIndigo
```

## Components

### Command Center

- [Web command center](https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/dashboard/page.tsx): `frontend/app/dashboard/page.tsx`
- [GIS and risk map](https://github.com/harshitkumar135267/pravaah/blob/master/frontend/components/MapComponent.tsx): `frontend/components/MapComponent.tsx`
- [Hazard pages](https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/flood-risk/page.tsx): `frontend/app/flood-risk/page.tsx`
- [Rainfall page](https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/rainfall/page.tsx): `frontend/app/rainfall/page.tsx`
- [Analytics page](https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/analytics/page.tsx): `frontend/app/analytics/page.tsx`
- [Event history](https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/history/page.tsx): `frontend/app/history/page.tsx`
- [Admin console](https://github.com/harshitkumar135267/pravaah/blob/master/frontend/app/admin/page.tsx): `frontend/app/admin/page.tsx`
- [Alert WebSocket hook](https://github.com/harshitkumar135267/pravaah/blob/master/frontend/hooks/useAlertWebSocket.ts): `frontend/hooks/useAlertWebSocket.ts`

### API and Operations

- [API and WebSocket app](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/main.py): `backend/app/main.py`
- [API route registry](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [Authentication](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/auth.py): `backend/app/api/v1/endpoints/auth.py`
- [Alert endpoints](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/alerts.py): `backend/app/api/v1/endpoints/alerts.py`
- [Ingestion endpoints](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/ingestion.py): `backend/app/api/v1/endpoints/ingestion.py`
- [Hazard and telemetry APIs](https://github.com/harshitkumar135267/pravaah/tree/master/backend/app/api/v1/endpoints): `backend/app/api/v1/endpoints`
- [Analytics endpoint](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/analytics.py): `backend/app/api/v1/endpoints/analytics.py`
- [ML endpoints](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/ml.py): `backend/app/api/v1/endpoints/ml.py`
- [Disaster simulation](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/api/v1/endpoints/simulation.py): `backend/app/api/v1/endpoints/simulation.py`

### Risk and Response

- [Telemetry ingestion](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/services/ingestion_service.py): `backend/app/services/ingestion_service.py`
- [Risk prediction](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/services/ml_service.py): `backend/app/services/ml_service.py`
- [Alert lifecycle](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/services/alert_service.py): `backend/app/services/alert_service.py`

### Data Layer

- [Domain records](https://github.com/harshitkumar135267/pravaah/tree/master/backend/app/models): `backend/app/models`
- [API contracts](https://github.com/harshitkumar135267/pravaah/tree/master/backend/app/schemas): `backend/app/schemas`
- [Relational database](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/core/database.py): `backend/app/core/database.py`
- [Runtime configuration](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/core/config.py): `backend/app/core/config.py`
- [Demo data seeding](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/seed_data.py): `backend/app/seed_data.py`

### Live Updates

- [WebSocket manager](https://github.com/harshitkumar135267/pravaah/blob/master/backend/app/websocket/manager.py): `backend/app/websocket/manager.py`

### Other components

- **Authorities and users**
- **Browser user**

## Connections

- Authorities and users → Web command center: explores risks (evidence: `README.md`)
- Web command center → Hazard pages: navigates to (evidence: `README.md`)
- Browser user → API and WebSocket app: uses API (evidence: `README.md`)
- API and WebSocket app → API route registry: mounts routes (evidence: `backend/app/main.py`)
- API route registry → Authentication: registers (evidence: `backend/app/api/v1/router.py`)
- API route registry → Alert endpoints: registers (evidence: `backend/app/api/v1/router.py`)
- API route registry → Ingestion endpoints: registers (evidence: `backend/app/api/v1/router.py`)
- API route registry → Hazard and telemetry APIs: registers (evidence: `backend/app/api/v1/router.py`)
- API route registry → Analytics endpoint: registers (evidence: `backend/app/api/v1/router.py`)
- API route registry → ML endpoints: registers (evidence: `backend/app/api/v1/router.py`)
- API route registry → Disaster simulation: registers (evidence: `backend/app/api/v1/router.py`)
- Ingestion endpoints → Telemetry ingestion: processes telemetry (evidence: `backend/app/api/v1/endpoints/ingestion.py`)
- Telemetry ingestion → Domain records: writes observations (evidence: `backend/app/services/ingestion_service.py`)
- ML endpoints → Risk prediction: requests predictions (evidence: `backend/app/api/v1/endpoints/ml.py`)
- Risk prediction → API contracts: uses contracts (evidence: `backend/app/services/ml_service.py`)
- Alert endpoints → Alert lifecycle: manages alerts (evidence: `backend/app/api/v1/endpoints/alerts.py`)
- Analytics endpoint → Domain records: queries records (evidence: `backend/app/api/v1/endpoints/analytics.py`)
- API and WebSocket app → Relational database: creates schema (evidence: `backend/app/main.py`)
- Relational database → Runtime configuration: uses settings (evidence: `backend/app/core/database.py`)
- API and WebSocket app → Demo data seeding: seeds database (evidence: `backend/app/main.py`)
- API and WebSocket app → WebSocket manager: connects clients (evidence: `backend/app/main.py`)
- Browser user → Alert WebSocket hook: receives warnings (evidence: `README.md`)
- Alert WebSocket hook → API and WebSocket app: opens alert socket
- Disaster simulation → WebSocket manager: broadcasts warning
- Alert lifecycle → WebSocket manager: broadcasts alerts
