# alfredozc/rider_and_threads architecture

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

- Interactive diagram: https://gitdiagram.com/alfredozc/rider_and_threads
- Repository: https://github.com/alfredozc/rider_and_threads

## Overview

Equipetrol Delivery is a concurrent, accelerated-time C++ delivery-dispatch simulator. Its main workflow loads and validates JSON configuration, generates orders, admits them to a bounded order book, dispatches them to couriers, and records delivery outcomes and a summary. Restaurants impose pickup-slot constraints; routing uses the configured street graph, while breakdowns and optional reinforcements affect fleet operations. The live map and event log expose the run. Edges below reflect README-described behavior and visible startup code; several implementation details are unsampled, so their internal links are omitted.

Main entry points: [`src/main.cpp`](https://github.com/alfredozc/rider_and_threads/blob/master/src/main.cpp) (Simulation and map view), [`src/Dispatcher.cpp`](https://github.com/alfredozc/rider_and_threads/blob/master/src/Dispatcher.cpp) (Dispatcher), [`src/CourierActor.cpp`](https://github.com/alfredozc/rider_and_threads/blob/master/src/CourierActor.cpp) (Courier actor), [`src/OrderBook.cpp`](https://github.com/alfredozc/rider_and_threads/blob/master/src/OrderBook.cpp) (Order book)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration and map"]
  node_config["JSON configuration<br/>[Config.cpp]"]
  node_city["Street graph<br/>[CityGraph.cpp]"]
  node_router["Route planner<br/>[Router.cpp]"]
end

subgraph group_orders["Order lifecycle"]
  node_ordergen["Order generator<br/>[OrderGenerator.cpp]"]
  node_factory["Order factory<br/>[OrderFactory.cpp]"]
  node_book[("Order book<br/>[OrderBook.cpp]")]
  node_restaurant["Restaurant slots<br/>[Restaurant.cpp]"]
  node_order["Order state<br/>[Order.h]"]
end

subgraph group_dispatch["Dispatch and fleet"]
  node_quote["Courier quotes<br/>[Quote.cpp]"]
  node_quotepool["Quote pool<br/>[QuotePool.cpp]"]
  node_dispatcher["Dispatcher<br/>[Dispatcher.cpp]"]
  node_actor["Courier actor<br/>[CourierActor.cpp]"]
  node_fleet["Courier fleet<br/>[Fleet.cpp]"]
  node_courier["Courier state<br/>[Courier.h]"]
end

subgraph group_runtime["Simulation runtime"]
  node_clock["Simulation clock<br/>[SimClock.h]"]
  node_context["Shared context<br/>[SimContext.h]"]
  node_ids["Domain identifiers<br/>[Ids.h]"]
  node_app["Simulation and map view<br/>[main.cpp]"]
end

subgraph group_outputs["Observability"]
  node_eventlog["Event log<br/>[EventLog.cpp]"]
  node_summary["Run summary<br/>[Summary.cpp]"]
end

node_operator(("Operator"))

node_operator -->|"starts run"| node_app
node_app -->|"loads"| node_config
node_app -->|"builds graph"| node_city
node_city -->|"routes over"| node_router
node_app -->|"starts generator"| node_ordergen
node_ordergen -->|"creates orders"| node_factory
node_ordergen -->|"submits orders"| node_book
node_app -->|"starts dispatcher"| node_dispatcher
node_dispatcher -->|"reads waiting orders"| node_book
node_dispatcher -->|"collects quotes"| node_quotepool
node_quotepool -.->|"produces quotes"| node_quote
node_dispatcher -->|"assigns orders"| node_actor
node_actor -->|"plans trips"| node_router
node_actor -->|"updates order state"| node_book
node_actor -->|"waits for pickup slot"| node_restaurant
node_dispatcher -->|"requests reinforcements"| node_fleet
node_fleet -->|"starts couriers"| node_actor
node_app -->|"records events"| node_eventlog
node_book -->|"logs transitions"| node_eventlog
node_app -->|"prints results"| node_summary
node_app -->|"renders live state"| node_book
node_app -->|"times simulation"| node_clock
node_app -->|"shares runtime state"| node_context
node_order -->|"uses identifiers"| node_ids
node_courier -->|"uses identifiers"| node_ids

click node_config "https://github.com/alfredozc/rider_and_threads/blob/master/src/Config.cpp"
click node_city "https://github.com/alfredozc/rider_and_threads/blob/master/src/CityGraph.cpp"
click node_router "https://github.com/alfredozc/rider_and_threads/blob/master/src/Router.cpp"
click node_ordergen "https://github.com/alfredozc/rider_and_threads/blob/master/src/OrderGenerator.cpp"
click node_factory "https://github.com/alfredozc/rider_and_threads/blob/master/src/OrderFactory.cpp"
click node_book "https://github.com/alfredozc/rider_and_threads/blob/master/src/OrderBook.cpp"
click node_restaurant "https://github.com/alfredozc/rider_and_threads/blob/master/src/Restaurant.cpp"
click node_quote "https://github.com/alfredozc/rider_and_threads/blob/master/src/Quote.cpp"
click node_quotepool "https://github.com/alfredozc/rider_and_threads/blob/master/src/QuotePool.cpp"
click node_dispatcher "https://github.com/alfredozc/rider_and_threads/blob/master/src/Dispatcher.cpp"
click node_actor "https://github.com/alfredozc/rider_and_threads/blob/master/src/CourierActor.cpp"
click node_fleet "https://github.com/alfredozc/rider_and_threads/blob/master/src/Fleet.cpp"
click node_clock "https://github.com/alfredozc/rider_and_threads/blob/master/src/SimClock.h"
click node_context "https://github.com/alfredozc/rider_and_threads/blob/master/src/SimContext.h"
click node_ids "https://github.com/alfredozc/rider_and_threads/blob/master/src/Ids.h"
click node_order "https://github.com/alfredozc/rider_and_threads/blob/master/src/Order.h"
click node_courier "https://github.com/alfredozc/rider_and_threads/blob/master/src/Courier.h"
click node_eventlog "https://github.com/alfredozc/rider_and_threads/blob/master/src/EventLog.cpp"
click node_summary "https://github.com/alfredozc/rider_and_threads/blob/master/src/Summary.cpp"
click node_app "https://github.com/alfredozc/rider_and_threads/blob/master/src/main.cpp"

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_config,node_city,node_router toneBlue
class node_ordergen,node_factory,node_book,node_restaurant,node_order toneAmber
class node_quote,node_quotepool,node_dispatcher,node_actor,node_fleet,node_courier toneMint
class node_clock,node_context,node_ids,node_app toneRose
class node_eventlog,node_summary,node_operator toneIndigo
```

## Components

### Configuration and map

- [JSON configuration](https://github.com/alfredozc/rider_and_threads/blob/master/src/Config.cpp): `src/Config.cpp`
- [Street graph](https://github.com/alfredozc/rider_and_threads/blob/master/src/CityGraph.cpp): `src/CityGraph.cpp`
- [Route planner](https://github.com/alfredozc/rider_and_threads/blob/master/src/Router.cpp): `src/Router.cpp`

### Order lifecycle

- [Order generator](https://github.com/alfredozc/rider_and_threads/blob/master/src/OrderGenerator.cpp): `src/OrderGenerator.cpp`
- [Order factory](https://github.com/alfredozc/rider_and_threads/blob/master/src/OrderFactory.cpp): `src/OrderFactory.cpp`
- [Order book](https://github.com/alfredozc/rider_and_threads/blob/master/src/OrderBook.cpp): `src/OrderBook.cpp`
- [Restaurant slots](https://github.com/alfredozc/rider_and_threads/blob/master/src/Restaurant.cpp): `src/Restaurant.cpp`
- [Order state](https://github.com/alfredozc/rider_and_threads/blob/master/src/Order.h): `src/Order.h`

### Dispatch and fleet

- [Courier quotes](https://github.com/alfredozc/rider_and_threads/blob/master/src/Quote.cpp): `src/Quote.cpp`
- [Quote pool](https://github.com/alfredozc/rider_and_threads/blob/master/src/QuotePool.cpp): `src/QuotePool.cpp`
- [Dispatcher](https://github.com/alfredozc/rider_and_threads/blob/master/src/Dispatcher.cpp): `src/Dispatcher.cpp`
- [Courier actor](https://github.com/alfredozc/rider_and_threads/blob/master/src/CourierActor.cpp): `src/CourierActor.cpp`
- [Courier fleet](https://github.com/alfredozc/rider_and_threads/blob/master/src/Fleet.cpp): `src/Fleet.cpp`
- [Courier state](https://github.com/alfredozc/rider_and_threads/blob/master/src/Courier.h): `src/Courier.h`

### Simulation runtime

- [Simulation clock](https://github.com/alfredozc/rider_and_threads/blob/master/src/SimClock.h): `src/SimClock.h`
- [Shared context](https://github.com/alfredozc/rider_and_threads/blob/master/src/SimContext.h): `src/SimContext.h`
- [Domain identifiers](https://github.com/alfredozc/rider_and_threads/blob/master/src/Ids.h): `src/Ids.h`
- [Simulation and map view](https://github.com/alfredozc/rider_and_threads/blob/master/src/main.cpp): `src/main.cpp`

### Observability

- [Event log](https://github.com/alfredozc/rider_and_threads/blob/master/src/EventLog.cpp): `src/EventLog.cpp`
- [Run summary](https://github.com/alfredozc/rider_and_threads/blob/master/src/Summary.cpp): `src/Summary.cpp`

### Other components

- **Operator**

## Connections

- Operator → Simulation and map view: starts run (evidence: `README.md`)
- Simulation and map view → JSON configuration: loads (evidence: `src/main.cpp`)
- Simulation and map view → Street graph: builds graph (evidence: `src/main.cpp`)
- Street graph → Route planner: routes over
- Simulation and map view → Order generator: starts generator (evidence: `src/main.cpp`)
- Order generator → Order factory: creates orders
- Order generator → Order book: submits orders
- Simulation and map view → Dispatcher: starts dispatcher (evidence: `src/main.cpp`)
- Dispatcher → Order book: reads waiting orders (evidence: `README.md`)
- Dispatcher → Quote pool: collects quotes
- Quote pool → Courier quotes: produces quotes
- Dispatcher → Courier actor: assigns orders (evidence: `README.md`)
- Courier actor → Route planner: plans trips
- Courier actor → Order book: updates order state (evidence: `README.md`)
- Courier actor → Restaurant slots: waits for pickup slot (evidence: `README.md`)
- Dispatcher → Courier fleet: requests reinforcements (evidence: `README.md`)
- Courier fleet → Courier actor: starts couriers
- Simulation and map view → Event log: records events (evidence: `README.md`)
- Order book → Event log: logs transitions
- Simulation and map view → Run summary: prints results (evidence: `README.md`)
- Simulation and map view → Order book: renders live state (evidence: `src/main.cpp`)
- Simulation and map view → Simulation clock: times simulation (evidence: `src/main.cpp`)
- Simulation and map view → Shared context: shares runtime state (evidence: `src/SimContext.h`)
- Order state → Domain identifiers: uses identifiers (evidence: `src/Order.h`)
- Courier state → Domain identifiers: uses identifiers (evidence: `src/Courier.h`)
