# himanshudangwal16-gemini/breatheclear architecture

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

- Interactive diagram: https://gitdiagram.com/himanshudangwal16-gemini/breatheclear
- Repository: https://github.com/himanshudangwal16-gemini/breatheclear

## Overview

BreatheClear is an urban air-quality assistant for households. The main workflow is location and household profile selection, live air-data retrieval, deterministic risk and action assessment, then dashboard guidance and optional AI-generated plans or chat. It has parallel FastAPI and Express backends with corresponding Python and TypeScript service implementations. The README also documents comparison, alerts, indoor CADR guidance, quantified greener choices, and multilingual assistance. Some UI and Python relationships are supported by the README or source-index references; unsampled implementation details are not inferred.

Main entry points: [`src/App.tsx`](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/App.tsx) (Assistant SPA), [`app/main.py`](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/main.py) (FastAPI API), [`server.ts`](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server.ts) (Express API), [`server/services/providers.ts`](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/providers.ts) (Data providers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User Interface"]
  node_spa["Assistant SPA<br/>[App.tsx]"]
  node_dashboard["Air dashboard<br/>[DashboardView.tsx]"]
  node_daily["Daily plan<br/>[DailyPlanView.tsx]"]
  node_home["Clean home<br/>[CleanHomeView.tsx]"]
  node_choices["Greener choices"]
  node_compare["Compare trends"]
  node_alerts["Community alerts"]
  node_chat["Advisor chat<br/>[GeminiChatbot.tsx]"]
  node_location["Location picker"]
  node_profile["Household profile<br/>[ProfileDrawer.tsx]"]
end

subgraph group_routing["API Entry Points"]
  node_express["Express API<br/>[server.ts]"]
  node_fastapi["FastAPI API<br/>[main.py]"]
  node_schemas["Request schemas<br/>[schemas.py]"]
end

subgraph group_data["Environmental Data"]
  node_tsproviders["Data providers<br/>[providers.ts]"]
  node_pproviders["Data providers<br/>[providers.py]"]
end

subgraph group_logic["Decision Services"]
  node_tsdecision["Decision engine<br/>[decisionEngine.ts]"]
  node_pdecision["Decision engine<br/>[decision_engine.py]"]
  node_scales["AQI scales<br/>[aqiScales.ts]"]
  node_pscale["AQI scales<br/>[aqi_scales.py]"]
  node_impact["Impact calculator"]
  node_pimpact["Impact calculator<br/>[impact.py]"]
end

subgraph group_guidance["Household Guidance"]
  node_tsllm["Grounded AI<br/>[llmService.ts]"]
  node_pllm["Grounded AI<br/>[llm.py]"]
end

node_household(("Household user"))
node_genai{{"Gemini service"}}
node_environment{{"Open-Meteo and optional data sources"}}

node_household -->|"uses"| node_spa
node_spa -->|"requests assessment"| node_express
node_spa -->|"renders"| node_dashboard
node_spa -->|"renders"| node_daily
node_spa -->|"renders"| node_home
node_spa -->|"renders"| node_choices
node_spa -->|"renders"| node_compare
node_spa -->|"renders"| node_alerts
node_spa -->|"renders"| node_chat
node_spa -->|"renders"| node_location
node_spa -->|"renders"| node_profile
node_location -.->|"selects location"| node_spa
node_profile -.->|"sets profile"| node_spa
node_express -->|"fetches snapshot"| node_tsproviders
node_express -->|"runs assessment"| node_tsdecision
node_express -->|"streams chat"| node_tsllm
node_fastapi -->|"validates requests"| node_schemas
node_fastapi -->|"fetches snapshot"| node_pproviders
node_fastapi -->|"runs assessment"| node_pdecision
node_fastapi -->|"requests guidance"| node_pllm
node_tsproviders -->|"fetches data"| node_environment
node_pproviders -->|"fetches data"| node_environment
node_tsdecision -->|"calculates impact"| node_impact
node_pdecision -->|"calculates impact"| node_pimpact
node_tsproviders -->|"normalizes readings"| node_scales
node_pproviders -->|"normalizes readings"| node_pscale
node_tsllm -->|"generates response"| node_genai
node_pllm -->|"generates response"| node_genai
node_tsllm -->|"uses decision facts"| node_tsdecision
node_pllm -->|"uses decision facts"| node_pdecision

click node_spa "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/App.tsx"
click node_dashboard "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/DashboardView.tsx"
click node_daily "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/DailyPlanView.tsx"
click node_home "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/CleanHomeView.tsx"
click node_choices "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/GreenerChoicesView.tsx"
click node_compare "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/CompareTrendsView.tsx"
click node_alerts "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/AlertsCommunityView.tsx"
click node_chat "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/GeminiChatbot.tsx"
click node_location "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/LocationPickerModal.tsx"
click node_profile "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/ProfileDrawer.tsx"
click node_express "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server.ts"
click node_fastapi "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/main.py"
click node_schemas "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/models/schemas.py"
click node_tsproviders "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/providers.ts"
click node_pproviders "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/providers.py"
click node_tsdecision "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/decisionEngine.ts"
click node_pdecision "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/decision_engine.py"
click node_scales "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/aqiScales.ts"
click node_pscale "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/aqi_scales.py"
click node_impact "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/impactCalculator.ts"
click node_pimpact "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/impact.py"
click node_tsllm "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/llmService.ts"
click node_pllm "https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/llm.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_spa,node_dashboard,node_daily,node_home,node_choices,node_compare,node_alerts,node_chat,node_location,node_profile,node_household toneBlue
class node_express,node_fastapi,node_schemas toneAmber
class node_tsproviders,node_pproviders toneMint
class node_tsdecision,node_pdecision,node_scales,node_pscale,node_impact,node_pimpact toneRose
class node_tsllm,node_pllm,node_genai,node_environment toneIndigo
```

## Components

### User Interface

- [Assistant SPA](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/App.tsx): `src/App.tsx`
- [Air dashboard](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/DashboardView.tsx): `src/components/DashboardView.tsx`
- [Daily plan](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/DailyPlanView.tsx): `src/components/DailyPlanView.tsx`
- [Clean home](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/CleanHomeView.tsx): `src/components/CleanHomeView.tsx`
- [Greener choices](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/GreenerChoicesView.tsx): `src/components/GreenerChoicesView.tsx`
- [Compare trends](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/CompareTrendsView.tsx): `src/components/CompareTrendsView.tsx`
- [Community alerts](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/AlertsCommunityView.tsx): `src/components/AlertsCommunityView.tsx`
- [Advisor chat](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/GeminiChatbot.tsx): `src/components/GeminiChatbot.tsx`
- [Location picker](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/LocationPickerModal.tsx): `src/components/LocationPickerModal.tsx`
- [Household profile](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/src/components/ProfileDrawer.tsx): `src/components/ProfileDrawer.tsx`

### API Entry Points

- [Express API](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server.ts): `server.ts`
- [FastAPI API](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/main.py): `app/main.py`
- [Request schemas](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/models/schemas.py): `app/models/schemas.py`

### Environmental Data

- [Data providers](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/providers.ts): `server/services/providers.ts`
- [Data providers](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/providers.py): `app/services/providers.py`

### Decision Services

- [Decision engine](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/decisionEngine.ts): `server/services/decisionEngine.ts`
- [Decision engine](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/decision_engine.py): `app/services/decision_engine.py`
- [AQI scales](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/aqiScales.ts): `server/services/aqiScales.ts`
- [AQI scales](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/aqi_scales.py): `app/services/aqi_scales.py`
- [Impact calculator](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/impactCalculator.ts): `server/services/impactCalculator.ts`
- [Impact calculator](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/impact.py): `app/services/impact.py`

### Household Guidance

- [Grounded AI](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/server/services/llmService.ts): `server/services/llmService.ts`
- [Grounded AI](https://github.com/himanshudangwal16-gemini/breatheclear/blob/main/app/services/llm.py): `app/services/llm.py`

### Other components

- **Household user**
- **Gemini service**
- **Open-Meteo and optional data sources**

## Connections

- Household user → Assistant SPA: uses (evidence: `README.md`)
- Assistant SPA → Express API: requests assessment (evidence: `src/App.tsx`)
- Assistant SPA → Air dashboard: renders (evidence: `src/App.tsx`)
- Assistant SPA → Daily plan: renders (evidence: `src/App.tsx`)
- Assistant SPA → Clean home: renders (evidence: `src/App.tsx`)
- Assistant SPA → Greener choices: renders (evidence: `src/App.tsx`)
- Assistant SPA → Compare trends: renders (evidence: `src/App.tsx`)
- Assistant SPA → Community alerts: renders (evidence: `src/App.tsx`)
- Assistant SPA → Advisor chat: renders (evidence: `src/App.tsx`)
- Assistant SPA → Location picker: renders (evidence: `src/App.tsx`)
- Assistant SPA → Household profile: renders (evidence: `src/App.tsx`)
- Location picker → Assistant SPA: selects location (evidence: `src/App.tsx`)
- Household profile → Assistant SPA: sets profile (evidence: `src/App.tsx`)
- Express API → Data providers: fetches snapshot (evidence: `server.ts`)
- Express API → Decision engine: runs assessment (evidence: `server.ts`)
- Express API → Grounded AI: streams chat (evidence: `server.ts`)
- FastAPI API → Request schemas: validates requests (evidence: `app/main.py`)
- FastAPI API → Data providers: fetches snapshot (evidence: `app/main.py`)
- FastAPI API → Decision engine: runs assessment (evidence: `app/main.py`)
- FastAPI API → Grounded AI: requests guidance (evidence: `app/main.py`)
- Data providers → Open-Meteo and optional data sources: fetches data (evidence: `README.md`)
- Data providers → Open-Meteo and optional data sources: fetches data (evidence: `README.md`)
- Decision engine → Impact calculator: calculates impact (evidence: `server/services/decisionEngine.ts`)
- Decision engine → Impact calculator: calculates impact (evidence: `app/services/decision_engine.py`)
- Data providers → AQI scales: normalizes readings (evidence: `server/services/providers.ts`)
- Data providers → AQI scales: normalizes readings (evidence: `app/services/providers.py`)
- Grounded AI → Gemini service: generates response (evidence: `server/services/llmService.ts`)
- Grounded AI → Gemini service: generates response (evidence: `app/services/llm.py`)
- Grounded AI → Decision engine: uses decision facts (evidence: `server/services/llmService.ts`)
- Grounded AI → Decision engine: uses decision facts (evidence: `app/services/llm.py`)
