# phoenix-huh/bda-proj architecture

> Architecture diagram of the GitHub repository phoenix-huh/bda-proj, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phoenix-huh/bda-proj
- Repository: https://github.com/phoenix-huh/bda-proj

## Overview

This is a Flask air-quality prediction and analytics dashboard. Users select a monitoring station and time to get pollutant/AQI predictions with fallback lag inputs and health advice, or explore historical visuals, forecasts, model evaluation, COVID-era analysis, and city maps. The graph includes documented capabilities whose route implementations were not fully excerpted; their links are limited to README statements or visible imports and calls. Some runtime wiring and storage details are documented but not shown in source excerpts.

Main entry points: [`novelties.py`](https://github.com/phoenix-huh/bda-proj/blob/main/novelties.py) (Analytics routes), [`app.py`](https://github.com/phoenix-huh/bda-proj/blob/main/app.py) (Flask routes), [`compare_models.py`](https://github.com/phoenix-huh/bda-proj/blob/main/compare_models.py) (Model comparison), [`features.py`](https://github.com/phoenix-huh/bda-proj/blob/main/features.py) (Forecast features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_flask["Flask routes<br/>[app.py]"]
  node_novelty_routes["Analytics routes<br/>[novelties.py]"]
  node_dashboard["Dashboard views<br/>[index.html]"]
  node_forecast_view["Forecast view<br/>[forecast.html]"]
  node_models_view["Models view<br/>[models.html]"]
  node_covid_view["COVID view<br/>[covid.html]"]
  node_map_view["Map view<br/>[map.html]"]
  node_advice_renderer["Advice renderer<br/>[advisory.js]"]
end

subgraph group_prediction["Prediction and advice"]
  node_lag_fallback["Lag fallback<br/>[app.py]"]
  node_aqi_model["AQI regressor"]
  node_advice["Health advice<br/>[advisory.py]"]
end

subgraph group_forecast["Forecasting"]
  node_forecast_service["Forecast service<br/>[novelties.py]"]
  node_forecast_features["Forecast features<br/>[features.py]"]
  node_forecast_modeling["Forecast models<br/>[modeling.py]"]
  node_train_forecast["Forecast training<br/>[train_forecast.py]"]
end

subgraph group_analytics["Analytics"]
  node_covid_analysis["COVID analysis<br/>[covid.py]"]
  node_shap_analysis["Feature explanations<br/>[explain.py]"]
  node_model_comparison["Model comparison<br/>[compare_models.py]"]
end

subgraph group_data["Data and models"]
  node_forecast_assets["Forecast artifacts"]
  node_station_data["Station observations"]
  node_hourly_db[("Hourly lookup")]
  node_summary_cache["Station summaries"]
  node_covid_results["COVID results<br/>[covid_yoy.csv]"]
  node_model_results["Model results"]
end

node_visitor(("Dashboard user"))

node_visitor -->|"submits queries"| node_flask
node_flask -->|"renders dashboard"| node_dashboard
node_flask -->|"builds lag inputs"| node_lag_fallback
node_lag_fallback -->|"checks prior hour"| node_hourly_db
node_lag_fallback -->|"falls back to averages"| node_summary_cache
node_flask -->|"predicts targets"| node_aqi_model
node_flask -->|"requests advice"| node_advice
node_advice -->|"renders advice data"| node_advice_renderer
node_flask -->|"visualizes history"| node_station_data
node_flask -->|"registers routes"| node_novelty_routes
node_novelty_routes -->|"renders forecast"| node_forecast_view
node_novelty_routes -->|"loads forecasts"| node_forecast_assets
node_novelty_routes -->|"uses shared features"| node_forecast_features
node_train_forecast -->|"builds and calibrates"| node_forecast_modeling
node_novelty_routes -->|"renders evaluation"| node_models_view
node_novelty_routes -->|"reads comparisons"| node_model_results
node_novelty_routes -->|"renders analysis"| node_covid_view
node_novelty_routes -->|"requests chart data"| node_covid_analysis
node_novelty_routes -->|"reads map data"| node_covid_results
node_novelty_routes -->|"serves map data"| node_map_view
node_covid_analysis -.->|"analyzes observations"| node_station_data
node_shap_analysis -->|"uses feature set"| node_forecast_features
node_shap_analysis -->|"fits explainer model"| node_forecast_modeling
node_model_comparison -->|"loads dataset features"| node_forecast_features
node_model_comparison -->|"compares regressors"| node_forecast_modeling
node_model_comparison -.->|"uses observations"| node_station_data

click node_flask "https://github.com/phoenix-huh/bda-proj/blob/main/app.py"
click node_novelty_routes "https://github.com/phoenix-huh/bda-proj/blob/main/novelties.py"
click node_dashboard "https://github.com/phoenix-huh/bda-proj/blob/main/templates/index.html"
click node_forecast_view "https://github.com/phoenix-huh/bda-proj/blob/main/templates/forecast.html"
click node_models_view "https://github.com/phoenix-huh/bda-proj/blob/main/templates/models.html"
click node_covid_view "https://github.com/phoenix-huh/bda-proj/blob/main/templates/covid.html"
click node_map_view "https://github.com/phoenix-huh/bda-proj/blob/main/templates/map.html"
click node_lag_fallback "https://github.com/phoenix-huh/bda-proj/blob/main/app.py"
click node_aqi_model "https://github.com/phoenix-huh/bda-proj/blob/main/models/air_quality_model.pkl"
click node_advice "https://github.com/phoenix-huh/bda-proj/blob/main/advisory.py"
click node_advice_renderer "https://github.com/phoenix-huh/bda-proj/blob/main/static/advisory.js"
click node_forecast_service "https://github.com/phoenix-huh/bda-proj/blob/main/novelties.py"
click node_forecast_features "https://github.com/phoenix-huh/bda-proj/blob/main/features.py"
click node_forecast_modeling "https://github.com/phoenix-huh/bda-proj/blob/main/modeling.py"
click node_forecast_assets "https://github.com/phoenix-huh/bda-proj/blob/main/models/forecast_models.joblib"
click node_covid_analysis "https://github.com/phoenix-huh/bda-proj/blob/main/covid.py"
click node_shap_analysis "https://github.com/phoenix-huh/bda-proj/blob/main/explain.py"
click node_model_comparison "https://github.com/phoenix-huh/bda-proj/blob/main/compare_models.py"
click node_station_data "https://github.com/phoenix-huh/bda-proj/blob/main/data/station_hour_cleaned.csv"
click node_covid_results "https://github.com/phoenix-huh/bda-proj/blob/main/results/covid_yoy.csv"
click node_model_results "https://github.com/phoenix-huh/bda-proj/blob/main/results/model_comparison.csv"
click node_train_forecast "https://github.com/phoenix-huh/bda-proj/blob/main/train_forecast.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_flask,node_novelty_routes,node_dashboard,node_forecast_view,node_models_view,node_covid_view,node_map_view,node_advice_renderer,node_visitor toneBlue
class node_lag_fallback,node_aqi_model,node_advice toneAmber
class node_forecast_service,node_forecast_features,node_forecast_modeling,node_train_forecast toneMint
class node_covid_analysis,node_shap_analysis,node_model_comparison toneRose
class node_forecast_assets,node_station_data,node_hourly_db,node_summary_cache,node_covid_results,node_model_results toneIndigo
```

## Components

### Web application

- [Flask routes](https://github.com/phoenix-huh/bda-proj/blob/main/app.py): `app.py`
- [Analytics routes](https://github.com/phoenix-huh/bda-proj/blob/main/novelties.py): `novelties.py`
- [Dashboard views](https://github.com/phoenix-huh/bda-proj/blob/main/templates/index.html): `templates/index.html`
- [Forecast view](https://github.com/phoenix-huh/bda-proj/blob/main/templates/forecast.html): `templates/forecast.html`
- [Models view](https://github.com/phoenix-huh/bda-proj/blob/main/templates/models.html): `templates/models.html`
- [COVID view](https://github.com/phoenix-huh/bda-proj/blob/main/templates/covid.html): `templates/covid.html`
- [Map view](https://github.com/phoenix-huh/bda-proj/blob/main/templates/map.html): `templates/map.html`
- [Advice renderer](https://github.com/phoenix-huh/bda-proj/blob/main/static/advisory.js): `static/advisory.js`

### Prediction and advice

- [Lag fallback](https://github.com/phoenix-huh/bda-proj/blob/main/app.py): `app.py`
- [AQI regressor](https://github.com/phoenix-huh/bda-proj/blob/main/models/air_quality_model.pkl): `models/air_quality_model.pkl`
- [Health advice](https://github.com/phoenix-huh/bda-proj/blob/main/advisory.py): `advisory.py`

### Forecasting

- [Forecast service](https://github.com/phoenix-huh/bda-proj/blob/main/novelties.py): `novelties.py`
- [Forecast features](https://github.com/phoenix-huh/bda-proj/blob/main/features.py): `features.py`
- [Forecast models](https://github.com/phoenix-huh/bda-proj/blob/main/modeling.py): `modeling.py`
- [Forecast training](https://github.com/phoenix-huh/bda-proj/blob/main/train_forecast.py): `train_forecast.py`

### Analytics

- [COVID analysis](https://github.com/phoenix-huh/bda-proj/blob/main/covid.py): `covid.py`
- [Feature explanations](https://github.com/phoenix-huh/bda-proj/blob/main/explain.py): `explain.py`
- [Model comparison](https://github.com/phoenix-huh/bda-proj/blob/main/compare_models.py): `compare_models.py`

### Data and models

- [Forecast artifacts](https://github.com/phoenix-huh/bda-proj/blob/main/models/forecast_models.joblib): `models/forecast_models.joblib`
- [Station observations](https://github.com/phoenix-huh/bda-proj/blob/main/data/station_hour_cleaned.csv): `data/station_hour_cleaned.csv`
- **Hourly lookup**
- **Station summaries**
- [COVID results](https://github.com/phoenix-huh/bda-proj/blob/main/results/covid_yoy.csv): `results/covid_yoy.csv`
- [Model results](https://github.com/phoenix-huh/bda-proj/blob/main/results/model_comparison.csv): `results/model_comparison.csv`

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Flask routes: submits queries (evidence: `README.md`)
- Flask routes → Dashboard views: renders dashboard (evidence: `README.md`)
- Flask routes → Lag fallback: builds lag inputs (evidence: `app.py`)
- Lag fallback → Hourly lookup: checks prior hour (evidence: `README.md`)
- Lag fallback → Station summaries: falls back to averages (evidence: `README.md`)
- Flask routes → AQI regressor: predicts targets (evidence: `README.md`)
- Flask routes → Health advice: requests advice (evidence: `app.py`)
- Health advice → Advice renderer: renders advice data (evidence: `static/advisory.js`)
- Flask routes → Station observations: visualizes history (evidence: `README.md`)
- Flask routes → Analytics routes: registers routes (evidence: `app.py`)
- Analytics routes → Forecast view: renders forecast (evidence: `novelties.py`)
- Analytics routes → Forecast artifacts: loads forecasts (evidence: `novelties.py`)
- Analytics routes → Forecast features: uses shared features (evidence: `novelties.py`)
- Forecast training → Forecast models: builds and calibrates (evidence: `train_forecast.py`)
- Analytics routes → Models view: renders evaluation (evidence: `novelties.py`)
- Analytics routes → Model results: reads comparisons (evidence: `novelties.py`)
- Analytics routes → COVID view: renders analysis (evidence: `novelties.py`)
- Analytics routes → COVID analysis: requests chart data (evidence: `novelties.py`)
- Analytics routes → COVID results: reads map data (evidence: `novelties.py`)
- Analytics routes → Map view: serves map data (evidence: `novelties.py`)
- COVID analysis → Station observations: analyzes observations
- Feature explanations → Forecast features: uses feature set (evidence: `explain.py`)
- Feature explanations → Forecast models: fits explainer model (evidence: `explain.py`)
- Model comparison → Forecast features: loads dataset features (evidence: `compare_models.py`)
- Model comparison → Forecast models: compares regressors (evidence: `compare_models.py`)
- Model comparison → Station observations: uses observations
