# ahzengyang/mbta-weather-delay architecture

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

- Interactive diagram: https://gitdiagram.com/ahzengyang/mbta-weather-delay
- Repository: https://github.com/ahzengyang/mbta-weather-delay

## Overview

This repository collects MBTA delay, station, ridership, and weather data, stores processed data in Google Cloud Storage, and exposes API endpoints alongside a Streamlit dashboard. The principal analytical workflow is to acquire and normalize each source, join the hourly records by station and time, then explore delay/weather relationships with station and time filters. The README describes the intended dashboard capabilities; the Streamlit entry point is only 0.1 KB, so its implementation is not visible. Some API wiring is also omitted from the excerpts, and those connections are left out or marked unverified.

Main entry points: [`fastapi/fastapi_functions/weather_openmeteo.py`](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/weather_openmeteo.py) (Weather fetch), [`fastapi/combine_sources.py`](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/combine_sources.py) (Hourly source join), [`fastapi/mbta_weather_api.py`](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/mbta_weather_api.py) (Data API), [`fastapi/fastapi_functions/gse_clean.py`](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/gse_clean.py) (Hourly ridership)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Data collection"]
  node_lamp["LAMP delays"]
  node_gtfs["GTFS stations<br/>[station_data.py]"]
  node_arcgis["ArcGIS ridership<br/>[gse_fetch.py]"]
  node_weather["Weather fetch"]
end

subgraph group_processing["Processing"]
  node_stationtable["Station metadata<br/>[station_data.py]"]
  node_ridership["Hourly ridership<br/>[gse_clean.py]"]
  node_stationids["Station IDs<br/>[stations.py]"]
  node_ridershiprun["Ridership pipeline<br/>[run_pipeline.py]"]
  node_delaypanel["Delay panel"]
  node_join["Hourly source join<br/>[combine_sources.py]"]
end

subgraph group_platform["API and storage"]
  node_config["Shared configuration<br/>[user_definition.py]"]
  node_gcs[("GCS storage<br/>[gcs.py]")]
  node_stationapi["Station upload"]
  node_api["Data API"]
end

subgraph group_analysis["Analysis and exploration"]
  node_dashboard["Dashboard<br/>[main.py]"]
end

node_mbta(("MBTA data"))
node_openmeteo(("Open-Meteo"))
node_analyst(("Analyst"))

node_mbta -->|"publishes delays"| node_lamp
node_mbta -->|"publishes GTFS"| node_gtfs
node_arcgis -->|"provides entries"| node_ridership
node_openmeteo -->|"provides weather"| node_weather
node_gtfs -->|"downloads feed"| node_stationtable
node_stationtable -->|"builds station table"| node_api
node_stationids -->|"filters stations"| node_ridership
node_ridershiprun -->|"cleans hourly entries"| node_ridership
node_ridershiprun -->|"uploads CSV"| node_gcs
node_lamp -->|"derives hourly panel"| node_delaypanel
node_weather -->|"stores processed weather"| node_gcs
node_config -->|"configures fetch"| node_weather
node_delaypanel -->|"supplies delay data"| node_join
node_stationtable -->|"supplies station data"| node_join
node_ridership -->|"supplies ridership"| node_join
node_weather -->|"supplies weather"| node_join
node_api -->|"fetches weather"| node_weather
node_api -->|"uploads station data"| node_gcs
node_analyst -->|"explores results"| node_dashboard
node_dashboard -.->|"requests data"| node_api
node_join -.->|"stores combined data"| node_gcs

