# nguyentribaothang/airsafenet architecture

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

- Interactive diagram: https://gitdiagram.com/nguyentribaothang/airsafenet
- Repository: https://github.com/nguyentribaothang/airsafenet

## Overview

AirSafeNet is an HCMC air-quality decision platform. A citizen signs in through the React application, opens the dashboard, and receives cached current conditions, forecasts, risk guidance, trust metadata, alerts, and activity recommendations from the ASP.NET backend. Python computes ensemble forecasts into cache files, while backend services persist user, family, schedule, and conversation state in SQL Server. Separate product branches provide clean routing, mobility impact tracking, family safety, anomaly views, and an AI assistant. Some feature wiring is inferred from documented routes and named modules; sampled excerpts limit deeper call relationships.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_web_app["React Application<br/>[App.tsx]"]
  node_dashboard_ui["Dashboard View<br/>[Dashboard.tsx]"]
  node_assistant_ui["Assistant View<br/>[AssistantPage.tsx]"]
end

subgraph group_api["Backend APIs"]
  node_dashboard_api["Dashboard API"]
  node_activity_api["Activity API"]
  node_assistant_api["Assistant API"]
  node_auth_api["Authentication API<br/>[AuthController.cs]"]
  node_family_api["Family Profiles API"]
  node_anomaly_api["Anomaly API"]
end

subgraph group_intelligence["AI Intelligence"]
  node_ai_cache["Cached AI Service<br/>[AiCachedService.cs]"]
  node_data_trust["Source Health"]
  node_python_compute["Forecast Cache Compute<br/>[cache_manager.py]"]
  node_ensemble["Ensemble Forecasting"]
end

subgraph group_state["State and Integrations"]
  node_sql_server[("SQL Server<br/>[AppDbContext.cs]")]
  node_ai_cache_files["AI Cache Files<br/>[cache_manager.py]"]
  node_open_meteo["Open-Meteo"]
  node_open_aq["OpenAQ"]
  node_llm_provider["LLM Provider"]
end

subgraph group_decisions["Decision Features"]
  node_decision_ui["Clean Map<br/>[CleanMapPage.tsx]"]
  node_impact_ui["Impact Dashboard<br/>[ImpactPage.tsx]"]
  node_alert_service["Contextual Alerts"]
end

node_citizen(("Citizen"))

node_citizen -->|"uses"| node_web_app
node_web_app -->|"routes"| node_dashboard_ui
node_web_app -->|"routes"| node_assistant_ui
node_web_app -->|"routes"| node_decision_ui
node_web_app -->|"routes"| node_impact_ui
node_web_app -->|"authenticates"| node_auth_api
node_dashboard_ui -->|"requests"| node_dashboard_api
node_dashboard_ui -->|"requests"| node_anomaly_api
node_dashboard_ui -->|"requests"| node_family_api
node_dashboard_api -->|"reads forecasts"| node_ai_cache
node_dashboard_api -->|"reads trust"| node_data_trust
node_dashboard_api -->|"records snapshots"| node_sql_server
node_activity_api -->|"reads forecasts"| node_ai_cache
node_activity_api -->|"reads schedules"| node_sql_server
node_alert_service -->|"uses forecasts"| node_ai_cache
node_alert_service -->|"reads profiles"| node_sql_server
node_family_api -->|"stores profiles"| node_sql_server
node_assistant_ui -->|"requests"| node_assistant_api
node_assistant_api -->|"stores messages"| node_sql_server
node_assistant_api -.->|"generates replies"| node_llm_provider
node_python_compute -->|"calls models"| node_ensemble
node_python_compute -->|"writes results"| node_ai_cache_files
node_ai_cache -->|"reads results"| node_ai_cache_files
node_data_trust -->|"checks source"| node_open_meteo
node_data_trust -.->|"checks source"| node_open_aq

