# govindsin-gh/aqiforecast architecture

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

- Interactive diagram: https://gitdiagram.com/govindsin-gh/aqiforecast
- Repository: https://github.com/govindsin-gh/aqiforecast

## Overview

AQI Forecast serves hourly PM2.5 and US AQI forecasts for eight Indian cities through a web dashboard and API. The workflow prepares observation features, runs a promoted quantile LSTM model, and presents forecast bands and histories; an explanation endpoint can narrate forecast facts. Separate operational stages retrain and gate candidate models, score and monitor production, and compare outputs with OpenAQ stations. The excerpts show API prediction and model-gating behavior; connections for unsampled jobs are included only where the source index names dependencies.

Main entry points: [`api/main.py`](https://github.com/govindsin-gh/aqiforecast/blob/main/api/main.py) (Forecast API), [`src/serving/store.py`](https://github.com/govindsin-gh/aqiforecast/blob/main/src/serving/store.py) (Observation store), [`src/models/gate.py`](https://github.com/govindsin-gh/aqiforecast/blob/main/src/models/gate.py) (Promotion gate), [`src/features/transform.py`](https://github.com/govindsin-gh/aqiforecast/blob/main/src/features/transform.py) (Feature windows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_weather["Weather ingestion<br/>[open_meteo.py]"]
  node_observations[("Observation store<br/>[store.py]")]
  node_features["Feature windows<br/>[transform.py]"]
  node_aqi["AQI conversion<br/>[aqi.py]"]
end

subgraph group_models["Forecast modeling"]
  node_training["Model training<br/>[train.py]"]
  node_lstm["Quantile LSTM<br/>[lstm.py]"]
  node_metrics["Model metrics<br/>[metrics.py]"]
  node_gate["Promotion gate<br/>[gate.py]"]
  node_artifact[("Model artifacts<br/>[store.py]")]
  node_predictor["ONNX predictor<br/>[predictor.py]"]
end

subgraph group_ops["Monitoring and validation"]
  node_scoring["Hourly scoring<br/>[score.py]"]
  node_drift["Drift checks<br/>[drift.py]"]
  node_monitorpredict["Monitor predictions<br/>[predict.py]"]
  node_validation["Station validation<br/>[openaq.py]"]
end

subgraph group_service["API service"]
  node_api["Forecast API<br/>[main.py]"]
  node_explain["Forecast narration<br/>[explain.py]"]
end

subgraph group_web["Web dashboard"]
  node_client["Web API client<br/>[api.js]"]
  node_routes["Dashboard routes<br/>[App.jsx]"]
  node_map["City map<br/>[MapPage.jsx]"]
  node_city["City forecast<br/>[CityPage.jsx]"]
  node_health["Model health view<br/>[HealthPage.jsx]"]
end

node_browser(("Dashboard user"))
node_openaq(("OpenAQ stations"))
node_groq{{"Groq language model"}}

node_weather -.->|"writes observations"| node_observations
node_observations -->|"feeds windows"| node_features
node_training -->|"uses transforms"| node_features
node_training -->|"trains model"| node_lstm
node_training -->|"evaluates"| node_metrics
node_gate -->|"loads candidate"| node_lstm
node_gate -->|"compares metrics"| node_metrics
node_gate -->|"tests production"| node_predictor
node_gate -->|"stores promotion"| node_artifact
node_gate -->|"reads production"| node_observations
node_predictor -->|"normalizes input"| node_features
node_monitorpredict -->|"builds windows"| node_features
node_monitorpredict -->|"runs inference"| node_predictor
node_monitorpredict -->|"reads data"| node_observations
node_scoring -.->|"reads scores"| node_observations
node_drift -.->|"checks data"| node_observations
node_validation -.->|"checks stations"| node_openaq
node_api -->|"reads history"| node_observations
node_api -->|"loads production"| node_artifact
node_api -->|"runs forecasts"| node_predictor
node_api -->|"builds windows"| node_features
node_api -->|"converts AQI"| node_aqi
node_api -->|"requests narration"| node_explain
node_explain -.->|"narrates facts"| node_groq
node_browser -.->|"uses dashboard"| node_routes
node_routes -->|"routes to"| node_map
node_routes -->|"routes to"| node_city
node_routes -->|"routes to"| node_health
node_map -->|"fetches data"| node_client
node_city -->|"fetches data"| node_client
node_health -->|"fetches data"| node_client
node_client -.->|"calls endpoints"| node_api
node_api -.->|"serves comparisons"| node_validation

click node_weather "https://github.com/govindsin-gh/aqiforecast/blob/main/src/ingest/open_meteo.py"
click node_observations "https://github.com/govindsin-gh/aqiforecast/blob/main/src/serving/store.py"
click node_features "https://github.com/govindsin-gh/aqiforecast/blob/main/src/features/transform.py"
click node_aqi "https://github.com/govindsin-gh/aqiforecast/blob/main/src/features/aqi.py"
click node_training "https://github.com/govindsin-gh/aqiforecast/blob/main/src/models/train.py"
click node_lstm "https://github.com/govindsin-gh/aqiforecast/blob/main/src/models/lstm.py"
click node_metrics "https://github.com/govindsin-gh/aqiforecast/blob/main/src/models/metrics.py"
click node_gate "https://github.com/govindsin-gh/aqiforecast/blob/main/src/models/gate.py"
click node_artifact "https://github.com/govindsin-gh/aqiforecast/blob/main/src/serving/store.py"
click node_predictor "https://github.com/govindsin-gh/aqiforecast/blob/main/src/serving/predictor.py"
click node_scoring "https://github.com/govindsin-gh/aqiforecast/blob/main/src/monitoring/score.py"
click node_drift "https://github.com/govindsin-gh/aqiforecast/blob/main/src/monitoring/drift.py"
click node_monitorpredict "https://github.com/govindsin-gh/aqiforecast/blob/main/src/monitoring/predict.py"
click node_validation "https://github.com/govindsin-gh/aqiforecast/blob/main/src/validation/openaq.py"
click node_api "https://github.com/govindsin-gh/aqiforecast/blob/main/api/main.py"
click node_explain "https://github.com/govindsin-gh/aqiforecast/blob/main/api/explain.py"
click node_client "https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/api.js"
click node_routes "https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/App.jsx"
click node_map "https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/pages/MapPage.jsx"
click node_city "https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/pages/CityPage.jsx"
click node_health "https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/pages/HealthPage.jsx"

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_weather,node_observations,node_features,node_aqi,node_browser toneBlue
class node_training,node_lstm,node_metrics,node_gate,node_artifact,node_predictor toneAmber
class node_scoring,node_drift,node_monitorpredict,node_validation toneMint
class node_api,node_explain toneRose
class node_client,node_routes,node_map,node_city,node_health,node_openaq,node_groq toneIndigo
```

## Components

### Data preparation

- [Weather ingestion](https://github.com/govindsin-gh/aqiforecast/blob/main/src/ingest/open_meteo.py): `src/ingest/open_meteo.py`
- [Observation store](https://github.com/govindsin-gh/aqiforecast/blob/main/src/serving/store.py): `src/serving/store.py`
- [Feature windows](https://github.com/govindsin-gh/aqiforecast/blob/main/src/features/transform.py): `src/features/transform.py`
- [AQI conversion](https://github.com/govindsin-gh/aqiforecast/blob/main/src/features/aqi.py): `src/features/aqi.py`

### Forecast modeling

- [Model training](https://github.com/govindsin-gh/aqiforecast/blob/main/src/models/train.py): `src/models/train.py`
- [Quantile LSTM](https://github.com/govindsin-gh/aqiforecast/blob/main/src/models/lstm.py): `src/models/lstm.py`
- [Model metrics](https://github.com/govindsin-gh/aqiforecast/blob/main/src/models/metrics.py): `src/models/metrics.py`
- [Promotion gate](https://github.com/govindsin-gh/aqiforecast/blob/main/src/models/gate.py): `src/models/gate.py`
- [Model artifacts](https://github.com/govindsin-gh/aqiforecast/blob/main/src/serving/store.py): `src/serving/store.py`
- [ONNX predictor](https://github.com/govindsin-gh/aqiforecast/blob/main/src/serving/predictor.py): `src/serving/predictor.py`

### Monitoring and validation

- [Hourly scoring](https://github.com/govindsin-gh/aqiforecast/blob/main/src/monitoring/score.py): `src/monitoring/score.py`
- [Drift checks](https://github.com/govindsin-gh/aqiforecast/blob/main/src/monitoring/drift.py): `src/monitoring/drift.py`
- [Monitor predictions](https://github.com/govindsin-gh/aqiforecast/blob/main/src/monitoring/predict.py): `src/monitoring/predict.py`
- [Station validation](https://github.com/govindsin-gh/aqiforecast/blob/main/src/validation/openaq.py): `src/validation/openaq.py`

### API service

- [Forecast API](https://github.com/govindsin-gh/aqiforecast/blob/main/api/main.py): `api/main.py`
- [Forecast narration](https://github.com/govindsin-gh/aqiforecast/blob/main/api/explain.py): `api/explain.py`

### Web dashboard

- [Web API client](https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/api.js): `web/src/api.js`
- [Dashboard routes](https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/App.jsx): `web/src/App.jsx`
- [City map](https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/pages/MapPage.jsx): `web/src/pages/MapPage.jsx`
- [City forecast](https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/pages/CityPage.jsx): `web/src/pages/CityPage.jsx`
- [Model health view](https://github.com/govindsin-gh/aqiforecast/blob/main/web/src/pages/HealthPage.jsx): `web/src/pages/HealthPage.jsx`

### Other components

- **Dashboard user**
- **OpenAQ stations**
- **Groq language model**

## Connections

- Weather ingestion → Observation store: writes observations
- Observation store → Feature windows: feeds windows (evidence: `src/serving/store.py`)
- Model training → Feature windows: uses transforms (evidence: `src/models/train.py`)
- Model training → Quantile LSTM: trains model (evidence: `src/models/train.py`)
- Model training → Model metrics: evaluates (evidence: `src/models/train.py`)
- Promotion gate → Quantile LSTM: loads candidate (evidence: `src/models/gate.py`)
- Promotion gate → Model metrics: compares metrics (evidence: `src/models/gate.py`)
- Promotion gate → ONNX predictor: tests production (evidence: `src/models/gate.py`)
- Promotion gate → Model artifacts: stores promotion (evidence: `src/models/gate.py`)
- Promotion gate → Observation store: reads production (evidence: `src/models/gate.py`)
- ONNX predictor → Feature windows: normalizes input (evidence: `src/serving/predictor.py`)
- Monitor predictions → Feature windows: builds windows (evidence: `src/monitoring/predict.py`)
- Monitor predictions → ONNX predictor: runs inference (evidence: `src/monitoring/predict.py`)
- Monitor predictions → Observation store: reads data (evidence: `src/monitoring/predict.py`)
- Hourly scoring → Observation store: reads scores
- Drift checks → Observation store: checks data
- Station validation → OpenAQ stations: checks stations
- Forecast API → Observation store: reads history (evidence: `api/main.py`)
- Forecast API → Model artifacts: loads production (evidence: `api/main.py`)
- Forecast API → ONNX predictor: runs forecasts (evidence: `api/main.py`)
- Forecast API → Feature windows: builds windows (evidence: `api/main.py`)
- Forecast API → AQI conversion: converts AQI (evidence: `api/main.py`)
- Forecast API → Forecast narration: requests narration (evidence: `api/main.py`)
- Forecast narration → Groq language model: narrates facts (evidence: `api/explain.py`)
- Dashboard user → Dashboard routes: uses dashboard
- Dashboard routes → City map: routes to (evidence: `web/src/App.jsx`)
- Dashboard routes → City forecast: routes to (evidence: `web/src/App.jsx`)
- Dashboard routes → Model health view: routes to (evidence: `web/src/App.jsx`)
- City map → Web API client: fetches data (evidence: `web/src/pages/MapPage.jsx`)
- City forecast → Web API client: fetches data (evidence: `web/src/pages/CityPage.jsx`)
- Model health view → Web API client: fetches data (evidence: `web/src/pages/HealthPage.jsx`)
- Web API client → Forecast API: calls endpoints
- Forecast API → Station validation: serves comparisons