click node_lamp "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/source1_mbta_lamp_delay.py"
click node_gtfs "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/station_data.py"
click node_arcgis "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/gse_fetch.py"
click node_weather "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/weather_openmeteo.py"
click node_stationtable "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/station_data.py"
click node_ridership "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/gse_clean.py"
click node_stationids "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/stations.py"
click node_ridershiprun "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/run_pipeline.py"
click node_delaypanel "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/source1_mbta_lamp_delay.py"
click node_join "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/combine_sources.py"
click node_config "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/user_definition.py"
click node_gcs "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/gcs.py"
click node_stationapi "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/mbta_weather_api.py"
click node_api "https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/mbta_weather_api.py"
click node_dashboard "https://github.com/ahzengyang/mbta-weather-delay/blob/main/streamlit/main.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_lamp,node_gtfs,node_arcgis,node_weather toneBlue
class node_stationtable,node_ridership,node_stationids,node_ridershiprun,node_delaypanel,node_join toneAmber
class node_config,node_gcs,node_stationapi,node_api toneMint
class node_dashboard toneRose
class node_mbta,node_openmeteo,node_analyst toneIndigo
```

## Components

### Data collection

- [LAMP delays](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/source1_mbta_lamp_delay.py): `fastapi/fastapi_functions/source1_mbta_lamp_delay.py`
- [GTFS stations](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/station_data.py): `fastapi/fastapi_functions/station_data.py`
- [ArcGIS ridership](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/gse_fetch.py): `fastapi/fastapi_functions/gse_fetch.py`
- [Weather fetch](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/weather_openmeteo.py): `fastapi/fastapi_functions/weather_openmeteo.py`

### Processing

- [Station metadata](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/station_data.py): `fastapi/fastapi_functions/station_data.py`
- [Hourly ridership](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/gse_clean.py): `fastapi/fastapi_functions/gse_clean.py`
- [Station IDs](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/stations.py): `fastapi/fastapi_functions/stations.py`
- [Ridership pipeline](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/run_pipeline.py): `fastapi/fastapi_functions/run_pipeline.py`
- [Delay panel](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/source1_mbta_lamp_delay.py): `fastapi/fastapi_functions/source1_mbta_lamp_delay.py`
- [Hourly source join](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/combine_sources.py): `fastapi/combine_sources.py`

### API and storage

- [Shared configuration](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/user_definition.py): `fastapi/fastapi_functions/user_definition.py`
- [GCS storage](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/fastapi_functions/gcs.py): `fastapi/fastapi_functions/gcs.py`
- [Station upload](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/mbta_weather_api.py): `fastapi/mbta_weather_api.py`
- [Data API](https://github.com/ahzengyang/mbta-weather-delay/blob/main/fastapi/mbta_weather_api.py): `fastapi/mbta_weather_api.py`

### Analysis and exploration

- [Dashboard](https://github.com/ahzengyang/mbta-weather-delay/blob/main/streamlit/main.py): `streamlit/main.py`

### Other components

- **MBTA data**
- **Open-Meteo**
- **Analyst**

## Connections

- MBTA data → LAMP delays: publishes delays (evidence: `README.md`)
- MBTA data → GTFS stations: publishes GTFS (evidence: `README.md`)
- ArcGIS ridership → Hourly ridership: provides entries (evidence: `fastapi/fastapi_functions/gse_fetch.py`)
- Open-Meteo → Weather fetch: provides weather (evidence: `fastapi/fastapi_functions/weather_openmeteo.py`)
- GTFS stations → Station metadata: downloads feed (evidence: `fastapi/mbta_weather_api.py`)
- Station metadata → Data API: builds station table (evidence: `fastapi/mbta_weather_api.py`)
- Station IDs → Hourly ridership: filters stations (evidence: `fastapi/fastapi_functions/gse_clean.py`)
- Ridership pipeline → Hourly ridership: cleans hourly entries (evidence: `fastapi/fastapi_functions/run_pipeline.py`)
- Ridership pipeline → GCS storage: uploads CSV (evidence: `fastapi/fastapi_functions/run_pipeline.py`)
- LAMP delays → Delay panel: derives hourly panel (evidence: `fastapi/fastapi_functions/source1_mbta_lamp_delay.py`)
- Weather fetch → GCS storage: stores processed weather (evidence: `fastapi/fastapi_functions/weather_openmeteo.py`)
- Shared configuration → Weather fetch: configures fetch (evidence: `fastapi/fastapi_functions/weather_openmeteo.py`)
- Delay panel → Hourly source join: supplies delay data (evidence: `fastapi/combine_sources.py`)
- Station metadata → Hourly source join: supplies station data (evidence: `fastapi/combine_sources.py`)
- Hourly ridership → Hourly source join: supplies ridership (evidence: `fastapi/combine_sources.py`)
- Weather fetch → Hourly source join: supplies weather (evidence: `fastapi/combine_sources.py`)
- Data API → Weather fetch: fetches weather (evidence: `fastapi/mbta_weather_api.py`)
- Data API → GCS storage: uploads station data (evidence: `fastapi/mbta_weather_api.py`)
- Analyst → Dashboard: explores results (evidence: `README.md`)
- Dashboard → Data API: requests data
- Hourly source join → GCS storage: stores combined data
