# 210041258/cityflow-branch architecture

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

- Interactive diagram: https://gitdiagram.com/210041258/cityflow-branch
- Repository: https://github.com/210041258/cityflow-branch

## Overview

CityFlow is a microscopic traffic simulator with a C++ runtime and Python-facing API, surrounded by Python tools for network/scenario generation, replay visualization, and traffic-control or active-learning studies. The principal workflow is to load road-network and flow configuration, advance vehicles through the simulated network, and expose simulation state or replay output. The graph includes major research and tooling branches visible in the tree; with no README and incomplete excerpts, some subsystem links are intentionally omitted.

Main entry points: [`src/engine/engine.cpp`](https://github.com/210041258/cityflow-branch/blob/master/src/engine/engine.cpp) (Simulation engine), [`src/roadnet/roadnet.cpp`](https://github.com/210041258/cityflow-branch/blob/master/src/roadnet/roadnet.cpp) (Road network), [`src/vehicle/vehicle.cpp`](https://github.com/210041258/cityflow-branch/blob/master/src/vehicle/vehicle.cpp) (Vehicle dynamics), [`src/cityflow.cpp`](https://github.com/210041258/cityflow-branch/blob/master/src/cityflow.cpp) (Python API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Simulation runtime"]
  node_api["Python API<br/>[cityflow.cpp]"]
  node_engine["Simulation engine<br/>[engine.cpp]"]
  node_archive["State archive<br/>[archive.cpp]"]
  node_flow["Vehicle flows<br/>[flow.cpp]"]
  node_roadnet["Road network<br/>[roadnet.cpp]"]
  node_trafficlight["Traffic lights<br/>[trafficlight.cpp]"]
  node_vehicle["Vehicle dynamics<br/>[vehicle.cpp]"]
  node_router["Route planning<br/>[router.cpp]"]
  node_lanechange["Lane changing<br/>[lanechange.cpp]"]
  node_utilities["Geometry and JSON<br/>[utility.cpp]"]
  node_floatformat["Float formatting<br/>[dtoa_milo.h]"]
end

subgraph group_scenario["Network and scenarios"]
  node_gridjson["Grid to roadnet"]
  node_scenariogen["Scenario generation"]
  node_converter["Network converters"]
end

subgraph group_research["Traffic research"]
  node_studies["Traffic-control studies"]
  node_features["Control extensions"]
  node_synthetic["Synthetic datasets"]
  node_synthpred["Synthetic prediction<br/>[synth_to_pred.py]"]
  node_activelearning["Active learning"]
end

subgraph group_replay["Replay and visualization"]
  node_replaysim["Replay simulation<br/>[replay_simu.py]"]
  node_replayview["Replay viewer<br/>[script.js]"]
  node_replayconvert["Replay conversion"]
  node_replaydownload["Replay download<br/>[download_replay.py]"]
end

node_user(("Simulator user"))

node_user -->|"uses"| node_api
node_api -->|"exposes"| node_engine
node_api -->|"uses"| node_archive
node_engine -->|"manages"| node_flow
node_engine -->|"loads and updates"| node_roadnet
node_engine -->|"updates"| node_vehicle
node_roadnet -->|"references"| node_vehicle
node_roadnet -->|"uses"| node_trafficlight
node_vehicle -->|"delegates routing"| node_router
node_vehicle -->|"delegates lane changes"| node_lanechange
node_router -->|"queries lanes and roads"| node_roadnet
node_engine -->|"uses"| node_utilities
node_utilities -->|"formats floats"| node_floatformat
node_scenariogen -->|"uses"| node_gridjson
node_synthpred -->|"imports dataset"| node_synthetic
node_replaysim -.->|"converts replay"| node_replayconvert

click node_api "https://github.com/210041258/cityflow-branch/blob/master/src/cityflow.cpp"
click node_engine "https://github.com/210041258/cityflow-branch/blob/master/src/engine/engine.cpp"
click node_archive "https://github.com/210041258/cityflow-branch/blob/master/src/engine/archive.cpp"
click node_flow "https://github.com/210041258/cityflow-branch/blob/master/src/flow/flow.cpp"
click node_roadnet "https://github.com/210041258/cityflow-branch/blob/master/src/roadnet/roadnet.cpp"
click node_trafficlight "https://github.com/210041258/cityflow-branch/blob/master/src/roadnet/trafficlight.cpp"
click node_vehicle "https://github.com/210041258/cityflow-branch/blob/master/src/vehicle/vehicle.cpp"
click node_router "https://github.com/210041258/cityflow-branch/blob/master/src/vehicle/router.cpp"
click node_lanechange "https://github.com/210041258/cityflow-branch/blob/master/src/vehicle/lanechange.cpp"
click node_utilities "https://github.com/210041258/cityflow-branch/blob/master/src/utility/utility.cpp"
click node_floatformat "https://github.com/210041258/cityflow-branch/blob/master/extern/milo/dtoa_milo.h"
click node_gridjson "https://github.com/210041258/cityflow-branch/blob/master/tools/generator/generate_json_from_grid.py"
click node_converter "https://github.com/210041258/cityflow-branch/tree/master/tools/converter"
click node_studies "https://github.com/210041258/cityflow-branch/blob/master/cases-study/traffic_control_algorithm.py"
click node_features "https://github.com/210041258/cityflow-branch/tree/master/cityflow_features"
click node_synthetic "https://github.com/210041258/cityflow-branch/blob/master/cases-study/synthetic_dataset.py"
click node_synthpred "https://github.com/210041258/cityflow-branch/blob/master/cases-study/synth_to_pred.py"
click node_activelearning "https://github.com/210041258/cityflow-branch/blob/master/cases-study/bayesian_active_learning.py"
click node_replaysim "https://github.com/210041258/cityflow-branch/blob/master/simulation/frontend_replay/replay_simu.py"
click node_replayview "https://github.com/210041258/cityflow-branch/blob/master/frontend/script.js"
click node_replayconvert "https://github.com/210041258/cityflow-branch/tree/master/simulation/frontend_replay/init_replay/replay"
click node_replaydownload "https://github.com/210041258/cityflow-branch/blob/master/frontend/download_replay.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_api,node_engine,node_archive,node_flow,node_roadnet,node_trafficlight,node_vehicle,node_router,node_lanechange,node_utilities,node_floatformat,node_user toneBlue
class node_gridjson,node_scenariogen,node_converter toneAmber
class node_studies,node_features,node_synthetic,node_synthpred,node_activelearning toneMint
class node_replaysim,node_replayview,node_replayconvert,node_replaydownload toneRose
```

## Components

### Simulation runtime

- [Python API](https://github.com/210041258/cityflow-branch/blob/master/src/cityflow.cpp): `src/cityflow.cpp`
- [Simulation engine](https://github.com/210041258/cityflow-branch/blob/master/src/engine/engine.cpp): `src/engine/engine.cpp`
- [State archive](https://github.com/210041258/cityflow-branch/blob/master/src/engine/archive.cpp): `src/engine/archive.cpp`
- [Vehicle flows](https://github.com/210041258/cityflow-branch/blob/master/src/flow/flow.cpp): `src/flow/flow.cpp`
- [Road network](https://github.com/210041258/cityflow-branch/blob/master/src/roadnet/roadnet.cpp): `src/roadnet/roadnet.cpp`
- [Traffic lights](https://github.com/210041258/cityflow-branch/blob/master/src/roadnet/trafficlight.cpp): `src/roadnet/trafficlight.cpp`
- [Vehicle dynamics](https://github.com/210041258/cityflow-branch/blob/master/src/vehicle/vehicle.cpp): `src/vehicle/vehicle.cpp`
- [Route planning](https://github.com/210041258/cityflow-branch/blob/master/src/vehicle/router.cpp): `src/vehicle/router.cpp`
- [Lane changing](https://github.com/210041258/cityflow-branch/blob/master/src/vehicle/lanechange.cpp): `src/vehicle/lanechange.cpp`
- [Geometry and JSON](https://github.com/210041258/cityflow-branch/blob/master/src/utility/utility.cpp): `src/utility/utility.cpp`
- [Float formatting](https://github.com/210041258/cityflow-branch/blob/master/extern/milo/dtoa_milo.h): `extern/milo/dtoa_milo.h`

### Network and scenarios

- [Grid to roadnet](https://github.com/210041258/cityflow-branch/blob/master/tools/generator/generate_json_from_grid.py): `tools/generator/generate_json_from_grid.py`
- **Scenario generation**
- [Network converters](https://github.com/210041258/cityflow-branch/tree/master/tools/converter): `tools/converter`

### Traffic research

- [Traffic-control studies](https://github.com/210041258/cityflow-branch/blob/master/cases-study/traffic_control_algorithm.py): `cases-study/traffic_control_algorithm.py`
- [Control extensions](https://github.com/210041258/cityflow-branch/tree/master/cityflow_features): `cityflow_features`
- [Synthetic datasets](https://github.com/210041258/cityflow-branch/blob/master/cases-study/synthetic_dataset.py): `cases-study/synthetic_dataset.py`
- [Synthetic prediction](https://github.com/210041258/cityflow-branch/blob/master/cases-study/synth_to_pred.py): `cases-study/synth_to_pred.py`
- [Active learning](https://github.com/210041258/cityflow-branch/blob/master/cases-study/bayesian_active_learning.py): `cases-study/bayesian_active_learning.py`

### Replay and visualization

- [Replay simulation](https://github.com/210041258/cityflow-branch/blob/master/simulation/frontend_replay/replay_simu.py): `simulation/frontend_replay/replay_simu.py`
- [Replay viewer](https://github.com/210041258/cityflow-branch/blob/master/frontend/script.js): `frontend/script.js`
- [Replay conversion](https://github.com/210041258/cityflow-branch/tree/master/simulation/frontend_replay/init_replay/replay): `simulation/frontend_replay/init_replay/replay`
- [Replay download](https://github.com/210041258/cityflow-branch/blob/master/frontend/download_replay.py): `frontend/download_replay.py`

### Other components

- **Simulator user**

## Connections

- Simulator user → Python API: uses (evidence: `src/cityflow.cpp`)
- Python API → Simulation engine: exposes (evidence: `src/cityflow.cpp`)
- Python API → State archive: uses (evidence: `src/cityflow.cpp`)
- Simulation engine → Vehicle flows: manages
- Simulation engine → Road network: loads and updates (evidence: `src/engine/engine.cpp`)
- Simulation engine → Vehicle dynamics: updates (evidence: `src/engine/engine.cpp`)
- Road network → Vehicle dynamics: references (evidence: `src/roadnet/roadnet.cpp`)
- Road network → Traffic lights: uses
- Vehicle dynamics → Route planning: delegates routing
- Vehicle dynamics → Lane changing: delegates lane changes
- Route planning → Road network: queries lanes and roads (evidence: `src/vehicle/router.cpp`)
- Simulation engine → Geometry and JSON: uses (evidence: `src/engine/engine.cpp`)
- Geometry and JSON → Float formatting: formats floats
- Scenario generation → Grid to roadnet: uses
- Synthetic prediction → Synthetic datasets: imports dataset (evidence: `cases-study/synth_to_pred.py`)
- Replay simulation → Replay conversion: converts replay
