# hiteshrawat289/heatguard architecture

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

- Interactive diagram: https://gitdiagram.com/hiteshrawat289/heatguard
- Repository: https://github.com/hiteshrawat289/heatguard

## Overview

HeatGuard is a prototype smartphone-based heat-strain early-warning service. A worker profile and GPS weather feed a personalized WBGT estimate and risk band, which inform a work/rest/hydration plan and a localized message delivered over WhatsApp, SMS, or IVR. A separate WhatsApp self-registration flow collects worker context. The README documents the main computation sequence; sampled source confirms key orchestration and registration behaviors. Some delivery and scheduling details are unsampled, so uncertain links are omitted.

Main entry points: [`HeatGuard/heatstrain/delivery/orchestrator.py`](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/orchestrator.py) (Daily alert orchestrator), [`HeatGuard/heatstrain/delivery/registration_flow.py`](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/registration_flow.py) (Registration conversation), [`HeatGuard/heatstrain/iso7243.py`](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/iso7243.py) (Risk classification), [`HeatGuard/heatstrain/delivery/whatsapp.py`](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/whatsapp.py) (WhatsApp sender)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_risk["Risk assessment"]
  node_wbgt["WBGT estimate<br/>[wbgt.py]"]
  node_risk_band["Risk classification<br/>[iso7243.py]"]
  node_insurance["Payout likelihood<br/>[insurance.py]"]
  node_weather["Weather fetch<br/>[weather.py]"]
end

subgraph group_advice["Worker guidance"]
  node_rest_plan["Rest and hydration<br/>[rest_cycle.py]"]
  node_message["Localized message<br/>[messages.py]"]
end

subgraph group_delivery["Alert delivery"]
  node_daily_orchestrator["Daily alert orchestrator<br/>[orchestrator.py]"]
  node_worker_store[("Worker registry<br/>[orchestrator.py]")]
  node_message_cache[("Message cache<br/>[orchestrator.py]")]
  node_channel_base["Channel interface<br/>[base.py]"]
  node_whatsapp["WhatsApp sender<br/>[whatsapp.py]"]
  node_sms["SMS sender<br/>[sms.py]"]
  node_ivr["Voice IVR sender<br/>[ivr.py]"]
end

subgraph group_onboarding["Worker onboarding"]
  node_registration_flow["Registration conversation"]
  node_registration_tracker[("Registration state<br/>[registration.py]")]
end

node_worker(("Worker"))
node_open_meteo{{"Open-Meteo"}}
node_webhook["WhatsApp webhook<br/>[webhook_server.py]"]
node_twilio{{"Twilio"}}

node_worker -->|"provides profile"| node_daily_orchestrator
node_daily_orchestrator -->|"fetches weather"| node_weather
node_weather -->|"requests conditions"| node_open_meteo
node_daily_orchestrator -->|"computes WBGT"| node_wbgt
node_wbgt -->|"supplies WBGT"| node_risk_band
node_daily_orchestrator -->|"classifies risk"| node_risk_band
node_risk_band -->|"sets risk plan"| node_rest_plan
node_risk_band -->|"checks threshold"| node_insurance
node_daily_orchestrator -->|"checks likelihood"| node_insurance
node_daily_orchestrator -->|"builds guidance"| node_rest_plan
node_daily_orchestrator -->|"renders alert"| node_message
node_rest_plan -->|"supplies plan"| node_message
node_insurance -->|"adds note"| node_message
node_daily_orchestrator -->|"reads profiles"| node_worker_store
node_daily_orchestrator -->|"caches message"| node_message_cache
node_daily_orchestrator -->|"dispatches alert"| node_whatsapp
node_daily_orchestrator -->|"dispatches alert"| node_sms
node_daily_orchestrator -->|"dispatches alert"| node_ivr
node_whatsapp -->|"implements interface"| node_channel_base
node_sms -->|"implements interface"| node_channel_base
node_ivr -->|"implements interface"| node_channel_base
node_whatsapp -.-> node_twilio
node_worker -.->|"sends replies"| node_webhook
node_webhook -.->|"routes messages"| node_registration_flow
node_registration_flow -->|"tracks progress"| node_registration_tracker
node_registration_flow -->|"sends prompts"| node_whatsapp
node_registration_flow -->|"stores profile"| node_worker_store
node_registration_flow -->|"starts first alert"| node_daily_orchestrator

