# girwandhakal/flight-delay-pipeline architecture

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

- Interactive diagram: https://gitdiagram.com/girwandhakal/flight-delay-pipeline
- Repository: https://github.com/girwandhakal/flight-delay-pipeline

## Overview

This is a PySpark flight-delay prediction pipeline: it acquires BTS schedules and NOAA weather, prepares chronological flight and weather features, adds rotation and en-route advisories, then trains and evaluates progressively richer models. Edges follow the README’s documented stages and the supplied source references/excerpts; unsampled implementation details are not assumed.

Main entry points: [`pipeline/main.py`](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/pipeline/main.py) (Pipeline runner), [`scripts/bts/train.py`](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/train.py) (Tiered model training), [`scripts/origin_weather/build_features.py`](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/origin_weather/build_features.py) (Origin weather features), [`scripts/bts/cache.py`](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/cache.py) (BTS generation cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Pipeline orchestration"]
  node_pipeline["Pipeline runner<br/>[main.py]"]
end

subgraph group_bts["BTS flight data"]
  node_bts_download["BTS acquisition<br/>[download.py]"]
  node_bts_clean["BTS cleaning<br/>[clean.py]"]
  node_bts_features["BTS Gold features<br/>[build_features.py]"]
  node_bts_history["Delay histories<br/>[recent_delays.py]"]
  node_bts_cache["BTS generation cache<br/>[cache.py]"]
end

subgraph group_weather["Surface weather"]
  node_weather_download["Weather acquisition<br/>[download.py]"]
  node_weather_clean["Weather normalization<br/>[clean.py]"]
  node_measurements["Weather measurements<br/>[measurements.py]"]
  node_origin_weather["Origin weather features<br/>[build_features.py]"]
  node_destination_weather["Destination weather features<br/>[build_features.py]"]
  node_weather_cache["Weather Gold cache<br/>[weather_cache.py]"]
end

subgraph group_enrichment["Predictive enrichment"]
  node_rotation["Aircraft rotation<br/>[build_features.py]"]
  node_rotation_run["Rotation experiment runner<br/>[run.py]"]
  node_enroute_download["En-route acquisition<br/>[download.py]"]
  node_taf_clean["TAF cleaning<br/>[clean_taf.py]"]
  node_sigmet_clean["SIGMET cleaning<br/>[clean_sigmets.py]"]
  node_enroute_features["En-route features<br/>[build_features.py]"]
  node_enroute_run["En-route runner<br/>[run.py]"]
end

subgraph group_modeling["Modeling and outputs"]
  node_trainer["Tiered model training<br/>[train.py]"]
  node_evaluator["Explicit scoring<br/>[evaluate.py]"]
  node_results["Metrics and history<br/>[results.py]"]
end

node_user(("Pipeline operator"))
node_bts_source[("BTS TranStats")]
node_noaa[("NOAA LCDv2")]

node_user -->|"runs"| node_pipeline
node_pipeline -->|"runs"| node_bts_download
node_bts_source -->|"acquires schedules"| node_bts_download
node_pipeline -->|"prepares generations"| node_bts_cache
node_bts_cache -->|"builds Silver"| node_bts_clean
node_bts_cache -->|"builds Gold"| node_bts_features
node_bts_features -->|"uses histories"| node_bts_history
node_pipeline -->|"runs"| node_weather_download
node_noaa -->|"provides observations"| node_weather_download
node_weather_download -->|"supplies raw files"| node_weather_clean
node_weather_clean -->|"decodes fields"| node_measurements
node_pipeline -->|"runs"| node_origin_weather
node_origin_weather -->|"uses observations"| node_weather_clean
node_pipeline -->|"runs"| node_destination_weather
node_destination_weather -->|"enriches origin Gold"| node_origin_weather
node_pipeline -->|"checks reuse"| node_weather_cache
node_pipeline -->|"runs comparison"| node_rotation_run
node_rotation_run -->|"prepares features"| node_rotation
node_pipeline -->|"runs"| node_enroute_run
node_enroute_run -->|"acquires inputs"| node_enroute_download
node_enroute_download -->|"cleans TAF"| node_taf_clean
node_enroute_download -->|"cleans SIGMET"| node_sigmet_clean
node_enroute_run -->|"builds features"| node_enroute_features
node_pipeline -->|"trains tiers"| node_trainer
node_trainer -->|"uses BTS features"| node_bts_features
node_trainer -->|"uses weather features"| node_origin_weather
node_trainer -->|"uses destination features"| node_destination_weather
node_trainer -->|"uses rotation features"| node_rotation
node_trainer -->|"uses en-route features"| node_enroute_features
node_pipeline -->|"scores holdout"| node_evaluator
node_trainer -->|"publishes metrics"| node_results
node_evaluator -->|"publishes scores"| node_results

click node_pipeline "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/pipeline/main.py"
click node_bts_download "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/download.py"
click node_bts_clean "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/clean.py"
click node_bts_features "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/build_features.py"
click node_bts_history "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/recent_delays.py"
click node_bts_cache "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/cache.py"
click node_weather_download "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/origin_weather/download.py"
click node_weather_clean "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/origin_weather/clean.py"
click node_measurements "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/origin_weather/measurements.py"
click node_origin_weather "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/origin_weather/build_features.py"
click node_destination_weather "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/destination_weather/build_features.py"
click node_weather_cache "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/weather_cache.py"
click node_rotation "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/aircraft_rotation/build_features.py"
click node_rotation_run "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/aircraft_rotation/run.py"
click node_enroute_download "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/download.py"
click node_taf_clean "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/clean_taf.py"
click node_sigmet_clean "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/clean_sigmets.py"
click node_enroute_features "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/build_features.py"
click node_enroute_run "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/run.py"
click node_trainer "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/train.py"
click node_evaluator "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/evaluate.py"
click node_results "https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/results.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_pipeline toneBlue
class node_bts_download,node_bts_clean,node_bts_features,node_bts_history,node_bts_cache,node_bts_source,node_noaa toneAmber
class node_weather_download,node_weather_clean,node_measurements,node_origin_weather,node_destination_weather,node_weather_cache toneMint
class node_rotation,node_rotation_run,node_enroute_download,node_taf_clean,node_sigmet_clean,node_enroute_features,node_enroute_run toneRose
class node_trainer,node_evaluator,node_results,node_user toneIndigo
```

## Components

### Pipeline orchestration

- [Pipeline runner](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/pipeline/main.py): `pipeline/main.py`

### BTS flight data

- [BTS acquisition](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/download.py): `scripts/bts/download.py`
- [BTS cleaning](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/clean.py): `scripts/bts/clean.py`
- [BTS Gold features](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/build_features.py): `scripts/bts/build_features.py`
- [Delay histories](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/recent_delays.py): `scripts/bts/recent_delays.py`
- [BTS generation cache](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/cache.py): `scripts/bts/cache.py`

### Surface weather

- [Weather acquisition](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/origin_weather/download.py): `scripts/origin_weather/download.py`
- [Weather normalization](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/origin_weather/clean.py): `scripts/origin_weather/clean.py`
- [Weather measurements](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/origin_weather/measurements.py): `scripts/origin_weather/measurements.py`
- [Origin weather features](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/origin_weather/build_features.py): `scripts/origin_weather/build_features.py`
- [Destination weather features](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/destination_weather/build_features.py): `scripts/destination_weather/build_features.py`
- [Weather Gold cache](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/weather_cache.py): `scripts/weather_cache.py`

### Predictive enrichment

- [Aircraft rotation](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/aircraft_rotation/build_features.py): `scripts/aircraft_rotation/build_features.py`
- [Rotation experiment runner](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/aircraft_rotation/run.py): `scripts/aircraft_rotation/run.py`
- [En-route acquisition](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/download.py): `scripts/enroute_weather/download.py`
- [TAF cleaning](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/clean_taf.py): `scripts/enroute_weather/clean_taf.py`
- [SIGMET cleaning](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/clean_sigmets.py): `scripts/enroute_weather/clean_sigmets.py`
- [En-route features](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/build_features.py): `scripts/enroute_weather/build_features.py`
- [En-route runner](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/enroute_weather/run.py): `scripts/enroute_weather/run.py`

### Modeling and outputs

- [Tiered model training](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/train.py): `scripts/bts/train.py`
- [Explicit scoring](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/bts/evaluate.py): `scripts/bts/evaluate.py`
- [Metrics and history](https://github.com/girwandhakal/flight-delay-pipeline/blob/main/scripts/results.py): `scripts/results.py`

### Other components

- **Pipeline operator**
- **BTS TranStats**
- **NOAA LCDv2**

## Connections

- Pipeline operator → Pipeline runner: runs (evidence: `README.md`)
- Pipeline runner → BTS acquisition: runs (evidence: `pipeline/main.py`)
- BTS TranStats → BTS acquisition: acquires schedules (evidence: `README.md`)
- Pipeline runner → BTS generation cache: prepares generations (evidence: `pipeline/main.py`)
- BTS generation cache → BTS cleaning: builds Silver (evidence: `scripts/bts/cache.py`)
- BTS generation cache → BTS Gold features: builds Gold (evidence: `scripts/bts/cache.py`)
- BTS Gold features → Delay histories: uses histories (evidence: `scripts/bts/build_features.py`)
- Pipeline runner → Weather acquisition: runs (evidence: `pipeline/main.py`)
- NOAA LCDv2 → Weather acquisition: provides observations (evidence: `README.md`)
- Weather acquisition → Weather normalization: supplies raw files (evidence: `scripts/origin_weather/clean.py`)
- Weather normalization → Weather measurements: decodes fields (evidence: `scripts/origin_weather/clean.py`)
- Pipeline runner → Origin weather features: runs (evidence: `pipeline/main.py`)
- Origin weather features → Weather normalization: uses observations (evidence: `scripts/origin_weather/build_features.py`)
- Pipeline runner → Destination weather features: runs (evidence: `pipeline/main.py`)
- Destination weather features → Origin weather features: enriches origin Gold (evidence: `scripts/destination_weather/build_features.py`)
- Pipeline runner → Weather Gold cache: checks reuse (evidence: `pipeline/main.py`)
- Pipeline runner → Rotation experiment runner: runs comparison (evidence: `pipeline/main.py`)
- Rotation experiment runner → Aircraft rotation: prepares features (evidence: `scripts/aircraft_rotation/run.py`)
- Pipeline runner → En-route runner: runs (evidence: `pipeline/main.py`)
- En-route runner → En-route acquisition: acquires inputs (evidence: `scripts/enroute_weather/run.py`)
- En-route acquisition → TAF cleaning: cleans TAF (evidence: `scripts/enroute_weather/download.py`)
- En-route acquisition → SIGMET cleaning: cleans SIGMET (evidence: `scripts/enroute_weather/download.py`)
- En-route runner → En-route features: builds features (evidence: `scripts/enroute_weather/run.py`)
- Pipeline runner → Tiered model training: trains tiers (evidence: `pipeline/main.py`)
- Tiered model training → BTS Gold features: uses BTS features (evidence: `scripts/bts/train.py`)
- Tiered model training → Origin weather features: uses weather features (evidence: `scripts/bts/train.py`)
- Tiered model training → Destination weather features: uses destination features (evidence: `scripts/bts/train.py`)
- Tiered model training → Aircraft rotation: uses rotation features (evidence: `scripts/bts/train.py`)
- Tiered model training → En-route features: uses en-route features (evidence: `scripts/bts/train.py`)
- Pipeline runner → Explicit scoring: scores holdout (evidence: `pipeline/main.py`)
- Tiered model training → Metrics and history: publishes metrics (evidence: `scripts/bts/train.py`)
- Explicit scoring → Metrics and history: publishes scores (evidence: `scripts/bts/evaluate.py`)
