# trynmaps/metrics-mvp architecture

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

- Interactive diagram: https://gitdiagram.com/trynmaps/metrics-mvp
- Repository: https://github.com/trynmaps/metrics-mvp

## Overview

OpenTransit Metrics is a transit-performance analysis application for riders, advocates, and planners. Users select an agency, route, dates, and time range; the frontend requests metrics and presents service frequency, on-time performance, trip and wait times, and route maps. A separate isochrone experience explores reachable areas. Backend processing derives statistics from historical vehicle arrivals and schedules, while route configuration and public S3 data support the application. Some backend and frontend subsystems are represented from README or index evidence; their internal calls are not inferred where excerpts do not show them.

Main entry points: [`backend/models/metrics.py`](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/metrics.py) (Metric calculations), [`frontend/src/screens/RouteScreen.jsx`](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/screens/RouteScreen.jsx) (Route metrics view), [`backend/compute_stats.py`](https://github.com/trynmaps/metrics-mvp/blob/master/backend/compute_stats.py) (Statistics computation), [`frontend/src/actions/index.js`](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/actions/index.js) (Data requests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["App navigation<br/>[App.jsx]"]
  node_routeview["Route metrics view<br/>[RouteScreen.jsx]"]
  node_controls["Metric controls<br/>[ControlPanel.jsx]"]
  node_maps["Stop map<br/>[MapStops.jsx]"]
  node_charts["Performance charts"]
  node_isochrone["Reachability map<br/>[Isochrone.jsx]"]
  node_iso_worker["Isochrone worker"]
  node_actions["Data requests<br/>[index.js]"]
  node_state["Application state<br/>[index.js]"]
end

subgraph group_analytics["Metrics backend"]
  node_trip_times["Trip-time analysis<br/>[trip_times.py]"]
  node_wait_times["Wait-time analysis<br/>[wait_times.py]"]
  node_metrics["Metric calculations<br/>[metrics.py]"]
  node_stats_job["Statistics computation<br/>[compute_stats.py]"]
end

subgraph group_transitdata["Transit data"]
  node_arrival_history[("Historical arrivals<br/>[arrival_history.py]")]
  node_timetables[("Timetables<br/>[timetables.py]")]
  node_gtfs["GTFS schedules<br/>[gtfs.py]"]
  node_precomputed[("Cached statistics")]
end

subgraph group_configapi["Configuration and API"]
  node_graphql["Metrics GraphQL<br/>[schema.py]"]
  node_route_config["Agency and route config<br/>[config.py]"]
  node_route_definitions["Route definitions<br/>[routeconfig.py]"]
end

node_user(("Transit user"))
node_orion["Vehicle data collector"]
node_trynapi["Tryn API"]
node_s3[("Public S3 data")]

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_routeview
node_app -->|"routes to"| node_isochrone
node_routeview -->|"renders"| node_controls
node_routeview -->|"renders"| node_maps
node_routeview -->|"dispatches"| node_actions
node_routeview -->|"renders"| node_charts
node_isochrone -.->|"delegates"| node_iso_worker
node_actions -->|"requests metrics"| node_graphql
node_actions -.->|"dispatches updates"| node_state
node_actions -.->|"fetches data"| node_s3
node_graphql -.->|"provides metrics"| node_metrics
node_metrics -->|"loads date keys"| node_timetables
node_metrics -->|"uses history"| node_arrival_history
node_metrics -->|"uses trip data"| node_trip_times
node_metrics -->|"uses wait data"| node_wait_times
node_metrics -->|"uses cached stats"| node_precomputed
node_stats_job -->|"computes stats"| node_wait_times
node_stats_job -.->|"reads history"| node_arrival_history
node_stats_job -.->|"reads schedules"| node_timetables
node_stats_job -.->|"writes stats"| node_precomputed
node_gtfs -->|"stores schedule data"| node_s3
node_arrival_history -->|"loads history"| node_s3
node_timetables -->|"loads schedules"| node_s3
node_precomputed -.->|"stores statistics"| node_s3
node_route_config -->|"loads routes"| node_route_definitions
node_orion -->|"stores vehicle data"| node_s3
node_trynapi -->|"reads vehicle data"| node_s3
node_route_config -.->|"configures schedules"| node_gtfs

click node_app "https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/App.jsx"
click node_routeview "https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/screens/RouteScreen.jsx"
click node_controls "https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/components/ControlPanel.jsx"
click node_maps "https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/components/MapStops.jsx"
click node_charts "https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/components/ServiceFrequencyHistogram.jsx"
click node_isochrone "https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/screens/Isochrone.jsx"
click node_iso_worker "https://github.com/trynmaps/metrics-mvp/blob/master/frontend/public/isochrone-worker.js"
click node_actions "https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/actions/index.js"
click node_state "https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/reducers/index.js"
click node_graphql "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/schema.py"
click node_route_config "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/config.py"
click node_route_definitions "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/routeconfig.py"
click node_arrival_history "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/arrival_history.py"
click node_timetables "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/timetables.py"
click node_gtfs "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/gtfs.py"
click node_trip_times "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/trip_times.py"
click node_wait_times "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/wait_times.py"
click node_metrics "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/metrics.py"
click node_stats_job "https://github.com/trynmaps/metrics-mvp/blob/master/backend/compute_stats.py"
click node_precomputed "https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/precomputed_stats.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_app,node_routeview,node_controls,node_maps,node_charts,node_isochrone,node_iso_worker,node_actions,node_state,node_user toneBlue
class node_trip_times,node_wait_times,node_metrics,node_stats_job,node_s3 toneAmber
class node_arrival_history,node_timetables,node_gtfs,node_precomputed,node_trynapi toneMint
class node_graphql,node_route_config,node_route_definitions toneRose
class node_orion toneIndigo
```

## Components

### Web application

- [App navigation](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Route metrics view](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/screens/RouteScreen.jsx): `frontend/src/screens/RouteScreen.jsx`
- [Metric controls](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/components/ControlPanel.jsx): `frontend/src/components/ControlPanel.jsx`
- [Stop map](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/components/MapStops.jsx): `frontend/src/components/MapStops.jsx`
- [Performance charts](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/components/ServiceFrequencyHistogram.jsx): `frontend/src/components/ServiceFrequencyHistogram.jsx`
- [Reachability map](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/screens/Isochrone.jsx): `frontend/src/screens/Isochrone.jsx`
- [Isochrone worker](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/public/isochrone-worker.js): `frontend/public/isochrone-worker.js`
- [Data requests](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/actions/index.js): `frontend/src/actions/index.js`
- [Application state](https://github.com/trynmaps/metrics-mvp/blob/master/frontend/src/reducers/index.js): `frontend/src/reducers/index.js`

### Metrics backend

- [Trip-time analysis](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/trip_times.py): `backend/models/trip_times.py`
- [Wait-time analysis](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/wait_times.py): `backend/models/wait_times.py`
- [Metric calculations](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/metrics.py): `backend/models/metrics.py`
- [Statistics computation](https://github.com/trynmaps/metrics-mvp/blob/master/backend/compute_stats.py): `backend/compute_stats.py`

### Transit data

- [Historical arrivals](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/arrival_history.py): `backend/models/arrival_history.py`
- [Timetables](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/timetables.py): `backend/models/timetables.py`
- [GTFS schedules](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/gtfs.py): `backend/models/gtfs.py`
- [Cached statistics](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/precomputed_stats.py): `backend/models/precomputed_stats.py`

### Configuration and API

- [Metrics GraphQL](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/schema.py): `backend/models/schema.py`
- [Agency and route config](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/config.py): `backend/models/config.py`
- [Route definitions](https://github.com/trynmaps/metrics-mvp/blob/master/backend/models/routeconfig.py): `backend/models/routeconfig.py`

### Other components

- **Transit user**
- **Vehicle data collector**
- **Tryn API**
- **Public S3 data**

## Connections

- Transit user → App navigation: opens
- App navigation → Route metrics view: routes to (evidence: `frontend/src/App.jsx`)
- App navigation → Reachability map: routes to (evidence: `frontend/src/App.jsx`)
- Route metrics view → Metric controls: renders (evidence: `frontend/src/screens/RouteScreen.jsx`)
- Route metrics view → Stop map: renders (evidence: `frontend/src/screens/RouteScreen.jsx`)
- Route metrics view → Data requests: dispatches (evidence: `frontend/src/screens/RouteScreen.jsx`)
- Route metrics view → Performance charts: renders (evidence: `frontend/src/screens/RouteScreen.jsx`)
- Reachability map → Isochrone worker: delegates
- Data requests → Metrics GraphQL: requests metrics (evidence: `frontend/src/actions/index.js`)
- Data requests → Application state: dispatches updates
- Data requests → Public S3 data: fetches data
- Metrics GraphQL → Metric calculations: provides metrics
- Metric calculations → Timetables: loads date keys (evidence: `backend/models/metrics.py`)
- Metric calculations → Historical arrivals: uses history (evidence: `backend/models/metrics.py`)
- Metric calculations → Trip-time analysis: uses trip data (evidence: `backend/models/metrics.py`)
- Metric calculations → Wait-time analysis: uses wait data (evidence: `backend/models/metrics.py`)
- Metric calculations → Cached statistics: uses cached stats (evidence: `backend/models/metrics.py`)
- Statistics computation → Wait-time analysis: computes stats (evidence: `backend/compute_stats.py`)
- Statistics computation → Historical arrivals: reads history (evidence: `backend/compute_stats.py`)
- Statistics computation → Timetables: reads schedules (evidence: `backend/compute_stats.py`)
- Statistics computation → Cached statistics: writes stats (evidence: `backend/compute_stats.py`)
- GTFS schedules → Public S3 data: stores schedule data (evidence: `backend/models/gtfs.py`)
- Historical arrivals → Public S3 data: loads history (evidence: `backend/models/arrival_history.py`)
- Timetables → Public S3 data: loads schedules (evidence: `backend/models/timetables.py`)
- Cached statistics → Public S3 data: stores statistics
- Agency and route config → Route definitions: loads routes (evidence: `backend/models/config.py`)
- Vehicle data collector → Public S3 data: stores vehicle data
- Tryn API → Public S3 data: reads vehicle data
- Agency and route config → GTFS schedules: configures schedules (evidence: `backend/models/gtfs.py`)
