# jeevesh2605/smoke-dispersion architecture

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

- Interactive diagram: https://gitdiagram.com/jeevesh2605/smoke-dispersion
- Repository: https://github.com/jeevesh2605/smoke-dispersion

## Overview

SmokeGuard estimates location-level PM2.5 risk for Delhi-NCR, combining station history, wind and fire-dispersion features. The main workflow is station selection in the dashboard, API orchestration of current inputs and remote inference, then a risk forecast and rule-based advice. Offline collection, feature engineering and model training are documented product stages; their relationships are shown only where README or sampled source supports them. The map visualizes recent observations separately from forecast results. Unsampled implementation links are omitted.

Main entry points: [`agent/tools/forecast.py`](https://github.com/jeevesh2605/smoke-dispersion/blob/main/agent/tools/forecast.py) (Forecast assembly), [`app.py`](https://github.com/jeevesh2605/smoke-dispersion/blob/main/app.py) (FastAPI routes), [`frontend/src/App.jsx`](https://github.com/jeevesh2605/smoke-dispersion/blob/main/frontend/src/App.jsx) (App navigation), [`frontend/src/Dashboard.jsx`](https://github.com/jeevesh2605/smoke-dispersion/blob/main/frontend/src/Dashboard.jsx) (Station dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_offline["Offline data and training"]
  node_data_sources["Fire, AQI, wind data"]
  node_collection["Data collection"]
  node_feature_engineering["Feature engineering"]
  node_training_data["Unified dataset"]
  node_model_training["Random Forest training"]
  node_model_bundle["Local model bundle"]
end

subgraph group_service["Forecast service"]
  node_api["FastAPI routes<br/>[app.py]"]
  node_advice["Risk advice<br/>[app.py]"]
end

subgraph group_agent_tools["Forecast inputs and inference"]
  node_location["Location metadata<br/>[location.py]"]
  node_recent_aqi["Recent PM2.5 history<br/>[aqi_recent.csv]"]
  node_current_wind["Current wind lookup<br/>[forecast.py]"]
  node_fire_features["Stored fire features"]
  node_forecast["Forecast assembly<br/>[forecast.py]"]
  node_predictor["Remote prediction client<br/>[predict_pm25.py]"]
end

subgraph group_web["Web experience"]
  node_app_ui["App navigation<br/>[App.jsx]"]
  node_dashboard["Station dashboard<br/>[Dashboard.jsx]"]
  node_map["3D NCR map<br/>[NCRMap.jsx]"]
  node_map_data["Map geography and AQI"]
end

node_sagemaker["SageMaker inference"]
node_visitor(("Dashboard user"))

node_data_sources -.->|"collects"| node_collection
node_data_sources -.->|"engineers"| node_feature_engineering
node_feature_engineering -.->|"builds"| node_training_data
node_training_data -.->|"trains"| node_model_training
node_model_training -.->|"produces"| node_model_bundle
node_visitor -.->|"opens"| node_app_ui
node_app_ui -->|"renders"| node_map
node_app_ui -->|"opens"| node_dashboard
node_dashboard -->|"requests advice"| node_api
node_dashboard -->|"loads stations"| node_recent_aqi
node_map -->|"loads"| node_map_data
node_api -->|"loads model"| node_model_bundle
node_api -->|"calls forecast"| node_forecast
node_api -->|"builds advice"| node_advice
node_forecast -->|"looks up"| node_location
node_forecast -->|"fetches wind"| node_current_wind
node_forecast -->|"reads history"| node_recent_aqi
node_forecast -->|"reads features"| node_fire_features
node_forecast -->|"submits inputs"| node_predictor
node_predictor -->|"invokes endpoint"| node_sagemaker
node_advice -->|"uses result"| node_forecast

click node_data_sources "https://github.com/jeevesh2605/smoke-dispersion/tree/main/data/raw"
click node_collection "https://github.com/jeevesh2605/smoke-dispersion/blob/main/scripts/fetch_aqi_by_stations.py"
click node_feature_engineering "https://github.com/jeevesh2605/smoke-dispersion/blob/main/scripts/build_historical_dispersion_features.py"
click node_training_data "https://github.com/jeevesh2605/smoke-dispersion/blob/main/scripts/build_unified_dataset.py"
click node_model_training "https://github.com/jeevesh2605/smoke-dispersion/blob/main/scripts/train_unified_model.py"
click node_model_bundle "https://github.com/jeevesh2605/smoke-dispersion/tree/main/data/processed"
click node_api "https://github.com/jeevesh2605/smoke-dispersion/blob/main/app.py"
click node_location "https://github.com/jeevesh2605/smoke-dispersion/blob/main/agent/tools/location.py"
click node_recent_aqi "https://github.com/jeevesh2605/smoke-dispersion/blob/main/data/raw/aqi_recent.csv"
click node_current_wind "https://github.com/jeevesh2605/smoke-dispersion/blob/main/agent/tools/forecast.py"
click node_fire_features "https://github.com/jeevesh2605/smoke-dispersion/blob/main/data/processed/today_fire_features.csv"
click node_forecast "https://github.com/jeevesh2605/smoke-dispersion/blob/main/agent/tools/forecast.py"
click node_predictor "https://github.com/jeevesh2605/smoke-dispersion/blob/main/agent/tools/predict_pm25.py"
click node_advice "https://github.com/jeevesh2605/smoke-dispersion/blob/main/app.py"
click node_app_ui "https://github.com/jeevesh2605/smoke-dispersion/blob/main/frontend/src/App.jsx"
click node_dashboard "https://github.com/jeevesh2605/smoke-dispersion/blob/main/frontend/src/Dashboard.jsx"
click node_map "https://github.com/jeevesh2605/smoke-dispersion/blob/main/frontend/src/components/NCRMap.jsx"
click node_map_data "https://github.com/jeevesh2605/smoke-dispersion/tree/main/frontend/public/data"

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_data_sources,node_collection,node_feature_engineering,node_training_data,node_model_training,node_model_bundle,node_visitor toneBlue
class node_api,node_advice toneAmber
class node_location,node_recent_aqi,node_current_wind,node_fire_features,node_forecast,node_predictor toneMint
class node_app_ui,node_dashboard,node_map,node_map_data toneRose
class node_sagemaker toneIndigo
```

## Components

### Offline data and training

- [Fire, AQI, wind data](https://github.com/jeevesh2605/smoke-dispersion/tree/main/data/raw): `data/raw`
- [Data collection](https://github.com/jeevesh2605/smoke-dispersion/blob/main/scripts/fetch_aqi_by_stations.py): `scripts/fetch_aqi_by_stations.py`
- [Feature engineering](https://github.com/jeevesh2605/smoke-dispersion/blob/main/scripts/build_historical_dispersion_features.py): `scripts/build_historical_dispersion_features.py`
- [Unified dataset](https://github.com/jeevesh2605/smoke-dispersion/blob/main/scripts/build_unified_dataset.py): `scripts/build_unified_dataset.py`
- [Random Forest training](https://github.com/jeevesh2605/smoke-dispersion/blob/main/scripts/train_unified_model.py): `scripts/train_unified_model.py`
- [Local model bundle](https://github.com/jeevesh2605/smoke-dispersion/tree/main/data/processed): `data/processed`

### Forecast service

- [FastAPI routes](https://github.com/jeevesh2605/smoke-dispersion/blob/main/app.py): `app.py`
- [Risk advice](https://github.com/jeevesh2605/smoke-dispersion/blob/main/app.py): `app.py`

### Forecast inputs and inference

- [Location metadata](https://github.com/jeevesh2605/smoke-dispersion/blob/main/agent/tools/location.py): `agent/tools/location.py`
- [Recent PM2.5 history](https://github.com/jeevesh2605/smoke-dispersion/blob/main/data/raw/aqi_recent.csv): `data/raw/aqi_recent.csv`
- [Current wind lookup](https://github.com/jeevesh2605/smoke-dispersion/blob/main/agent/tools/forecast.py): `agent/tools/forecast.py`
- [Stored fire features](https://github.com/jeevesh2605/smoke-dispersion/blob/main/data/processed/today_fire_features.csv): `data/processed/today_fire_features.csv`
- [Forecast assembly](https://github.com/jeevesh2605/smoke-dispersion/blob/main/agent/tools/forecast.py): `agent/tools/forecast.py`
- [Remote prediction client](https://github.com/jeevesh2605/smoke-dispersion/blob/main/agent/tools/predict_pm25.py): `agent/tools/predict_pm25.py`

### Web experience

- [App navigation](https://github.com/jeevesh2605/smoke-dispersion/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Station dashboard](https://github.com/jeevesh2605/smoke-dispersion/blob/main/frontend/src/Dashboard.jsx): `frontend/src/Dashboard.jsx`
- [3D NCR map](https://github.com/jeevesh2605/smoke-dispersion/blob/main/frontend/src/components/NCRMap.jsx): `frontend/src/components/NCRMap.jsx`
- [Map geography and AQI](https://github.com/jeevesh2605/smoke-dispersion/tree/main/frontend/public/data): `frontend/public/data`

### Other components

- **SageMaker inference**
- **Dashboard user**

## Connections

- Fire, AQI, wind data → Data collection: collects (evidence: `README.md`)
- Fire, AQI, wind data → Feature engineering: engineers (evidence: `README.md`)
- Feature engineering → Unified dataset: builds (evidence: `README.md`)
- Unified dataset → Random Forest training: trains (evidence: `README.md`)
- Random Forest training → Local model bundle: produces (evidence: `README.md`)
- Dashboard user → App navigation: opens (evidence: `frontend/src/App.jsx`)
- App navigation → 3D NCR map: renders (evidence: `frontend/src/App.jsx`)
- App navigation → Station dashboard: opens (evidence: `frontend/src/App.jsx`)
- Station dashboard → FastAPI routes: requests advice (evidence: `frontend/src/Dashboard.jsx`)
- Station dashboard → Recent PM2.5 history: loads stations (evidence: `frontend/src/Dashboard.jsx`)
- 3D NCR map → Map geography and AQI: loads (evidence: `frontend/src/components/NCRMap.jsx`)
- FastAPI routes → Local model bundle: loads model (evidence: `app.py`)
- FastAPI routes → Forecast assembly: calls forecast (evidence: `app.py`)
- FastAPI routes → Risk advice: builds advice (evidence: `app.py`)
- Forecast assembly → Location metadata: looks up (evidence: `agent/tools/forecast.py`)
- Forecast assembly → Current wind lookup: fetches wind (evidence: `agent/tools/forecast.py`)
- Forecast assembly → Recent PM2.5 history: reads history (evidence: `agent/tools/forecast.py`)
- Forecast assembly → Stored fire features: reads features (evidence: `agent/tools/forecast.py`)
- Forecast assembly → Remote prediction client: submits inputs (evidence: `agent/tools/forecast.py`)
- Remote prediction client → SageMaker inference: invokes endpoint (evidence: `agent/tools/predict_pm25.py`)
- Risk advice → Forecast assembly: uses result (evidence: `app.py`)
