# r-samarth/heat-cdd architecture

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

- Interactive diagram: https://gitdiagram.com/r-samarth/heat-cdd
- Repository: https://github.com/r-samarth/heat-cdd

## Overview

Cool Block Commander is a municipal heat-risk planning application for Mumbai and Mysuru. The user selects a city and budget; the browser requests an optimization, then presents ward-level risk and recommended actions in dashboard and map views. Backend responsibilities include officer and budget authorization, intervention commits, and risk optimization backed by ward data and persisted intervention state. The excerpts show the browser-to-optimization request and several backend data operations; other endpoint relationships are not inferred where their callers are unsampled.

Main entry points: [`frontend/script.js`](https://github.com/r-samarth/heat-cdd/blob/main/frontend/script.js) (Dashboard and map), [`backend/main.py`](https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py) (Database initialization), [`backend/data/mcgm_portal.db`](https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mcgm_portal.db) (Portal state), [`backend/data/mumbai_24_wards_master.csv`](https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mumbai_24_wards_master.csv) (Mumbai ward master)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Planning Interface"]
  node_dashboard["Dashboard and map<br/>[script.js]"]
end

subgraph group_backend["Planning Backend"]
  node_simulation_api["Simulation API<br/>[main.py]"]
  node_risk_optimizer["Risk optimization<br/>[main.py]"]
  node_officer_access["Officer and budget access<br/>[main.py]"]
  node_action_commit["Intervention commits<br/>[main.py]"]
  node_database_init["Database initialization<br/>[main.py]"]
end

subgraph group_data["Ward Data and State"]
  node_sqlite_state[("Portal state<br/>[mcgm_portal.db]")]
  node_mumbai_wards["Mumbai ward master"]
  node_mysore_wards["Mysore ward master"]
  node_mumbai_history["Mumbai heat history"]
  node_mysore_history["Mysore heat history"]
end

subgraph group_maps["Map Services"]
  node_mysore_geo["Mysore ward geometry"]
  node_basemap["Carto basemap tiles"]
end

node_planner(("Municipal planner"))

node_planner -->|"uses"| node_dashboard
node_dashboard -->|"requests optimization"| node_simulation_api
node_simulation_api -->|"dispatches"| node_risk_optimizer
node_risk_optimizer -->|"reads interventions"| node_sqlite_state
node_database_init -->|"initializes"| node_sqlite_state
node_database_init -->|"reads ward data"| node_mumbai_wards
node_dashboard -->|"loads geometry"| node_mysore_geo
node_dashboard -->|"loads tiles"| node_basemap

click node_dashboard "https://github.com/r-samarth/heat-cdd/blob/main/frontend/script.js"
click node_simulation_api "https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py"
click node_risk_optimizer "https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py"
click node_officer_access "https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py"
click node_action_commit "https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py"
click node_database_init "https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py"
click node_sqlite_state "https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mcgm_portal.db"
click node_mumbai_wards "https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mumbai_24_wards_master.csv"
click node_mysore_wards "https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mysore_wards_master.csv"
click node_mumbai_history "https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mumbai_historical_training_db.csv"
click node_mysore_history "https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mysore_historical_training_db.csv"
click node_mysore_geo "https://github.com/r-samarth/heat-cdd/blob/main/frontend/mysore-wards.geojson"

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_dashboard toneBlue
class node_simulation_api,node_risk_optimizer,node_officer_access,node_action_commit,node_database_init toneAmber
class node_sqlite_state,node_mumbai_wards,node_mysore_wards,node_mumbai_history,node_mysore_history toneMint
class node_mysore_geo,node_basemap toneRose
class node_planner toneIndigo
```

## Components

### Planning Interface

- [Dashboard and map](https://github.com/r-samarth/heat-cdd/blob/main/frontend/script.js): `frontend/script.js`

### Planning Backend

- [Simulation API](https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py): `backend/main.py`
- [Risk optimization](https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py): `backend/main.py`
- [Officer and budget access](https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py): `backend/main.py`
- [Intervention commits](https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py): `backend/main.py`
- [Database initialization](https://github.com/r-samarth/heat-cdd/blob/main/backend/main.py): `backend/main.py`

### Ward Data and State

- [Portal state](https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mcgm_portal.db): `backend/data/mcgm_portal.db`
- [Mumbai ward master](https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mumbai_24_wards_master.csv): `backend/data/mumbai_24_wards_master.csv`
- [Mysore ward master](https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mysore_wards_master.csv): `backend/data/mysore_wards_master.csv`
- [Mumbai heat history](https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mumbai_historical_training_db.csv): `backend/data/mumbai_historical_training_db.csv`
- [Mysore heat history](https://github.com/r-samarth/heat-cdd/blob/main/backend/data/mysore_historical_training_db.csv): `backend/data/mysore_historical_training_db.csv`

### Map Services

- [Mysore ward geometry](https://github.com/r-samarth/heat-cdd/blob/main/frontend/mysore-wards.geojson): `frontend/mysore-wards.geojson`
- **Carto basemap tiles**

### Other components

- **Municipal planner**

## Connections

- Municipal planner → Dashboard and map: uses
- Dashboard and map → Simulation API: requests optimization (evidence: `frontend/script.js`)
- Simulation API → Risk optimization: dispatches (evidence: `backend/main.py`)
- Risk optimization → Portal state: reads interventions (evidence: `backend/main.py`)
- Database initialization → Portal state: initializes (evidence: `backend/main.py`)
- Database initialization → Mumbai ward master: reads ward data (evidence: `backend/main.py`)
- Dashboard and map → Mysore ward geometry: loads geometry (evidence: `frontend/script.js`)
- Dashboard and map → Carto basemap tiles: loads tiles (evidence: `frontend/script.js`)
