# mbta/dotcom architecture

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

- Interactive diagram: https://gitdiagram.com/mbta/dotcom
- Repository: https://github.com/mbta/dotcom

## Overview

Dotcom is the MBTA’s public transit website. A rider request enters the Phoenix router, reaches a page or live interface, and is resolved using schedules, stops, fares, CMS content, search, or real-time predictions before HTML, JSON, or PubSub updates return to the browser. The tree and excerpts clearly show these boundaries; several controller integrations and alert paths were not sampled, so those relationships are intentionally conservative.

Main entry points: [`lib/dotcom_web/router.ex`](https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/router.ex) (Phoenix Router), [`lib/dotcom_web/controllers/stop_controller.ex`](https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/controllers/stop_controller.ex) (Stop Page), [`lib/dotcom/predictions/manager.ex`](https://github.com/mbta/dotcom/blob/main/lib/dotcom/predictions/manager.ex) (Prediction Manager), [`lib/dotcom/upcoming_departures/server.ex`](https://github.com/mbta/dotcom/blob/main/lib/dotcom/upcoming_departures/server.ex) (Departure Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web Experience"]
  node_router["Phoenix Router<br/>[router.ex]"]
  node_timetable["Timetable Page"]
  node_line_page["Line Page<br/>[line_controller.ex]"]
  node_stop_page["Stop Page<br/>[stop_controller.ex]"]
  node_trip_planner["Trip Planner"]
  node_support["Support Form"]
end

subgraph group_transit["Transit Information"]
  node_timetable_data["Timetable Data<br/>[repo.ex]"]
  node_stops_data["Stop Data<br/>[repo.ex]"]
  node_route_data["Route Data<br/>[repo.ex]"]
  node_service_patterns["Service Patterns"]
  node_open_trip_planner["OTP Adapter"]
end

subgraph group_realtime["Realtime Operations"]
  node_predictions["Prediction Manager<br/>[manager.ex]"]
  node_prediction_events["Prediction Events"]
  node_departures["Departure Server<br/>[server.ex]"]
  node_pubsub_endpoint["Phoenix Endpoint<br/>[endpoint.ex]"]
end

subgraph group_content["Content and Search"]
  node_search["Search Service<br/>[search_service.ex]"]
  node_algolia_client["Algolia Client<br/>[algolia_client.ex]"]
  node_cms_api["CMS API<br/>[api.ex]"]
  node_feedback_repo[("Feedback Store<br/>[repo.ex]")]
end

node_rider(("Rider"))
node_otp_service["OpenTripPlanner"]
node_algolia["Algolia"]
node_cms_service["CMS Service"]
node_mbta_api["MBTA V3 API"]

node_rider -->|"requests"| node_router
node_router -->|"dispatches"| node_timetable
node_router -->|"dispatches"| node_line_page
node_router -->|"dispatches"| node_stop_page
node_router -->|"dispatches"| node_trip_planner
node_router -->|"dispatches"| node_support
node_timetable -->|"reads schedules"| node_timetable_data
node_timetable -->|"reads stops"| node_stops_data
node_line_page -->|"loads services"| node_service_patterns
node_stop_page -->|"reads stop"| node_stops_data
node_stop_page -->|"loads routes"| node_route_data
node_stop_page -->|"gets predictions"| node_predictions
node_trip_planner -->|"plans trip"| node_open_trip_planner
node_open_trip_planner -.->|"queries routes"| node_otp_service
node_support -->|"sends ticket"| node_feedback_repo
node_predictions -->|"starts events"| node_prediction_events
node_predictions -->|"broadcasts updates"| node_pubsub_endpoint
node_departures -->|"subscribes"| node_predictions
node_departures -->|"loads schedules"| node_timetable_data
node_departures -->|"broadcasts departures"| node_pubsub_endpoint
node_search -->|"runs search"| node_algolia_client
node_algolia_client -->|"queries indexes"| node_algolia
node_cms_api -->|"fetches content"| node_cms_service
node_cms_api -->|"loads pages"| node_cms_service
node_mbta_api -.->|"provides routes"| node_route_data

click node_router "https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/router.ex"
click node_timetable "https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/controllers/schedule/timetable_controller.ex"
click node_line_page "https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/controllers/schedule/line_controller.ex"
click node_stop_page "https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/controllers/stop_controller.ex"
click node_trip_planner "https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/live/trip_planner_live.ex"
click node_support "https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/controllers/customer_support_controller.ex"
click node_timetable_data "https://github.com/mbta/dotcom/blob/main/lib/schedules/repo.ex"
click node_stops_data "https://github.com/mbta/dotcom/blob/main/lib/stops/repo.ex"
click node_route_data "https://github.com/mbta/dotcom/blob/main/lib/routes/repo.ex"
click node_service_patterns "https://github.com/mbta/dotcom/blob/main/lib/dotcom/service_patterns.ex"
click node_open_trip_planner "https://github.com/mbta/dotcom/blob/main/lib/dotcom/trip_plan/open_trip_planner.ex"
click node_predictions "https://github.com/mbta/dotcom/blob/main/lib/dotcom/predictions/manager.ex"
click node_prediction_events "https://github.com/mbta/dotcom/blob/main/lib/dotcom/predictions/event_supervisor.ex"
click node_departures "https://github.com/mbta/dotcom/blob/main/lib/dotcom/upcoming_departures/server.ex"
click node_pubsub_endpoint "https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/endpoint.ex"
click node_search "https://github.com/mbta/dotcom/blob/main/lib/dotcom/search_service.ex"
click node_algolia_client "https://github.com/mbta/dotcom/blob/main/lib/algolia_client.ex"
click node_cms_api "https://github.com/mbta/dotcom/blob/main/lib/cms/api.ex"
click node_feedback_repo "https://github.com/mbta/dotcom/blob/main/lib/feedback/repo.ex"

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_router,node_timetable,node_line_page,node_stop_page,node_trip_planner,node_support toneBlue
class node_timetable_data,node_stops_data,node_route_data,node_service_patterns,node_open_trip_planner toneAmber
class node_predictions,node_prediction_events,node_departures,node_pubsub_endpoint,node_mbta_api toneMint
class node_search,node_algolia_client,node_cms_api,node_feedback_repo toneRose
class node_rider,node_otp_service,node_algolia,node_cms_service toneIndigo
```

## Components

### Web Experience

- [Phoenix Router](https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/router.ex): `lib/dotcom_web/router.ex`
- [Timetable Page](https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/controllers/schedule/timetable_controller.ex): `lib/dotcom_web/controllers/schedule/timetable_controller.ex`
- [Line Page](https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/controllers/schedule/line_controller.ex): `lib/dotcom_web/controllers/schedule/line_controller.ex`
- [Stop Page](https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/controllers/stop_controller.ex): `lib/dotcom_web/controllers/stop_controller.ex`
- [Trip Planner](https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/live/trip_planner_live.ex): `lib/dotcom_web/live/trip_planner_live.ex`
- [Support Form](https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/controllers/customer_support_controller.ex): `lib/dotcom_web/controllers/customer_support_controller.ex`

### Transit Information

- [Timetable Data](https://github.com/mbta/dotcom/blob/main/lib/schedules/repo.ex): `lib/schedules/repo.ex`
- [Stop Data](https://github.com/mbta/dotcom/blob/main/lib/stops/repo.ex): `lib/stops/repo.ex`
- [Route Data](https://github.com/mbta/dotcom/blob/main/lib/routes/repo.ex): `lib/routes/repo.ex`
- [Service Patterns](https://github.com/mbta/dotcom/blob/main/lib/dotcom/service_patterns.ex): `lib/dotcom/service_patterns.ex`
- [OTP Adapter](https://github.com/mbta/dotcom/blob/main/lib/dotcom/trip_plan/open_trip_planner.ex): `lib/dotcom/trip_plan/open_trip_planner.ex`

### Realtime Operations

- [Prediction Manager](https://github.com/mbta/dotcom/blob/main/lib/dotcom/predictions/manager.ex): `lib/dotcom/predictions/manager.ex`
- [Prediction Events](https://github.com/mbta/dotcom/blob/main/lib/dotcom/predictions/event_supervisor.ex): `lib/dotcom/predictions/event_supervisor.ex`
- [Departure Server](https://github.com/mbta/dotcom/blob/main/lib/dotcom/upcoming_departures/server.ex): `lib/dotcom/upcoming_departures/server.ex`
- [Phoenix Endpoint](https://github.com/mbta/dotcom/blob/main/lib/dotcom_web/endpoint.ex): `lib/dotcom_web/endpoint.ex`

### Content and Search

- [Search Service](https://github.com/mbta/dotcom/blob/main/lib/dotcom/search_service.ex): `lib/dotcom/search_service.ex`
- [Algolia Client](https://github.com/mbta/dotcom/blob/main/lib/algolia_client.ex): `lib/algolia_client.ex`
- [CMS API](https://github.com/mbta/dotcom/blob/main/lib/cms/api.ex): `lib/cms/api.ex`
- [Feedback Store](https://github.com/mbta/dotcom/blob/main/lib/feedback/repo.ex): `lib/feedback/repo.ex`

### Other components

- **Rider**
- **OpenTripPlanner**
- **Algolia**
- **CMS Service**
- **MBTA V3 API**

## Connections

- Rider → Phoenix Router: requests
- Phoenix Router → Timetable Page: dispatches
- Phoenix Router → Line Page: dispatches
- Phoenix Router → Stop Page: dispatches
- Phoenix Router → Trip Planner: dispatches
- Phoenix Router → Support Form: dispatches
- Timetable Page → Timetable Data: reads schedules
- Timetable Page → Stop Data: reads stops
- Line Page → Service Patterns: loads services
- Stop Page → Stop Data: reads stop
- Stop Page → Route Data: loads routes
- Stop Page → Prediction Manager: gets predictions
- Trip Planner → OTP Adapter: plans trip
- OTP Adapter → OpenTripPlanner: queries routes
- Support Form → Feedback Store: sends ticket
- Prediction Manager → Prediction Events: starts events
- Prediction Manager → Phoenix Endpoint: broadcasts updates
- Departure Server → Prediction Manager: subscribes
- Departure Server → Timetable Data: loads schedules
- Departure Server → Phoenix Endpoint: broadcasts departures
- Search Service → Algolia Client: runs search
- Algolia Client → Algolia: queries indexes
- CMS API → CMS Service: fetches content
- CMS API → CMS Service: loads pages
- MBTA V3 API → Route Data: provides routes
