# geresia/transport_builder architecture

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

- Interactive diagram: https://gitdiagram.com/geresia/transport_builder
- Repository: https://github.com/geresia/transport_builder

## Overview

Transport Builder is a railway planning and management game whose regional CityPack data supplies the setting. The principal workflow is to inspect demand and existing rail, draw a service proposal, assess feasibility and commercial terms, deliver construction and fleet/depot preparations, then operate passenger services and reinvest. The sampled sources show separation between map-derived spatial facts and management decisions, plus the demand model and application entry point. README capabilities cover additional tendering, finance, procurement, and commissioning stages; their internal wiring is not established by the excerpts.

Main entry points: [`transitline/engine/src/main.mjs`](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/main.mjs) (Game application), [`transitline/engine/src/simulation.mjs`](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/simulation.mjs) (Passenger simulation), [`transitline/engine/src/management/construction.mjs`](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/management/construction.mjs) (Project delivery), [`transitline/engine/src/map/map-input-pipeline.mjs`](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/map/map-input-pipeline.mjs) (Map interactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_planning["Planning and map"]
  node_demand["Passenger demand<br/>[demand-engine.mjs]"]
  node_mapplan["Route planning geometry<br/>[plan-geometry.mjs]"]
  node_serviceplan["Service plan geometry"]
  node_railgeometry["Rail capacity geometry"]
  node_mapui["Map interactions"]
  node_projection["Geographic projection<br/>[projection.mjs]"]
end

subgraph group_management["Company management"]
  node_contracts["Tenders and contracts"]
  node_construction["Project delivery<br/>[construction.mjs]"]
  node_finance["Company finance<br/>[finance.mjs]"]
  node_fleet["Fleet and depots<br/>[rolling-stock.mjs]"]
  node_operations["Rail operations<br/>[operations.mjs]"]
end

subgraph group_runtime["Simulation runtime"]
  node_app["Game application<br/>[main.mjs]"]
  node_state["Game state<br/>[state.mjs]"]
  node_simulation["Passenger simulation<br/>[simulation.mjs]"]
end

subgraph group_regional["Regional data"]
  node_citypack["CityPack input<br/>[pack.mjs]"]
end

node_player(("Player"))

node_player -->|"plays"| node_app
node_app -->|"loads"| node_citypack
node_app -->|"uses"| node_demand
node_app -->|"uses"| node_state
node_app -->|"wires"| node_mapui
node_player -->|"draws proposals"| node_mapui
node_mapui -.->|"produces inputs"| node_mapplan
node_mapplan -->|"measures distances"| node_projection
node_serviceplan -.->|"reads spatial facts"| node_railgeometry
node_player -->|"reviews bids"| node_contracts
node_contracts -->|"awards work"| node_construction
node_construction -->|"incurs project costs"| node_finance
node_construction -->|"coordinates preparation"| node_fleet
node_fleet -->|"supplies trains"| node_operations
node_operations -.->|"runs services"| node_simulation
node_demand -.->|"supplies trip model"| node_simulation
node_app -.->|"runs"| node_simulation
node_state -.->|"provides state"| node_simulation

click node_app "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/main.mjs"
click node_citypack "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/pack.mjs"
click node_demand "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/demand-engine.mjs"
click node_mapplan "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/map/plan-geometry.mjs"
click node_serviceplan "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/map/service-plan-geometry.mjs"
click node_railgeometry "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/map/rail-capacity-geometry.mjs"
click node_mapui "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/map/map-input-pipeline.mjs"
click node_contracts "https://github.com/geresia/transport_builder/tree/master/transitline/engine/src/management"
click node_construction "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/management/construction.mjs"
click node_finance "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/management/finance.mjs"
click node_fleet "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/management/rolling-stock.mjs"
click node_operations "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/management/operations.mjs"
click node_state "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/state.mjs"
click node_simulation "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/simulation.mjs"
click node_projection "https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/projection.mjs"

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_demand,node_mapplan,node_serviceplan,node_railgeometry,node_mapui,node_projection toneBlue
class node_contracts,node_construction,node_finance,node_fleet,node_operations toneAmber
class node_app,node_state,node_simulation toneMint
class node_citypack toneRose
class node_player toneIndigo
```

## Components

### Planning and map

- [Passenger demand](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/demand-engine.mjs): `transitline/engine/src/demand-engine.mjs`
- [Route planning geometry](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/map/plan-geometry.mjs): `transitline/engine/src/map/plan-geometry.mjs`
- [Service plan geometry](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/map/service-plan-geometry.mjs): `transitline/engine/src/map/service-plan-geometry.mjs`
- [Rail capacity geometry](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/map/rail-capacity-geometry.mjs): `transitline/engine/src/map/rail-capacity-geometry.mjs`
- [Map interactions](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/map/map-input-pipeline.mjs): `transitline/engine/src/map/map-input-pipeline.mjs`
- [Geographic projection](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/projection.mjs): `transitline/engine/src/projection.mjs`

### Company management

- [Tenders and contracts](https://github.com/geresia/transport_builder/tree/master/transitline/engine/src/management): `transitline/engine/src/management`
- [Project delivery](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/management/construction.mjs): `transitline/engine/src/management/construction.mjs`
- [Company finance](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/management/finance.mjs): `transitline/engine/src/management/finance.mjs`
- [Fleet and depots](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/management/rolling-stock.mjs): `transitline/engine/src/management/rolling-stock.mjs`
- [Rail operations](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/management/operations.mjs): `transitline/engine/src/management/operations.mjs`

### Simulation runtime

- [Game application](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/main.mjs): `transitline/engine/src/main.mjs`
- [Game state](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/state.mjs): `transitline/engine/src/state.mjs`
- [Passenger simulation](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/simulation.mjs): `transitline/engine/src/simulation.mjs`

### Regional data

- [CityPack input](https://github.com/geresia/transport_builder/blob/master/transitline/engine/src/pack.mjs): `transitline/engine/src/pack.mjs`

### Other components

- **Player**

## Connections

- Player → Game application: plays (evidence: `README.md`)
- Game application → CityPack input: loads (evidence: `transitline/engine/src/main.mjs`)
- Game application → Passenger demand: uses (evidence: `transitline/engine/src/main.mjs`)
- Game application → Game state: uses (evidence: `transitline/engine/src/main.mjs`)
- Game application → Map interactions: wires (evidence: `transitline/engine/src/main.mjs`)
- Player → Map interactions: draws proposals (evidence: `README.md`)
- Map interactions → Route planning geometry: produces inputs
- Route planning geometry → Geographic projection: measures distances (evidence: `transitline/engine/src/map/plan-geometry.mjs`)
- Service plan geometry → Rail capacity geometry: reads spatial facts (evidence: `transitline/engine/src/map/service-plan-geometry.mjs`)
- Player → Tenders and contracts: reviews bids (evidence: `README.md`)
- Tenders and contracts → Project delivery: awards work (evidence: `README.md`)
- Project delivery → Company finance: incurs project costs (evidence: `README.md`)
- Project delivery → Fleet and depots: coordinates preparation (evidence: `README.md`)
- Fleet and depots → Rail operations: supplies trains (evidence: `README.md`)
- Rail operations → Passenger simulation: runs services
- Passenger demand → Passenger simulation: supplies trip model
- Game application → Passenger simulation: runs
- Game state → Passenger simulation: provides state
