# abhijnanbc/heatguard-ai architecture

> Architecture diagram of the GitHub repository abhijnanbc/heatguard-ai, 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/abhijnanbc/heatguard-ai
- Repository: https://github.com/abhijnanbc/heatguard-ai

## Overview

HeatGuard is an early-warning system that synthesizes physiologically grounded worker data, profiles worker vulnerability, trains an explainable risk model, and serves personalised predictions through an API and worker-app prototype. The graph preserves the documented phase handoffs and the sampled API-to-inference call. Some runner-to-analysis links are documented at a high level; where excerpts do not show the runtime call, those relationships are omitted rather than inferred.

Main entry points: [`src/phase3_modeling/run_phase3.py`](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase3_modeling/run_phase3.py) (Training pipeline), [`src/phase2_clustering/run_phase2.py`](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase2_clustering/run_phase2.py) (Profiling pipeline), [`src/phase1_generation/run_phase1.py`](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase1_generation/run_phase1.py) (Data generation), [`app/api/app.py`](https://github.com/abhijnanbc/heatguard-ai/blob/main/app/api/app.py) (Prediction API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_generation["Synthetic data"]
  node_phase1_runner["Data generation<br/>[run_phase1.py]"]
  node_phs_engine["PHS synthesis"]
  node_phase1_viz["Data diagnostics"]
  node_synthetic_data["Synthetic workers"]
end

subgraph group_profiling["Worker profiling"]
  node_phase2_runner["Profiling pipeline<br/>[run_phase2.py]"]
  node_clustering["K-means profiles"]
  node_phase2_viz["Profile diagnostics"]
  node_clustered_data["Profiled workers"]
end

subgraph group_modeling["Risk modeling"]
  node_phase3_runner["Training pipeline<br/>[run_phase3.py]"]
  node_trainer["XGBoost training<br/>[train_xgboost.py]"]
  node_shap["SHAP explanations"]
  node_model_viz["Model evaluation"]
  node_model_artifacts["Model artifacts"]
end

subgraph group_serving["Inference service"]
  node_api["Prediction API<br/>[app.py]"]
  node_inference["Feature and risk inference"]
  node_deployed_api["Deployment API<br/>[app.py]"]
  node_deployed_inference["Packaged inference"]
  node_deploy_kit["Export and deployment kit"]
end

subgraph group_experience["Worker experience"]
  node_worker_app["Worker app prototype<br/>[worker_app.html]"]
end

node_worker(("Outdoor worker"))

node_phase1_runner -->|"uses generation"| node_phs_engine
node_phase1_runner -->|"generates plots"| node_phase1_viz
node_phase1_runner -->|"writes dataset"| node_synthetic_data
node_synthetic_data -->|"feeds profiling"| node_phase2_runner
node_phase2_runner -->|"runs clustering"| node_clustering
node_phase2_runner -->|"generates plots"| node_phase2_viz
node_phase2_runner -->|"writes profiles"| node_clustered_data
node_clustered_data -->|"feeds training"| node_phase3_runner
node_phase3_runner -->|"runs training"| node_trainer
node_phase3_runner -->|"uses explanations"| node_shap
node_phase3_runner -->|"generates evaluation"| node_model_viz
node_phase3_runner -->|"exports models"| node_model_artifacts
node_model_artifacts -->|"loads artifacts"| node_inference
node_worker -.->|"uses app"| node_worker_app
node_worker_app -.->|"requests predictions"| node_api
node_api -->|"calls predict"| node_inference
node_api -.->|"returns risk alert"| node_worker
node_deployed_api -->|"calls inference"| node_deployed_inference
node_deploy_kit -.->|"packages deployment"| node_deployed_api

click node_phase1_runner "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase1_generation/run_phase1.py"
click node_phs_engine "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase1_generation/generate_synthetic.py"
click node_phase1_viz "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase1_generation/visualise_phase1.py"
click node_synthetic_data "https://github.com/abhijnanbc/heatguard-ai/blob/main/data/workers_synthetic_5000.csv"
click node_phase2_runner "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase2_clustering/run_phase2.py"
click node_clustering "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase2_clustering/kmeans_profiling.py"
click node_phase2_viz "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase2_clustering/visualise_phase2.py"
click node_clustered_data "https://github.com/abhijnanbc/heatguard-ai/blob/main/data/workers_with_clusters.csv"
click node_phase3_runner "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase3_modeling/run_phase3.py"
click node_trainer "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase3_modeling/train_xgboost.py"
click node_shap "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase3_modeling/shap_interpreter.py"
click node_model_viz "https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase3_modeling/visualise_phase3.py"
click node_model_artifacts "https://github.com/abhijnanbc/heatguard-ai/tree/main/models"
click node_api "https://github.com/abhijnanbc/heatguard-ai/blob/main/app/api/app.py"
click node_inference "https://github.com/abhijnanbc/heatguard-ai/blob/main/app/api/inference_engine.py"
click node_deployed_api "https://github.com/abhijnanbc/heatguard-ai/blob/main/phase5/deploy/app.py"
click node_deployed_inference "https://github.com/abhijnanbc/heatguard-ai/blob/main/phase5/deploy/inference_engine.py"
click node_worker_app "https://github.com/abhijnanbc/heatguard-ai/blob/main/phase5/worker_app.html"
click node_deploy_kit "https://github.com/abhijnanbc/heatguard-ai/blob/main/phase5/export_and_deploy.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_phase1_runner,node_phs_engine,node_phase1_viz,node_synthetic_data toneBlue
class node_phase2_runner,node_clustering,node_phase2_viz,node_clustered_data toneAmber
class node_phase3_runner,node_trainer,node_shap,node_model_viz,node_model_artifacts toneMint
class node_api,node_inference,node_deployed_api,node_deployed_inference,node_deploy_kit,node_worker toneRose
class node_worker_app toneIndigo
```

## Components

### Synthetic data

- [Data generation](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase1_generation/run_phase1.py): `src/phase1_generation/run_phase1.py`
- [PHS synthesis](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase1_generation/generate_synthetic.py): `src/phase1_generation/generate_synthetic.py`
- [Data diagnostics](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase1_generation/visualise_phase1.py): `src/phase1_generation/visualise_phase1.py`
- [Synthetic workers](https://github.com/abhijnanbc/heatguard-ai/blob/main/data/workers_synthetic_5000.csv): `data/workers_synthetic_5000.csv`

### Worker profiling

- [Profiling pipeline](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase2_clustering/run_phase2.py): `src/phase2_clustering/run_phase2.py`
- [K-means profiles](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase2_clustering/kmeans_profiling.py): `src/phase2_clustering/kmeans_profiling.py`
- [Profile diagnostics](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase2_clustering/visualise_phase2.py): `src/phase2_clustering/visualise_phase2.py`
- [Profiled workers](https://github.com/abhijnanbc/heatguard-ai/blob/main/data/workers_with_clusters.csv): `data/workers_with_clusters.csv`

### Risk modeling

- [Training pipeline](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase3_modeling/run_phase3.py): `src/phase3_modeling/run_phase3.py`
- [XGBoost training](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase3_modeling/train_xgboost.py): `src/phase3_modeling/train_xgboost.py`
- [SHAP explanations](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase3_modeling/shap_interpreter.py): `src/phase3_modeling/shap_interpreter.py`
- [Model evaluation](https://github.com/abhijnanbc/heatguard-ai/blob/main/src/phase3_modeling/visualise_phase3.py): `src/phase3_modeling/visualise_phase3.py`
- [Model artifacts](https://github.com/abhijnanbc/heatguard-ai/tree/main/models): `models`

### Inference service

- [Prediction API](https://github.com/abhijnanbc/heatguard-ai/blob/main/app/api/app.py): `app/api/app.py`
- [Feature and risk inference](https://github.com/abhijnanbc/heatguard-ai/blob/main/app/api/inference_engine.py): `app/api/inference_engine.py`
- [Deployment API](https://github.com/abhijnanbc/heatguard-ai/blob/main/phase5/deploy/app.py): `phase5/deploy/app.py`
- [Packaged inference](https://github.com/abhijnanbc/heatguard-ai/blob/main/phase5/deploy/inference_engine.py): `phase5/deploy/inference_engine.py`
- [Export and deployment kit](https://github.com/abhijnanbc/heatguard-ai/blob/main/phase5/export_and_deploy.py): `phase5/export_and_deploy.py`

### Worker experience

- [Worker app prototype](https://github.com/abhijnanbc/heatguard-ai/blob/main/phase5/worker_app.html): `phase5/worker_app.html`

### Other components

- **Outdoor worker**

## Connections

- Data generation → PHS synthesis: uses generation (evidence: `src/phase1_generation/run_phase1.py`)
- Data generation → Data diagnostics: generates plots (evidence: `src/phase1_generation/run_phase1.py`)
- Data generation → Synthetic workers: writes dataset (evidence: `src/phase1_generation/run_phase1.py`)
- Synthetic workers → Profiling pipeline: feeds profiling (evidence: `src/phase2_clustering/run_phase2.py`)
- Profiling pipeline → K-means profiles: runs clustering (evidence: `src/phase2_clustering/run_phase2.py`)
- Profiling pipeline → Profile diagnostics: generates plots (evidence: `src/phase2_clustering/run_phase2.py`)
- Profiling pipeline → Profiled workers: writes profiles (evidence: `src/phase2_clustering/run_phase2.py`)
- Profiled workers → Training pipeline: feeds training (evidence: `src/phase3_modeling/run_phase3.py`)
- Training pipeline → XGBoost training: runs training (evidence: `src/phase3_modeling/run_phase3.py`)
- Training pipeline → SHAP explanations: uses explanations (evidence: `README.md`)
- Training pipeline → Model evaluation: generates evaluation (evidence: `README.md`)
- Training pipeline → Model artifacts: exports models (evidence: `README.md`)
- Model artifacts → Feature and risk inference: loads artifacts (evidence: `app/api/inference_engine.py`)
- Outdoor worker → Worker app prototype: uses app
- Worker app prototype → Prediction API: requests predictions
- Prediction API → Feature and risk inference: calls predict (evidence: `app/api/app.py`)
- Prediction API → Outdoor worker: returns risk alert
- Deployment API → Packaged inference: calls inference (evidence: `phase5/deploy/app.py`)
- Export and deployment kit → Deployment API: packages deployment