click node_web_app "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/App.tsx"
click node_dashboard_ui "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/pages/Dashboard.tsx"
click node_assistant_ui "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/pages/AssistantPage.tsx"
click node_decision_ui "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/pages/CleanMapPage.tsx"
click node_impact_ui "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/pages/ImpactPage.tsx"
click node_dashboard_api "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/DashboardController.cs"
click node_activity_api "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/ActivityController.cs"
click node_assistant_api "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/AssistantController.cs"
click node_auth_api "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/AuthController.cs"
click node_family_api "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/FamilyProfilesController.cs"
click node_alert_service "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Services/ContextualAlertService.cs"
click node_ai_cache "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Services/AiCachedService.cs"
click node_data_trust "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Services/DataSourceHealthService.cs"
click node_python_compute "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_ai/app/cache_manager.py"
click node_ensemble "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_ai/app/ensemble_predict.py"
click node_anomaly_api "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/AnomalyController.cs"
click node_sql_server "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Data/AppDbContext.cs"
click node_ai_cache_files "https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_ai/app/cache_manager.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_web_app,node_dashboard_ui,node_assistant_ui toneBlue
class node_dashboard_api,node_activity_api,node_assistant_api,node_auth_api,node_family_api,node_anomaly_api toneAmber
class node_ai_cache,node_data_trust,node_python_compute,node_ensemble toneMint
class node_sql_server,node_ai_cache_files,node_open_meteo,node_open_aq,node_llm_provider toneRose
class node_decision_ui,node_impact_ui,node_alert_service,node_citizen toneIndigo
```

## Components

### User Experience

- [React Application](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/App.tsx): `src/airsafenet_frontend/src/App.tsx`
- [Dashboard View](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/pages/Dashboard.tsx): `src/airsafenet_frontend/src/pages/Dashboard.tsx`
- [Assistant View](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/pages/AssistantPage.tsx): `src/airsafenet_frontend/src/pages/AssistantPage.tsx`

### Backend APIs

- [Dashboard API](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/DashboardController.cs): `src/airsafenet_backend/airsafenet_backend/Controllers/DashboardController.cs`
- [Activity API](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/ActivityController.cs): `src/airsafenet_backend/airsafenet_backend/Controllers/ActivityController.cs`
- [Assistant API](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/AssistantController.cs): `src/airsafenet_backend/airsafenet_backend/Controllers/AssistantController.cs`
- [Authentication API](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/AuthController.cs): `src/airsafenet_backend/airsafenet_backend/Controllers/AuthController.cs`
- [Family Profiles API](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/FamilyProfilesController.cs): `src/airsafenet_backend/airsafenet_backend/Controllers/FamilyProfilesController.cs`
- [Anomaly API](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Controllers/AnomalyController.cs): `src/airsafenet_backend/airsafenet_backend/Controllers/AnomalyController.cs`

### AI Intelligence

- [Cached AI Service](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Services/AiCachedService.cs): `src/airsafenet_backend/airsafenet_backend/Services/AiCachedService.cs`
- [Source Health](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Services/DataSourceHealthService.cs): `src/airsafenet_backend/airsafenet_backend/Services/DataSourceHealthService.cs`
- [Forecast Cache Compute](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_ai/app/cache_manager.py): `src/airsafenet_ai/app/cache_manager.py`
- [Ensemble Forecasting](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_ai/app/ensemble_predict.py): `src/airsafenet_ai/app/ensemble_predict.py`

### State and Integrations

- [SQL Server](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Data/AppDbContext.cs): `src/airsafenet_backend/airsafenet_backend/Data/AppDbContext.cs`
- [AI Cache Files](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_ai/app/cache_manager.py): `src/airsafenet_ai/app/cache_manager.py`
- **Open-Meteo**
- **OpenAQ**
- **LLM Provider**

### Decision Features

- [Clean Map](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/pages/CleanMapPage.tsx): `src/airsafenet_frontend/src/pages/CleanMapPage.tsx`
- [Impact Dashboard](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_frontend/src/pages/ImpactPage.tsx): `src/airsafenet_frontend/src/pages/ImpactPage.tsx`
- [Contextual Alerts](https://github.com/nguyentribaothang/airsafenet/blob/main/src/airsafenet_backend/airsafenet_backend/Services/ContextualAlertService.cs): `src/airsafenet_backend/airsafenet_backend/Services/ContextualAlertService.cs`

### Other components

- **Citizen**

## Connections

- Citizen → React Application: uses
- React Application → Dashboard View: routes
- React Application → Assistant View: routes
- React Application → Clean Map: routes
- React Application → Impact Dashboard: routes
- React Application → Authentication API: authenticates
- Dashboard View → Dashboard API: requests
- Dashboard View → Anomaly API: requests
- Dashboard View → Family Profiles API: requests
- Dashboard API → Cached AI Service: reads forecasts
- Dashboard API → Source Health: reads trust
- Dashboard API → SQL Server: records snapshots
- Activity API → Cached AI Service: reads forecasts
- Activity API → SQL Server: reads schedules
- Contextual Alerts → Cached AI Service: uses forecasts
- Contextual Alerts → SQL Server: reads profiles
- Family Profiles API → SQL Server: stores profiles
- Assistant View → Assistant API: requests
- Assistant API → SQL Server: stores messages
- Assistant API → LLM Provider: generates replies
- Forecast Cache Compute → Ensemble Forecasting: calls models
- Forecast Cache Compute → AI Cache Files: writes results
- Cached AI Service → AI Cache Files: reads results
- Source Health → Open-Meteo: checks source
- Source Health → OpenAQ: checks source
