# sijan2006/ktm-transport-simulator architecture

> Architecture diagram of the GitHub repository sijan2006/ktm-transport-simulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sijan2006/ktm-transport-simulator
- Repository: https://github.com/sijan2006/ktm-transport-simulator

## Overview

This is a desktop public-transport network simulator and route planner. The workflow initializes stops, routes and vehicles, advances vehicle positions in simulated time, accepts a source and destination, compares direct and one-transfer plans, then displays and highlights the selected journey on the network map. The internal model layer represents stops, routes, vehicles and journey plans. Source excerpts show the main calls; configuration wiring is visible in the loader and entry point, while no README documents additional capabilities.

Main entry points: [`engine/transport_network.py`](https://github.com/sijan2006/ktm-transport-simulator/blob/main/engine/transport_network.py) (Network loader), [`engine/routing_engine.py`](https://github.com/sijan2006/ktm-transport-simulator/blob/main/engine/routing_engine.py) (Route search), [`gui/app.py`](https://github.com/sijan2006/ktm-transport-simulator/blob/main/gui/app.py) (Map and planner UI), [`engine/simulation_engine.py`](https://github.com/sijan2006/ktm-transport-simulator/blob/main/engine/simulation_engine.py) (Time simulation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["Application startup"]
  node_main["Application entry<br/>[main.py]"]
  node_stops_config["Stop data<br/>[stops.json]"]
  node_routes_config["Route data<br/>[routes.json]"]
end

subgraph group_network["Transport network"]
  node_network_engine["Network loader"]
end

subgraph group_runtime["Simulation and routing"]
  node_simulation["Time simulation"]
  node_routing["Route search<br/>[routing_engine.py]"]
end

subgraph group_interface["Desktop interface"]
  node_app["Map and planner UI<br/>[app.py]"]
end

subgraph group_models["Domain models"]
  node_stop["Stop<br/>[stop.py]"]
  node_route["Route<br/>[route.py]"]
  node_vehicle["Vehicle<br/>[vehicle.py]"]
  node_plan["Route plan<br/>[route_plan.py]"]
  node_leg["Journey leg<br/>[journey_leg.py]"]
end

node_user(("Planner user"))

node_user -->|"selects journey"| node_app
node_main -->|"initializes network"| node_network_engine
node_network_engine -->|"loads stops"| node_stops_config
node_network_engine -->|"loads routes"| node_routes_config
node_main -->|"creates simulation"| node_simulation
node_main -->|"launches interface"| node_app
node_network_engine -->|"creates stops"| node_stop
node_network_engine -->|"builds routes"| node_route
node_network_engine -->|"spawns vehicles"| node_vehicle
node_route -->|"registers stops"| node_stop
node_vehicle -->|"moves along"| node_route
node_simulation -->|"gets vehicles"| node_network_engine
node_simulation -->|"advances movement"| node_vehicle
node_app -->|"ticks and reads time"| node_simulation
node_app -->|"reads network state"| node_network_engine
node_app -->|"requests best route"| node_routing
node_routing -->|"looks up stops and vehicles"| node_network_engine
node_routing -->|"gets peak multiplier"| node_simulation
node_routing -->|"estimates arrival"| node_vehicle
node_routing -->|"builds candidate plans"| node_plan
node_routing -->|"creates journey legs"| node_leg
node_plan -->|"aggregates legs"| node_leg
node_app -->|"displays and highlights"| node_plan

click node_main "https://github.com/sijan2006/ktm-transport-simulator/blob/main/main.py"
click node_stops_config "https://github.com/sijan2006/ktm-transport-simulator/blob/main/config/stops.json"
click node_routes_config "https://github.com/sijan2006/ktm-transport-simulator/blob/main/config/routes.json"
click node_network_engine "https://github.com/sijan2006/ktm-transport-simulator/blob/main/engine/transport_network.py"
click node_simulation "https://github.com/sijan2006/ktm-transport-simulator/blob/main/engine/simulation_engine.py"
click node_routing "https://github.com/sijan2006/ktm-transport-simulator/blob/main/engine/routing_engine.py"
click node_app "https://github.com/sijan2006/ktm-transport-simulator/blob/main/gui/app.py"
click node_stop "https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/stop.py"
click node_route "https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/route.py"
click node_vehicle "https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/vehicle.py"
click node_plan "https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/route_plan.py"
click node_leg "https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/journey_leg.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_main,node_stops_config,node_routes_config,node_user toneBlue
class node_network_engine toneAmber
class node_simulation,node_routing toneMint
class node_app toneRose
class node_stop,node_route,node_vehicle,node_plan,node_leg toneIndigo
```

## Components

### Application startup

- [Application entry](https://github.com/sijan2006/ktm-transport-simulator/blob/main/main.py): `main.py`
- [Stop data](https://github.com/sijan2006/ktm-transport-simulator/blob/main/config/stops.json): `config/stops.json`
- [Route data](https://github.com/sijan2006/ktm-transport-simulator/blob/main/config/routes.json): `config/routes.json`

### Transport network

- [Network loader](https://github.com/sijan2006/ktm-transport-simulator/blob/main/engine/transport_network.py): `engine/transport_network.py`

### Simulation and routing

- [Time simulation](https://github.com/sijan2006/ktm-transport-simulator/blob/main/engine/simulation_engine.py): `engine/simulation_engine.py`
- [Route search](https://github.com/sijan2006/ktm-transport-simulator/blob/main/engine/routing_engine.py): `engine/routing_engine.py`

### Desktop interface

- [Map and planner UI](https://github.com/sijan2006/ktm-transport-simulator/blob/main/gui/app.py): `gui/app.py`

### Domain models

- [Stop](https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/stop.py): `models/stop.py`
- [Route](https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/route.py): `models/route.py`
- [Vehicle](https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/vehicle.py): `models/vehicle.py`
- [Route plan](https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/route_plan.py): `models/route_plan.py`
- [Journey leg](https://github.com/sijan2006/ktm-transport-simulator/blob/main/models/journey_leg.py): `models/journey_leg.py`

### Other components

- **Planner user**

## Connections

- Planner user → Map and planner UI: selects journey (evidence: `gui/app.py`)
- Application entry → Network loader: initializes network (evidence: `main.py`)
- Network loader → Stop data: loads stops (evidence: `engine/transport_network.py`)
- Network loader → Route data: loads routes (evidence: `engine/transport_network.py`)
- Application entry → Time simulation: creates simulation (evidence: `main.py`)
- Application entry → Map and planner UI: launches interface (evidence: `main.py`)
- Network loader → Stop: creates stops (evidence: `engine/transport_network.py`)
- Network loader → Route: builds routes (evidence: `engine/transport_network.py`)
- Network loader → Vehicle: spawns vehicles (evidence: `engine/transport_network.py`)
- Route → Stop: registers stops (evidence: `models/route.py`)
- Vehicle → Route: moves along (evidence: `models/vehicle.py`)
- Time simulation → Network loader: gets vehicles (evidence: `engine/simulation_engine.py`)
- Time simulation → Vehicle: advances movement (evidence: `engine/simulation_engine.py`)
- Map and planner UI → Time simulation: ticks and reads time (evidence: `gui/app.py`)
- Map and planner UI → Network loader: reads network state (evidence: `gui/app.py`)
- Map and planner UI → Route search: requests best route (evidence: `gui/app.py`)
- Route search → Network loader: looks up stops and vehicles (evidence: `engine/routing_engine.py`)
- Route search → Time simulation: gets peak multiplier (evidence: `engine/routing_engine.py`)
- Route search → Vehicle: estimates arrival (evidence: `engine/routing_engine.py`)
- Route search → Route plan: builds candidate plans (evidence: `engine/routing_engine.py`)
- Route search → Journey leg: creates journey legs (evidence: `engine/routing_engine.py`)
- Route plan → Journey leg: aggregates legs (evidence: `models/route_plan.py`)
- Map and planner UI → Route plan: displays and highlights (evidence: `gui/app.py`)