click node_wbgt "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/wbgt.py"
click node_risk_band "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/iso7243.py"
click node_insurance "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/insurance.py"
click node_rest_plan "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/rest_cycle.py"
click node_message "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/messages.py"
click node_weather "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/weather.py"
click node_daily_orchestrator "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/orchestrator.py"
click node_worker_store "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/orchestrator.py"
click node_message_cache "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/orchestrator.py"
click node_channel_base "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/base.py"
click node_whatsapp "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/whatsapp.py"
click node_sms "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/sms.py"
click node_ivr "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/ivr.py"
click node_registration_flow "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/registration_flow.py"
click node_registration_tracker "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/registration.py"
click node_webhook "https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/examples/webhook_server.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_wbgt,node_risk_band,node_insurance,node_weather toneBlue
class node_rest_plan,node_message toneAmber
class node_daily_orchestrator,node_worker_store,node_message_cache,node_channel_base,node_whatsapp,node_sms,node_ivr,node_webhook toneMint
class node_registration_flow,node_registration_tracker,node_worker toneRose
class node_open_meteo,node_twilio toneIndigo
```

## Components

### Risk assessment

- [WBGT estimate](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/wbgt.py): `HeatGuard/heatstrain/wbgt.py`
- [Risk classification](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/iso7243.py): `HeatGuard/heatstrain/iso7243.py`
- [Payout likelihood](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/insurance.py): `HeatGuard/heatstrain/insurance.py`
- [Weather fetch](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/weather.py): `HeatGuard/heatstrain/weather.py`

### Worker guidance

- [Rest and hydration](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/rest_cycle.py): `HeatGuard/heatstrain/rest_cycle.py`
- [Localized message](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/messages.py): `HeatGuard/heatstrain/messages.py`

### Alert delivery

- [Daily alert orchestrator](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/orchestrator.py): `HeatGuard/heatstrain/delivery/orchestrator.py`
- [Worker registry](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/orchestrator.py): `HeatGuard/heatstrain/delivery/orchestrator.py`
- [Message cache](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/orchestrator.py): `HeatGuard/heatstrain/delivery/orchestrator.py`
- [Channel interface](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/base.py): `HeatGuard/heatstrain/delivery/base.py`
- [WhatsApp sender](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/whatsapp.py): `HeatGuard/heatstrain/delivery/whatsapp.py`
- [SMS sender](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/sms.py): `HeatGuard/heatstrain/delivery/sms.py`
- [Voice IVR sender](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/ivr.py): `HeatGuard/heatstrain/delivery/ivr.py`

### Worker onboarding

- [Registration conversation](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/registration_flow.py): `HeatGuard/heatstrain/delivery/registration_flow.py`
- [Registration state](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/heatstrain/delivery/registration.py): `HeatGuard/heatstrain/delivery/registration.py`

### Other components

- **Worker**
- **Open-Meteo**
- [WhatsApp webhook](https://github.com/hiteshrawat289/heatguard/blob/main/HeatGuard/examples/webhook_server.py): `HeatGuard/examples/webhook_server.py`
- **Twilio**

## Connections

- Worker → Daily alert orchestrator: provides profile (evidence: `README.md`)
- Daily alert orchestrator → Weather fetch: fetches weather (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- Weather fetch → Open-Meteo: requests conditions (evidence: `README.md`)
- Daily alert orchestrator → WBGT estimate: computes WBGT (evidence: `README.md`)
- WBGT estimate → Risk classification: supplies WBGT (evidence: `README.md`)
- Daily alert orchestrator → Risk classification: classifies risk (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- Risk classification → Rest and hydration: sets risk plan (evidence: `README.md`)
- Risk classification → Payout likelihood: checks threshold (evidence: `README.md`)
- Daily alert orchestrator → Payout likelihood: checks likelihood (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- Daily alert orchestrator → Rest and hydration: builds guidance (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- Daily alert orchestrator → Localized message: renders alert (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- Rest and hydration → Localized message: supplies plan (evidence: `README.md`)
- Payout likelihood → Localized message: adds note (evidence: `README.md`)
- Daily alert orchestrator → Worker registry: reads profiles (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- Daily alert orchestrator → Message cache: caches message (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- Daily alert orchestrator → WhatsApp sender: dispatches alert (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- Daily alert orchestrator → SMS sender: dispatches alert (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- Daily alert orchestrator → Voice IVR sender: dispatches alert (evidence: `HeatGuard/heatstrain/delivery/orchestrator.py`)
- WhatsApp sender → Channel interface: implements interface (evidence: `HeatGuard/heatstrain/delivery/whatsapp.py`)
- SMS sender → Channel interface: implements interface (evidence: `HeatGuard/heatstrain/delivery/sms.py`)
- Voice IVR sender → Channel interface: implements interface (evidence: `HeatGuard/heatstrain/delivery/ivr.py`)
- WhatsApp sender → Twilio
- Worker → WhatsApp webhook: sends replies
- WhatsApp webhook → Registration conversation: routes messages
- Registration conversation → Registration state: tracks progress (evidence: `HeatGuard/heatstrain/delivery/registration_flow.py`)
- Registration conversation → WhatsApp sender: sends prompts (evidence: `HeatGuard/heatstrain/delivery/registration_flow.py`)
- Registration conversation → Worker registry: stores profile (evidence: `HeatGuard/heatstrain/delivery/registration_flow.py`)
- Registration conversation → Daily alert orchestrator: starts first alert (evidence: `HeatGuard/heatstrain/delivery/registration_flow.py`)
