# jeevanl16/air-planner-for-smog-season architecture

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

- Interactive diagram: https://gitdiagram.com/jeevanl16/air-planner-for-smog-season
- Repository: https://github.com/jeevanl16/air-planner-for-smog-season

## Overview

Saans turns a household profile and location into a bilingual clean-air plan: the browser requests a forecast, the API computes AQI and useful time windows, estimates personal exposure, ranks routine and indoor changes, and returns quantified advice. A separate what-if path reports deterministic exposure and emissions changes. Optional LLM narration explains calculated results, with templates as fallback. The README documents the main capabilities; some internal route calls and frontend wiring are only partially excerpted, so edges rely on README statements or indexed references where applicable.

Main entry points: [`src/saans/api/routes.py`](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/api/routes.py) (Plan API), [`src/saans/llm/narrator.py`](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/narrator.py) (Plan narrator), [`src/saans/domain/catalog.py`](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/catalog.py) (Catalog loaders), [`src/saans/static/app.js`](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/static/app.js) (Browser planner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_browser["Browser planner<br/>[app.js]"]
end

subgraph group_service["API service"]
  node_api["Plan API<br/>[routes.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_security["API security<br/>[security.py]"]
  node_settings["Runtime settings<br/>[settings.py]"]
end

subgraph group_planning["Clean-air planning"]
  node_aqi["AQI calculation<br/>[aqi.py]"]
  node_forecast["Forecast windows<br/>[forecast.py]"]
  node_exposure["Exposure model<br/>[exposure.py]"]
  node_impact["Impact scenarios<br/>[impact.py]"]
  node_recommend["Action ranking<br/>[recommend.py]"]
  node_grap["GRAP advisory<br/>[grap.py]"]
  node_catalog["Catalog loaders<br/>[catalog.py]"]
  node_data["Planning catalogs"]
end

subgraph group_narration["Narration"]
  node_narrator["Plan narrator<br/>[narrator.py]"]
  node_chain["Provider failover<br/>[chain.py]"]
  node_providers["LLM providers<br/>[providers.py]"]
  node_guard["Number guard<br/>[number_guard.py]"]
  node_templates["Bilingual templates<br/>[templates.py]"]
end

subgraph group_integrations["External data"]
  node_openmeteo["Open-Meteo adapter<br/>[open_meteo.py]"]
end

node_family(("Family"))
node_externalmeteo["Open-Meteo"]

node_family -->|"uses"| node_browser
node_browser -->|"requests plans"| node_api
node_api -->|"validates payloads"| node_schemas
node_api -->|"uses adapters"| node_openmeteo
node_openmeteo -->|"fetches forecasts"| node_externalmeteo
node_api -->|"calculates AQI"| node_aqi
node_api -->|"builds windows"| node_forecast
node_api -->|"estimates exposure"| node_exposure
node_api -->|"evaluates changes"| node_impact
node_api -->|"ranks actions"| node_recommend
node_api -->|"gets advisory"| node_grap
node_api -->|"requests narration"| node_narrator
node_aqi -->|"loads breakpoints"| node_catalog
node_forecast -->|"computes indices"| node_aqi
node_exposure -->|"loads assumptions"| node_catalog
node_impact -->|"recomputes exposure"| node_exposure
node_recommend -->|"scores actions"| node_impact
node_grap -->|"loads rules"| node_catalog
node_catalog -->|"reads YAML"| node_data
node_narrator -->|"requests completion"| node_chain
node_narrator -->|"checks numbers"| node_guard
node_narrator -->|"renders fallback"| node_templates
node_chain -->|"dispatches requests"| node_providers
node_narrator -->|"configures providers"| node_providers
node_api -->|"returns plan"| node_browser
node_settings -.->|"configures runtime"| node_api

click node_browser "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/static/app.js"
click node_api "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/api/routes.py"
click node_schemas "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/api/schemas.py"
click node_security "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/api/security.py"
click node_settings "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/settings.py"
click node_openmeteo "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/adapters/open_meteo.py"
click node_aqi "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/aqi.py"
click node_forecast "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/forecast.py"
click node_exposure "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/exposure.py"
click node_impact "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/impact.py"
click node_recommend "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/recommend.py"
click node_grap "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/grap.py"
click node_catalog "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/catalog.py"
click node_data "https://github.com/jeevanl16/air-planner-for-smog-season/tree/main/src/saans/data"
click node_narrator "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/narrator.py"
click node_chain "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/chain.py"
click node_providers "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/providers.py"
click node_guard "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/number_guard.py"
click node_templates "https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/templates.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_browser toneBlue
class node_api,node_schemas,node_security,node_settings toneAmber
class node_aqi,node_forecast,node_exposure,node_impact,node_recommend,node_grap,node_catalog,node_data toneMint
class node_narrator,node_chain,node_providers,node_guard,node_templates toneRose
class node_openmeteo,node_family,node_externalmeteo toneIndigo
```

## Components

### User experience

- [Browser planner](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/static/app.js): `src/saans/static/app.js`

### API service

- [Plan API](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/api/routes.py): `src/saans/api/routes.py`
- [API schemas](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/api/schemas.py): `src/saans/api/schemas.py`
- [API security](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/api/security.py): `src/saans/api/security.py`
- [Runtime settings](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/settings.py): `src/saans/settings.py`

### Clean-air planning

- [AQI calculation](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/aqi.py): `src/saans/domain/aqi.py`
- [Forecast windows](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/forecast.py): `src/saans/domain/forecast.py`
- [Exposure model](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/exposure.py): `src/saans/domain/exposure.py`
- [Impact scenarios](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/impact.py): `src/saans/domain/impact.py`
- [Action ranking](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/recommend.py): `src/saans/domain/recommend.py`
- [GRAP advisory](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/grap.py): `src/saans/domain/grap.py`
- [Catalog loaders](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/domain/catalog.py): `src/saans/domain/catalog.py`
- [Planning catalogs](https://github.com/jeevanl16/air-planner-for-smog-season/tree/main/src/saans/data): `src/saans/data`

### Narration

- [Plan narrator](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/narrator.py): `src/saans/llm/narrator.py`
- [Provider failover](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/chain.py): `src/saans/llm/chain.py`
- [LLM providers](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/providers.py): `src/saans/llm/providers.py`
- [Number guard](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/number_guard.py): `src/saans/llm/number_guard.py`
- [Bilingual templates](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/llm/templates.py): `src/saans/llm/templates.py`

### External data

- [Open-Meteo adapter](https://github.com/jeevanl16/air-planner-for-smog-season/blob/main/src/saans/adapters/open_meteo.py): `src/saans/adapters/open_meteo.py`

### Other components

- **Family**
- **Open-Meteo**

## Connections

- Family → Browser planner: uses (evidence: `README.md`)
- Browser planner → Plan API: requests plans (evidence: `README.md`)
- Plan API → API schemas: validates payloads (evidence: `src/saans/api/routes.py`)
- Plan API → Open-Meteo adapter: uses adapters (evidence: `README.md`)
- Open-Meteo adapter → Open-Meteo: fetches forecasts (evidence: `src/saans/adapters/open_meteo.py`)
- Plan API → AQI calculation: calculates AQI (evidence: `src/saans/api/routes.py`)
- Plan API → Forecast windows: builds windows (evidence: `src/saans/api/routes.py`)
- Plan API → Exposure model: estimates exposure (evidence: `src/saans/api/routes.py`)
- Plan API → Impact scenarios: evaluates changes (evidence: `src/saans/api/routes.py`)
- Plan API → Action ranking: ranks actions (evidence: `src/saans/api/routes.py`)
- Plan API → GRAP advisory: gets advisory (evidence: `src/saans/api/routes.py`)
- Plan API → Plan narrator: requests narration (evidence: `src/saans/api/routes.py`)
- AQI calculation → Catalog loaders: loads breakpoints (evidence: `src/saans/domain/aqi.py`)
- Forecast windows → AQI calculation: computes indices (evidence: `src/saans/domain/forecast.py`)
- Exposure model → Catalog loaders: loads assumptions (evidence: `src/saans/domain/exposure.py`)
- Impact scenarios → Exposure model: recomputes exposure (evidence: `src/saans/domain/impact.py`)
- Action ranking → Impact scenarios: scores actions (evidence: `src/saans/domain/recommend.py`)
- GRAP advisory → Catalog loaders: loads rules (evidence: `src/saans/domain/grap.py`)
- Catalog loaders → Planning catalogs: reads YAML (evidence: `src/saans/domain/catalog.py`)
- Plan narrator → Provider failover: requests completion (evidence: `src/saans/llm/narrator.py`)
- Plan narrator → Number guard: checks numbers (evidence: `src/saans/llm/narrator.py`)
- Plan narrator → Bilingual templates: renders fallback (evidence: `src/saans/llm/narrator.py`)
- Provider failover → LLM providers: dispatches requests (evidence: `src/saans/llm/chain.py`)
- Plan narrator → LLM providers: configures providers (evidence: `src/saans/llm/narrator.py`)
- Plan API → Browser planner: returns plan (evidence: `README.md`)
- Runtime settings → Plan API: configures runtime (evidence: `src/saans/api/routes.py`)
