# tiwaribh/h2s-prompt architecture

> Architecture diagram of the GitHub repository tiwaribh/h2s-prompt, 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/tiwaribh/h2s-prompt
- Repository: https://github.com/tiwaribh/h2s-prompt

## Overview

AirSathi is a civic air-intelligence dashboard: users authenticate, choose a location, view live air-quality telemetry and comparisons, then generate analysis, civic actions, briefings, and saved-report comparisons. The map follows documented capabilities and shown imports/calls; some client-to-API and optional-provider links are documented rather than visible in the sampled runtime excerpts.

Main entry points: [`src/app/page.tsx`](https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/page.tsx) (Dashboard orchestration), [`src/lib/storage.ts`](https://github.com/tiwaribh/h2s-prompt/blob/main/src/lib/storage.ts) (Browser report storage), [`src/components/OverviewTab.tsx`](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/OverviewTab.tsx) (Live overview), [`src/app/api/gemini/route.ts`](https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/gemini/route.ts) (Intelligence endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and dashboard"]
  node_dashboard["Dashboard orchestration<br/>[page.tsx]"]
  node_navigation["Dashboard navigation<br/>[Sidebar.tsx]"]
  node_header["User and location header<br/>[Header.tsx]"]
  node_login["Google sign-in screen<br/>[LoginPage.tsx]"]
  node_auth["Authentication state<br/>[AuthContext.tsx]"]
  node_firebase["Firebase client auth<br/>[firebase.ts]"]
end

subgraph group_data["Telemetry and location"]
  node_location["Location search<br/>[LocationModal.tsx]"]
  node_geocode["Geocoding endpoint<br/>[route.ts]"]
  node_geocoder{{"Open-Meteo geocoding"}}
  node_live["Air-quality endpoint<br/>[route.ts]"]
  node_meteo{{"Open-Meteo air API"}}
  node_cpcb["CPCB provider endpoint<br/>[route.ts]"]
  node_openaq["OpenAQ provider endpoint<br/>[route.ts]"]
end

subgraph group_insight["Analysis and trends"]
  node_overview["Live overview<br/>[OverviewTab.tsx]"]
  node_liveview["Pollutant details"]
  node_trends["Location trends"]
  node_intelligence["Intelligence endpoint<br/>[route.ts]"]
  node_gemini{{"Google Gemini"}}
  node_aqi["AQI classification<br/>[aqi-utils.ts]"]
  node_badge["AQI status badge<br/>[AQIBadge.tsx]"]
  node_intelligenceview["Data intelligence view"]
end

subgraph group_action["Civic actions and records"]
  node_recommendations["Stakeholder actions"]
  node_briefings["Bilingual briefings<br/>[BriefingsTab.tsx]"]
  node_reports["Report comparison"]
  node_storage[("Browser report storage<br/>[storage.ts]")]
end

node_resident(("Dashboard user"))

node_resident -->|"signs in"| node_login
node_login -->|"requests sign-in"| node_auth
node_auth -->|"delegates auth"| node_firebase
node_resident -->|"uses dashboard"| node_dashboard
node_dashboard -->|"renders"| node_navigation
node_dashboard -->|"renders"| node_header
node_header -->|"opens selector"| node_location
node_location -.->|"searches places"| node_geocode
node_geocode -->|"queries"| node_geocoder
node_dashboard -->|"fetches telemetry"| node_live
node_live -->|"fetches model data"| node_meteo
node_dashboard -->|"renders tab"| node_overview
node_dashboard -->|"renders tab"| node_liveview
node_dashboard -->|"renders tab"| node_trends
node_dashboard -->|"renders tab"| node_intelligenceview
node_dashboard -.->|"requests analysis"| node_intelligence
node_intelligence -->|"generates analysis"| node_gemini
node_intelligence -.->|"returns analysis"| node_dashboard
node_dashboard -->|"renders tab"| node_recommendations
node_dashboard -->|"renders tab"| node_briefings
node_dashboard -->|"renders tab"| node_reports
node_dashboard -->|"saves snapshots"| node_storage
node_reports -->|"reads snapshots"| node_storage
node_overview -->|"classifies AQI"| node_aqi
node_overview -->|"loads recommendations"| node_storage
node_recommendations -->|"gets actions"| node_storage
node_liveview -->|"classifies readings"| node_aqi
node_badge -->|"formats AQI"| node_aqi
node_dashboard -.->|"offers secondary data"| node_cpcb
node_dashboard -.->|"offers secondary data"| node_openaq

click node_dashboard "https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/page.tsx"
click node_navigation "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/Sidebar.tsx"
click node_header "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/Header.tsx"
click node_login "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/LoginPage.tsx"
click node_auth "https://github.com/tiwaribh/h2s-prompt/blob/main/src/context/AuthContext.tsx"
click node_firebase "https://github.com/tiwaribh/h2s-prompt/blob/main/src/lib/firebase.ts"
click node_location "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/LocationModal.tsx"
click node_geocode "https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/geocode/route.ts"
click node_live "https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/air-quality/route.ts"
click node_cpcb "https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/cpcb/route.ts"
click node_openaq "https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/openaq/route.ts"
click node_overview "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/OverviewTab.tsx"
click node_liveview "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/LiveAirQualityTab.tsx"
click node_trends "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/HotspotsTrendsTab.tsx"
click node_intelligence "https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/gemini/route.ts"
click node_recommendations "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/RecommendationsTab.tsx"
click node_briefings "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/BriefingsTab.tsx"
click node_reports "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/PreviousReportsTab.tsx"
click node_storage "https://github.com/tiwaribh/h2s-prompt/blob/main/src/lib/storage.ts"
click node_aqi "https://github.com/tiwaribh/h2s-prompt/blob/main/src/lib/aqi-utils.ts"
click node_badge "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/AQIBadge.tsx"
click node_intelligenceview "https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/DataIntelligenceTab.tsx"

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_dashboard,node_navigation,node_header,node_login,node_auth,node_firebase,node_resident toneBlue
class node_location,node_geocode,node_geocoder,node_live,node_meteo,node_cpcb,node_openaq toneAmber
class node_overview,node_liveview,node_trends,node_intelligence,node_gemini,node_aqi,node_badge,node_intelligenceview toneMint
class node_recommendations,node_briefings,node_reports,node_storage toneRose
```

## Components

### Access and dashboard

- [Dashboard orchestration](https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Dashboard navigation](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/Sidebar.tsx): `src/components/Sidebar.tsx`
- [User and location header](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/Header.tsx): `src/components/Header.tsx`
- [Google sign-in screen](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/LoginPage.tsx): `src/components/LoginPage.tsx`
- [Authentication state](https://github.com/tiwaribh/h2s-prompt/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Firebase client auth](https://github.com/tiwaribh/h2s-prompt/blob/main/src/lib/firebase.ts): `src/lib/firebase.ts`

### Telemetry and location

- [Location search](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/LocationModal.tsx): `src/components/LocationModal.tsx`
- [Geocoding endpoint](https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/geocode/route.ts): `src/app/api/geocode/route.ts`
- **Open-Meteo geocoding**
- [Air-quality endpoint](https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/air-quality/route.ts): `src/app/api/air-quality/route.ts`
- **Open-Meteo air API**
- [CPCB provider endpoint](https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/cpcb/route.ts): `src/app/api/cpcb/route.ts`
- [OpenAQ provider endpoint](https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/openaq/route.ts): `src/app/api/openaq/route.ts`

### Analysis and trends

- [Live overview](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/OverviewTab.tsx): `src/components/OverviewTab.tsx`
- [Pollutant details](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/LiveAirQualityTab.tsx): `src/components/LiveAirQualityTab.tsx`
- [Location trends](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/HotspotsTrendsTab.tsx): `src/components/HotspotsTrendsTab.tsx`
- [Intelligence endpoint](https://github.com/tiwaribh/h2s-prompt/blob/main/src/app/api/gemini/route.ts): `src/app/api/gemini/route.ts`
- **Google Gemini**
- [AQI classification](https://github.com/tiwaribh/h2s-prompt/blob/main/src/lib/aqi-utils.ts): `src/lib/aqi-utils.ts`
- [AQI status badge](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/AQIBadge.tsx): `src/components/AQIBadge.tsx`
- [Data intelligence view](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/DataIntelligenceTab.tsx): `src/components/DataIntelligenceTab.tsx`

### Civic actions and records

- [Stakeholder actions](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/RecommendationsTab.tsx): `src/components/RecommendationsTab.tsx`
- [Bilingual briefings](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/BriefingsTab.tsx): `src/components/BriefingsTab.tsx`
- [Report comparison](https://github.com/tiwaribh/h2s-prompt/blob/main/src/components/PreviousReportsTab.tsx): `src/components/PreviousReportsTab.tsx`
- [Browser report storage](https://github.com/tiwaribh/h2s-prompt/blob/main/src/lib/storage.ts): `src/lib/storage.ts`

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Google sign-in screen: signs in (evidence: `README.md`)
- Google sign-in screen → Authentication state: requests sign-in (evidence: `src/components/LoginPage.tsx`)
- Authentication state → Firebase client auth: delegates auth (evidence: `src/context/AuthContext.tsx`)
- Dashboard user → Dashboard orchestration: uses dashboard (evidence: `README.md`)
- Dashboard orchestration → Dashboard navigation: renders (evidence: `src/app/page.tsx`)
- Dashboard orchestration → User and location header: renders (evidence: `src/app/page.tsx`)
- User and location header → Location search: opens selector (evidence: `src/components/Header.tsx`)
- Location search → Geocoding endpoint: searches places (evidence: `README.md`)
- Geocoding endpoint → Open-Meteo geocoding: queries (evidence: `src/app/api/geocode/route.ts`)
- Dashboard orchestration → Air-quality endpoint: fetches telemetry (evidence: `src/app/page.tsx`)
- Air-quality endpoint → Open-Meteo air API: fetches model data (evidence: `src/app/api/air-quality/route.ts`)
- Dashboard orchestration → Live overview: renders tab (evidence: `src/app/page.tsx`)
- Dashboard orchestration → Pollutant details: renders tab (evidence: `src/app/page.tsx`)
- Dashboard orchestration → Location trends: renders tab (evidence: `src/app/page.tsx`)
- Dashboard orchestration → Data intelligence view: renders tab (evidence: `src/app/page.tsx`)
- Dashboard orchestration → Intelligence endpoint: requests analysis (evidence: `README.md`)
- Intelligence endpoint → Google Gemini: generates analysis (evidence: `src/app/api/gemini/route.ts`)
- Intelligence endpoint → Dashboard orchestration: returns analysis (evidence: `README.md`)
- Dashboard orchestration → Stakeholder actions: renders tab (evidence: `src/app/page.tsx`)
- Dashboard orchestration → Bilingual briefings: renders tab (evidence: `src/app/page.tsx`)
- Dashboard orchestration → Report comparison: renders tab (evidence: `src/app/page.tsx`)
- Dashboard orchestration → Browser report storage: saves snapshots (evidence: `src/app/page.tsx`)
- Report comparison → Browser report storage: reads snapshots (evidence: `src/components/PreviousReportsTab.tsx`)
- Live overview → AQI classification: classifies AQI (evidence: `src/components/OverviewTab.tsx`)
- Live overview → Browser report storage: loads recommendations (evidence: `src/components/OverviewTab.tsx`)
- Stakeholder actions → Browser report storage: gets actions (evidence: `src/components/RecommendationsTab.tsx`)
- Pollutant details → AQI classification: classifies readings (evidence: `src/components/LiveAirQualityTab.tsx`)
- AQI status badge → AQI classification: formats AQI (evidence: `src/components/AQIBadge.tsx`)
- Dashboard orchestration → CPCB provider endpoint: offers secondary data (evidence: `README.md`)
- Dashboard orchestration → OpenAQ provider endpoint: offers secondary data (evidence: `README.md`)
