# nyyanja/donnee2_high5 architecture

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

- Interactive diagram: https://gitdiagram.com/nyyanja/donnee2_high5
- Repository: https://github.com/nyyanja/donnee2_high5

## Overview

DONNEE2_High5 is an hourly air-quality ETL pipeline for five cities. GitHub Actions initiates collection; current and historical API responses are stored as raw JSON, transformed into a deduplicated and time-enriched CSV, validated, and loaded into a PostgreSQL star schema for analytics. The README also documents email success/failure notifications. Source excerpts establish the collection, backfill, transformation, validation, and warehouse calls; some scheduling and notification details are documented rather than demonstrated in sampled code.

Main entry points: [`src/load_warehouse.py`](https://github.com/nyyanja/donnee2_high5/blob/main/src/load_warehouse.py) (Warehouse loader), [`.github/workflows/daily_airflow.yml`](https://github.com/nyyanja/donnee2_high5/blob/main/.github/workflows/daily_airflow.yml) (Hourly Actions), [`src/collect.py`](https://github.com/nyyanja/donnee2_high5/blob/main/src/collect.py) (Live collection), [`src/backfill.py`](https://github.com/nyyanja/donnee2_high5/blob/main/src/backfill.py) (Historical backfill)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Scheduling"]
  node_actions["Hourly Actions<br/>[daily_airflow.yml]"]
end

subgraph group_ingestion["Data collection"]
  node_collector["Live collection<br/>[collect.py]"]
  node_backfill["Historical backfill<br/>[backfill.py]"]
  node_raw["Raw JSON"]
end

subgraph group_preparation["Data preparation"]
  node_cleaner["Transform and deduplicate<br/>[clean.py]"]
  node_clean_csv["Clean AQI CSV"]
  node_validator["Data validation<br/>[validate_clean.py]"]
end

subgraph group_warehouse["Analytics warehouse"]
  node_loader["Warehouse loader<br/>[load_warehouse.py]"]
  node_db_connection["DB connection<br/>[db.py]"]
  node_warehouse_models["Star-schema operations<br/>[models.py]"]
  node_postgres[("Neon PostgreSQL")]
end

node_openweather{{"OpenWeather API"}}
node_analytics(("Analytics consumers"))
node_email{{"Email notifications"}}

node_actions -->|"triggers hourly"| node_collector
node_actions -->|"runs backfill"| node_backfill
node_collector -->|"requests measurements"| node_openweather
node_backfill -->|"requests history"| node_openweather
node_collector -->|"writes JSON"| node_raw
node_backfill -->|"writes JSON"| node_raw
node_raw -->|"reads files"| node_cleaner
node_cleaner -->|"writes CSV"| node_clean_csv
node_clean_csv -->|"validates"| node_validator
node_validator -->|"gates loading"| node_loader
node_loader -->|"reads CSV"| node_clean_csv
node_loader -->|"calls operations"| node_warehouse_models
node_warehouse_models -->|"opens connections"| node_db_connection
node_loader -->|"opens connection"| node_db_connection
node_db_connection -->|"connects securely"| node_postgres
node_warehouse_models -->|"reads and writes"| node_postgres
node_postgres -->|"serves warehouse data"| node_analytics
node_actions -.->|"notifies outcomes"| node_email

click node_actions "https://github.com/nyyanja/donnee2_high5/blob/main/.github/workflows/daily_airflow.yml"
click node_collector "https://github.com/nyyanja/donnee2_high5/blob/main/src/collect.py"
click node_backfill "https://github.com/nyyanja/donnee2_high5/blob/main/src/backfill.py"
click node_raw "https://github.com/nyyanja/donnee2_high5/tree/main/raw"
click node_cleaner "https://github.com/nyyanja/donnee2_high5/blob/main/src/clean.py"
click node_clean_csv "https://github.com/nyyanja/donnee2_high5/blob/main/clean/air_quality_clean.csv"
click node_validator "https://github.com/nyyanja/donnee2_high5/blob/main/src/validate_clean.py"
click node_loader "https://github.com/nyyanja/donnee2_high5/blob/main/src/load_warehouse.py"
click node_db_connection "https://github.com/nyyanja/donnee2_high5/blob/main/src/warehouse/db.py"
click node_warehouse_models "https://github.com/nyyanja/donnee2_high5/blob/main/src/warehouse/models.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_actions toneBlue
class node_collector,node_backfill,node_raw toneAmber
class node_cleaner,node_clean_csv,node_validator,node_openweather toneMint
class node_loader,node_db_connection,node_warehouse_models,node_postgres toneRose
class node_analytics,node_email toneIndigo
```

## Components

### Scheduling

- [Hourly Actions](https://github.com/nyyanja/donnee2_high5/blob/main/.github/workflows/daily_airflow.yml): `.github/workflows/daily_airflow.yml`

### Data collection

- [Live collection](https://github.com/nyyanja/donnee2_high5/blob/main/src/collect.py): `src/collect.py`
- [Historical backfill](https://github.com/nyyanja/donnee2_high5/blob/main/src/backfill.py): `src/backfill.py`
- [Raw JSON](https://github.com/nyyanja/donnee2_high5/tree/main/raw): `raw`

### Data preparation

- [Transform and deduplicate](https://github.com/nyyanja/donnee2_high5/blob/main/src/clean.py): `src/clean.py`
- [Clean AQI CSV](https://github.com/nyyanja/donnee2_high5/blob/main/clean/air_quality_clean.csv): `clean/air_quality_clean.csv`
- [Data validation](https://github.com/nyyanja/donnee2_high5/blob/main/src/validate_clean.py): `src/validate_clean.py`

### Analytics warehouse

- [Warehouse loader](https://github.com/nyyanja/donnee2_high5/blob/main/src/load_warehouse.py): `src/load_warehouse.py`
- [DB connection](https://github.com/nyyanja/donnee2_high5/blob/main/src/warehouse/db.py): `src/warehouse/db.py`
- [Star-schema operations](https://github.com/nyyanja/donnee2_high5/blob/main/src/warehouse/models.py): `src/warehouse/models.py`
- **Neon PostgreSQL**

### Other components

- **OpenWeather API**
- **Analytics consumers**
- **Email notifications**

## Connections

- Hourly Actions → Live collection: triggers hourly (evidence: `README.md`)
- Hourly Actions → Historical backfill: runs backfill (evidence: `README.md`)
- Live collection → OpenWeather API: requests measurements (evidence: `src/collect.py`)
- Historical backfill → OpenWeather API: requests history (evidence: `src/backfill.py`)
- Live collection → Raw JSON: writes JSON (evidence: `src/collect.py`)
- Historical backfill → Raw JSON: writes JSON (evidence: `src/backfill.py`)
- Raw JSON → Transform and deduplicate: reads files (evidence: `src/clean.py`)
- Transform and deduplicate → Clean AQI CSV: writes CSV (evidence: `src/clean.py`)
- Clean AQI CSV → Data validation: validates (evidence: `README.md`)
- Data validation → Warehouse loader: gates loading (evidence: `README.md`)
- Warehouse loader → Clean AQI CSV: reads CSV (evidence: `src/load_warehouse.py`)
- Warehouse loader → Star-schema operations: calls operations (evidence: `src/load_warehouse.py`)
- Star-schema operations → DB connection: opens connections (evidence: `src/warehouse/models.py`)
- Warehouse loader → DB connection: opens connection (evidence: `src/load_warehouse.py`)
- DB connection → Neon PostgreSQL: connects securely (evidence: `src/warehouse/db.py`)
- Star-schema operations → Neon PostgreSQL: reads and writes (evidence: `src/warehouse/models.py`)
- Neon PostgreSQL → Analytics consumers: serves warehouse data (evidence: `README.md`)
- Hourly Actions → Email notifications: notifies outcomes (evidence: `README.md`)
