# nagarjun012/thermo-guard architecture

> Architecture diagram of the GitHub repository nagarjun012/thermo-guard, 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/nagarjun012/thermo-guard
- Repository: https://github.com/nagarjun012/thermo-guard

## Overview

THERMO-GUARD is an India-wide heat early-warning and disaster-response platform with citizen and government portals. Its workflow combines weather telemetry with thermal-stress and health-risk assessment, then presents warnings, forecasts, and response resources. The government portal adds district-wide monitoring, facility support, and SITREP reporting. The graph reflects documented capabilities and indexed or excerpted relationships; several frontend-to-API connections are not evidenced in the sampled material and are therefore omitted.

Main entry points: [`backend/app/api/risk.py`](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/risk.py) (Risk assessment API), [`backend/app/main.py`](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/main.py) (FastAPI application), [`frontend/src/App.tsx`](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/App.tsx) (Portal routing), [`backend/app/services/weather_service.py`](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/weather_service.py) (Weather telemetry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portals["User portals"]
  node_app["Portal routing<br/>[App.tsx]"]
  node_citizen_portal["Citizen dashboard"]
  node_gov_portal["Government dashboard"]
  node_learning["Heat learning hub<br/>[LearnPage.tsx]"]
end

subgraph group_telemetry["Weather and thermal assessment"]
  node_weather_api["Weather API<br/>[weather.py]"]
  node_weather_service["Weather telemetry<br/>[weather_service.py]"]
  node_thermal_api["Thermal stress API<br/>[thermal_stress.py]"]
  node_thermal_service["Thermal indices"]
  node_htss_engine["HTSS calculations<br/>[htssEngine.ts]"]
end

subgraph group_risk["Risk and response"]
  node_risk_api["Risk assessment API<br/>[risk.py]"]
  node_risk_prediction["Health risk prediction"]
  node_ml_predict["ML prediction<br/>[predict.py]"]
  node_vulnerability["Vulnerability assessment"]
  node_alerts["Heat alerts<br/>[alert_service.py]"]
  node_recommendations["Safety recommendations"]
  node_forecast_api["Forecast API<br/>[forecast.py]"]
end

subgraph group_operations["Government operations"]
  node_gov_data["District monitoring data<br/>[govHtssService.ts]"]
  node_districts["District reference data"]
  node_facilities_api["Facility API<br/>[facilities.py]"]
  node_facility_aggregation["Facility aggregation"]
  node_facility_db[("Facility database")]
  node_cooling_centres["Cooling centres"]
  node_sitrep["SITREP PDF export"]
end

subgraph group_security["API and security"]
  node_backend["FastAPI application<br/>[main.py]"]
  node_auth_service["Portal authentication<br/>[authService.ts]"]
  node_auth_api["Session endpoints<br/>[login.ts]"]
  node_auth_utils["Session verification<br/>[auth.ts]"]
end

node_citizens(("Citizens and workers"))
node_authorities(("Disaster authorities"))
node_meteo["Open-Meteo"]
node_abdm["ABDM facilities"]

node_citizens -->|"opens portal"| node_app
node_authorities -->|"opens portal"| node_app
node_app -->|"routes to"| node_citizen_portal
node_app -->|"routes to"| node_gov_portal
node_app -->|"routes to"| node_learning
node_backend -->|"registers route"| node_weather_api
node_backend -->|"registers route"| node_thermal_api
node_backend -->|"registers route"| node_risk_api
node_backend -->|"registers route"| node_forecast_api
node_backend -->|"registers route"| node_facilities_api
node_weather_api -->|"uses telemetry"| node_weather_service
node_weather_service -->|"fetches weather"| node_meteo
node_thermal_api -->|"gets weather"| node_weather_service
node_thermal_api -->|"calculates stress"| node_thermal_service
node_risk_api -->|"gets weather"| node_weather_service
node_risk_api -->|"calculates stress"| node_thermal_service
node_risk_api -->|"assesses vulnerability"| node_vulnerability
node_risk_api -->|"predicts risk"| node_risk_prediction
node_risk_api -->|"requests prediction"| node_ml_predict
node_risk_api -->|"generates alerts"| node_alerts
node_risk_api -->|"gets recommendations"| node_recommendations
node_forecast_api -->|"gets forecast data"| node_weather_service
node_forecast_api -->|"calculates stress"| node_thermal_service
node_gov_portal -.->|"shows district data"| node_gov_data
node_gov_data -->|"uses district list"| node_districts
node_facilities_api -->|"requests facilities"| node_facility_aggregation
node_facility_aggregation -->|"reads and writes"| node_facility_db
node_facility_aggregation -->|"fetches facilities"| node_abdm
node_facility_aggregation -->|"fetches centres"| node_cooling_centres
node_auth_service -->|"calls login"| node_auth_api
node_auth_api -->|"uses session helpers"| node_auth_utils
node_gov_portal -.->|"exports report"| node_sitrep

click node_app "https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/App.tsx"
click node_citizen_portal "https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/pages/CitizenDashboard.tsx"
click node_gov_portal "https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/pages/GovernmentDashboard.tsx"
click node_learning "https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/pages/LearnPage.tsx"
click node_weather_api "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/weather.py"
click node_weather_service "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/weather_service.py"
click node_thermal_api "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/thermal_stress.py"
click node_thermal_service "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/thermal_stress_service.py"
click node_htss_engine "https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/lib/htssEngine.ts"
click node_risk_api "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/risk.py"
click node_risk_prediction "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/risk_prediction_service.py"
click node_ml_predict "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/ml/predict.py"
click node_vulnerability "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/vulnerability_service.py"
click node_alerts "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/alert_service.py"
click node_recommendations "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/recommendation_service.py"
click node_forecast_api "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/forecast.py"
click node_gov_data "https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/services/govHtssService.ts"
click node_districts "https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/data/allIndiaDistricts.ts"
click node_facilities_api "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/facilities.py"
click node_facility_aggregation "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/facility_aggregation/aggregation_engine.py"
click node_facility_db "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/facility_aggregation/database_manager.py"
click node_cooling_centres "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/facility_aggregation/cooling_centre_adapter.py"
click node_backend "https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/main.py"
click node_auth_service "https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/services/authService.ts"
click node_auth_api "https://github.com/nagarjun012/thermo-guard/blob/main/api/auth/login.ts"
click node_auth_utils "https://github.com/nagarjun012/thermo-guard/blob/main/api/_utils/auth.ts"
click node_sitrep "https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/utils/sitrepPdfGenerator.ts"

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_citizen_portal,node_gov_portal,node_learning toneBlue
class node_weather_api,node_weather_service,node_thermal_api,node_thermal_service,node_htss_engine toneAmber
class node_risk_api,node_risk_prediction,node_ml_predict,node_vulnerability,node_alerts,node_recommendations,node_forecast_api toneMint
class node_gov_data,node_districts,node_facilities_api,node_facility_aggregation,node_facility_db,node_cooling_centres,node_sitrep,node_citizens toneRose
class node_backend,node_auth_service,node_auth_api,node_auth_utils,node_authorities,node_meteo,node_abdm toneIndigo
```

## Components

### User portals

- [Portal routing](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Citizen dashboard](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/pages/CitizenDashboard.tsx): `frontend/src/pages/CitizenDashboard.tsx`
- [Government dashboard](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/pages/GovernmentDashboard.tsx): `frontend/src/pages/GovernmentDashboard.tsx`
- [Heat learning hub](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/pages/LearnPage.tsx): `frontend/src/pages/LearnPage.tsx`

### Weather and thermal assessment

- [Weather API](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/weather.py): `backend/app/api/weather.py`
- [Weather telemetry](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/weather_service.py): `backend/app/services/weather_service.py`
- [Thermal stress API](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/thermal_stress.py): `backend/app/api/thermal_stress.py`
- [Thermal indices](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/thermal_stress_service.py): `backend/app/services/thermal_stress_service.py`
- [HTSS calculations](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/lib/htssEngine.ts): `frontend/src/lib/htssEngine.ts`

### Risk and response

- [Risk assessment API](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/risk.py): `backend/app/api/risk.py`
- [Health risk prediction](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/risk_prediction_service.py): `backend/app/services/risk_prediction_service.py`
- [ML prediction](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/ml/predict.py): `backend/app/ml/predict.py`
- [Vulnerability assessment](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/vulnerability_service.py): `backend/app/services/vulnerability_service.py`
- [Heat alerts](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/alert_service.py): `backend/app/services/alert_service.py`
- [Safety recommendations](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/recommendation_service.py): `backend/app/services/recommendation_service.py`
- [Forecast API](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/forecast.py): `backend/app/api/forecast.py`

### Government operations

- [District monitoring data](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/services/govHtssService.ts): `frontend/src/services/govHtssService.ts`
- [District reference data](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/data/allIndiaDistricts.ts): `frontend/src/data/allIndiaDistricts.ts`
- [Facility API](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/api/facilities.py): `backend/app/api/facilities.py`
- [Facility aggregation](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/facility_aggregation/aggregation_engine.py): `backend/app/services/facility_aggregation/aggregation_engine.py`
- [Facility database](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/facility_aggregation/database_manager.py): `backend/app/services/facility_aggregation/database_manager.py`
- [Cooling centres](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/services/facility_aggregation/cooling_centre_adapter.py): `backend/app/services/facility_aggregation/cooling_centre_adapter.py`
- [SITREP PDF export](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/utils/sitrepPdfGenerator.ts): `frontend/src/utils/sitrepPdfGenerator.ts`

### API and security

- [FastAPI application](https://github.com/nagarjun012/thermo-guard/blob/main/backend/app/main.py): `backend/app/main.py`
- [Portal authentication](https://github.com/nagarjun012/thermo-guard/blob/main/frontend/src/services/authService.ts): `frontend/src/services/authService.ts`
- [Session endpoints](https://github.com/nagarjun012/thermo-guard/blob/main/api/auth/login.ts): `api/auth/login.ts`
- [Session verification](https://github.com/nagarjun012/thermo-guard/blob/main/api/_utils/auth.ts): `api/_utils/auth.ts`

### Other components

- **Citizens and workers**
- **Disaster authorities**
- **Open-Meteo**
- **ABDM facilities**

## Connections

- Citizens and workers → Portal routing: opens portal
- Disaster authorities → Portal routing: opens portal
- Portal routing → Citizen dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Portal routing → Government dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Portal routing → Heat learning hub: routes to (evidence: `frontend/src/App.tsx`)
- FastAPI application → Weather API: registers route (evidence: `backend/app/main.py`)
- FastAPI application → Thermal stress API: registers route (evidence: `backend/app/main.py`)
- FastAPI application → Risk assessment API: registers route (evidence: `backend/app/main.py`)
- FastAPI application → Forecast API: registers route (evidence: `backend/app/main.py`)
- FastAPI application → Facility API: registers route (evidence: `backend/app/main.py`)
- Weather API → Weather telemetry: uses telemetry
- Weather telemetry → Open-Meteo: fetches weather (evidence: `backend/app/services/weather_service.py`)
- Thermal stress API → Weather telemetry: gets weather (evidence: `backend/app/api/thermal_stress.py`)
- Thermal stress API → Thermal indices: calculates stress (evidence: `backend/app/api/thermal_stress.py`)
- Risk assessment API → Weather telemetry: gets weather (evidence: `backend/app/api/risk.py`)
- Risk assessment API → Thermal indices: calculates stress (evidence: `backend/app/api/risk.py`)
- Risk assessment API → Vulnerability assessment: assesses vulnerability (evidence: `backend/app/api/risk.py`)
- Risk assessment API → Health risk prediction: predicts risk (evidence: `backend/app/api/risk.py`)
- Risk assessment API → ML prediction: requests prediction (evidence: `backend/app/api/risk.py`)
- Risk assessment API → Heat alerts: generates alerts (evidence: `backend/app/api/risk.py`)
- Risk assessment API → Safety recommendations: gets recommendations (evidence: `backend/app/api/risk.py`)
- Forecast API → Weather telemetry: gets forecast data (evidence: `backend/app/api/forecast.py`)
- Forecast API → Thermal indices: calculates stress (evidence: `backend/app/api/forecast.py`)
- Government dashboard → District monitoring data: shows district data
- District monitoring data → District reference data: uses district list (evidence: `frontend/src/services/govHtssService.ts`)
- Facility API → Facility aggregation: requests facilities (evidence: `backend/app/api/facilities.py`)
- Facility aggregation → Facility database: reads and writes (evidence: `backend/app/services/facility_aggregation/aggregation_engine.py`)
- Facility aggregation → ABDM facilities: fetches facilities (evidence: `backend/app/services/facility_aggregation/aggregation_engine.py`)
- Facility aggregation → Cooling centres: fetches centres (evidence: `backend/app/services/facility_aggregation/aggregation_engine.py`)
- Portal authentication → Session endpoints: calls login (evidence: `frontend/src/services/authService.ts`)
- Session endpoints → Session verification: uses session helpers (evidence: `api/auth/login.ts`)
- Government dashboard → SITREP PDF export: exports report
