# hisg-2427/taapsurakshak architecture

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

- Interactive diagram: https://gitdiagram.com/hisg-2427/taapsurakshak
- Repository: https://github.com/hisg-2427/taapsurakshak

## Overview

TaapSurakshak is a city heat-risk monitoring and emergency-response platform. Users view dashboard heat data and ward heatmaps; the web application proxies ward and prediction requests to the FastAPI service, which combines ward vulnerability/exposure with modeled heat forecasts and HMRI risk scores. The product also documents mortality-risk analysis, hospital-capacity monitoring, emergency alerts, and account access. Those UI branches are represented at their existing view directory because their implementation was not sampled. The graph omits uncertain wiring; sampled source establishes the main prediction, ward, MongoDB-user, weather, AI-suggestion, and WhatsApp paths.

Main entry points: [`app.js`](https://github.com/hisg-2427/taapsurakshak/blob/main/app.js) (Web routes), [`backend/app/services/prediction_service.py`](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/services/prediction_service.py) (Forecast and features), [`public/js/dashboard.js`](https://github.com/hisg-2427/taapsurakshak/blob/main/public/js/dashboard.js) (Risk dashboard), [`backend/app/routes/prediction.py`](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/routes/prediction.py) (Prediction routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Web routes<br/>[app.js]"]
  node_views["Risk and response views"]
  node_dashboard["Risk dashboard<br/>[dashboard.js]"]
end

subgraph group_risk["Risk analytics"]
  node_fastapi["Risk API<br/>[main.py]"]
  node_prediction_routes["Prediction routes<br/>[prediction.py]"]
  node_prediction_service["Forecast and features"]
  node_model_service["Forecast models<br/>[model_service.py]"]
  node_model_files["Model artifacts"]
  node_risk_score["HMRI scoring<br/>[risk_service.py]"]
  node_ward_routes["Ward routes<br/>[wards.py]"]
  node_ward_service["Ward factors<br/>[ward_service.py]"]
  node_risk_data["Ward and weather data"]
end

subgraph group_messaging["AI and messaging"]
  node_ai_routes["Suggestion endpoint<br/>[aiService.js]"]
  node_whatsapp_server["WhatsApp service<br/>[server.js]"]
end

subgraph group_state["User and data"]
  node_account["Account model<br/>[user.js]"]
  node_mongo[("MongoDB")]
end

node_resident(("City user"))
node_weather["Open-Meteo"]
node_gemini["Gemini AI"]
node_whatsapp["WhatsApp"]

node_resident -->|"uses"| node_webapp
node_webapp -->|"renders"| node_views
node_webapp -->|"queries"| node_account
node_account -->|"persists users"| node_mongo
node_views -->|"loads"| node_dashboard
node_dashboard -->|"requests heat data"| node_webapp
node_webapp -->|"fetches forecast"| node_weather
node_dashboard -->|"requests ward data"| node_webapp
node_webapp -->|"proxies predictions"| node_fastapi
node_fastapi -->|"dispatches"| node_prediction_routes
node_prediction_routes -->|"requests forecasts"| node_prediction_service
node_prediction_routes -->|"loads ward factors"| node_ward_service
node_prediction_service -->|"reads data"| node_risk_data
node_ward_service -->|"reads ward data"| node_risk_data
node_prediction_service -->|"predicts WBGT"| node_model_service
node_model_service -->|"loads models"| node_model_files
node_prediction_service -->|"scores forecasts"| node_risk_score
node_webapp -.->|"mounts routes"| node_ai_routes
node_ai_routes -->|"generates suggestion"| node_gemini
node_webapp -.->|"proxies messaging"| node_whatsapp_server
node_whatsapp_server -->|"sends messages"| node_whatsapp

click node_webapp "https://github.com/hisg-2427/taapsurakshak/blob/main/app.js"
click node_views "https://github.com/hisg-2427/taapsurakshak/tree/main/views/TaapSurakshak"
click node_dashboard "https://github.com/hisg-2427/taapsurakshak/blob/main/public/js/dashboard.js"
click node_account "https://github.com/hisg-2427/taapsurakshak/blob/main/models/user.js"
click node_fastapi "https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/main.py"
click node_prediction_routes "https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/routes/prediction.py"
click node_prediction_service "https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/services/prediction_service.py"
click node_model_service "https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/ml/model_service.py"
click node_model_files "https://github.com/hisg-2427/taapsurakshak/tree/main/backend/app/ml/models"
click node_risk_score "https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/services/risk_service.py"
click node_ward_routes "https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/routes/wards.py"
click node_ward_service "https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/services/ward_service.py"
click node_risk_data "https://github.com/hisg-2427/taapsurakshak/tree/main/backend/data"
click node_ai_routes "https://github.com/hisg-2427/taapsurakshak/blob/main/backend/aiService.js"
click node_whatsapp_server "https://github.com/hisg-2427/taapsurakshak/blob/main/backend/server.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_webapp,node_views,node_dashboard,node_resident toneBlue
class node_fastapi,node_prediction_routes,node_prediction_service,node_model_service,node_model_files,node_risk_score,node_ward_routes,node_ward_service,node_risk_data toneAmber
class node_ai_routes,node_whatsapp_server toneMint
class node_account,node_mongo toneRose
class node_weather,node_gemini,node_whatsapp toneIndigo
```

## Components

### Web application

- [Web routes](https://github.com/hisg-2427/taapsurakshak/blob/main/app.js): `app.js`
- [Risk and response views](https://github.com/hisg-2427/taapsurakshak/tree/main/views/TaapSurakshak): `views/TaapSurakshak`
- [Risk dashboard](https://github.com/hisg-2427/taapsurakshak/blob/main/public/js/dashboard.js): `public/js/dashboard.js`

### Risk analytics

- [Risk API](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/main.py): `backend/app/main.py`
- [Prediction routes](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/routes/prediction.py): `backend/app/routes/prediction.py`
- [Forecast and features](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/services/prediction_service.py): `backend/app/services/prediction_service.py`
- [Forecast models](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/ml/model_service.py): `backend/app/ml/model_service.py`
- [Model artifacts](https://github.com/hisg-2427/taapsurakshak/tree/main/backend/app/ml/models): `backend/app/ml/models`
- [HMRI scoring](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/services/risk_service.py): `backend/app/services/risk_service.py`
- [Ward routes](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/routes/wards.py): `backend/app/routes/wards.py`
- [Ward factors](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/app/services/ward_service.py): `backend/app/services/ward_service.py`
- [Ward and weather data](https://github.com/hisg-2427/taapsurakshak/tree/main/backend/data): `backend/data`

### AI and messaging

- [Suggestion endpoint](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/aiService.js): `backend/aiService.js`
- [WhatsApp service](https://github.com/hisg-2427/taapsurakshak/blob/main/backend/server.js): `backend/server.js`

### User and data

- [Account model](https://github.com/hisg-2427/taapsurakshak/blob/main/models/user.js): `models/user.js`
- **MongoDB**

### Other components

- **City user**
- **Open-Meteo**
- **Gemini AI**
- **WhatsApp**

## Connections

- City user → Web routes: uses
- Web routes → Risk and response views: renders
- Web routes → Account model: queries
- Account model → MongoDB: persists users
- Risk and response views → Risk dashboard: loads
- Risk dashboard → Web routes: requests heat data
- Web routes → Open-Meteo: fetches forecast
- Risk dashboard → Web routes: requests ward data
- Web routes → Risk API: proxies predictions
- Risk API → Prediction routes: dispatches
- Prediction routes → Forecast and features: requests forecasts
- Prediction routes → Ward factors: loads ward factors
- Forecast and features → Ward and weather data: reads data
- Ward factors → Ward and weather data: reads ward data
- Forecast and features → Forecast models: predicts WBGT
- Forecast models → Model artifacts: loads models
- Forecast and features → HMRI scoring: scores forecasts
- Web routes → Suggestion endpoint: mounts routes
- Suggestion endpoint → Gemini AI: generates suggestion
- Web routes → WhatsApp service: proxies messaging
- WhatsApp service → WhatsApp: sends messages
