# notarsal/food-delivery-simulator architecture

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

- Interactive diagram: https://gitdiagram.com/notarsal/food-delivery-simulator
- Repository: https://github.com/notarsal/food-delivery-simulator

## Overview

This is a full-stack food-delivery logistics simulator and route optimizer. Users configure a city, fleet, and order volume in the dashboard; the API starts a tick-based simulation that loads a road network, generates and batches orders, assigns drivers, computes routes, and streams live state back to the map and metrics panels. Separate branches provide routing benchmarks and ETA prediction. The README documents capabilities beyond the sampled code; uncertain implementation links are omitted rather than inferred.

Main entry points: [`backend/simulation.py`](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/simulation.py) (Simulation engine), [`frontend/src/components/Dashboard.jsx`](https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/Dashboard.jsx) (Live dashboard), [`backend/main.py`](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/main.py) (FastAPI and sockets), [`frontend/src/App.jsx`](https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/App.jsx) (App state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Dashboard"]
  node_app["App state<br/>[App.jsx]"]
  node_dashboard["Live dashboard<br/>[Dashboard.jsx]"]
  node_map["Map view<br/>[MapView.jsx]"]
  node_controls["Sim controls<br/>[SimControls.jsx]"]
  node_algorithm_ui["Algorithm selector"]
  node_metrics["Metrics panel<br/>[MetricsPanel.jsx]"]
  node_benchmark["Benchmark chart<br/>[AlgorithmChart.jsx]"]
end

subgraph group_service["Simulation service"]
  node_api["FastAPI and sockets<br/>[main.py]"]
  node_simulation["Simulation engine<br/>[simulation.py]"]
  node_orders["Order generation<br/>[orders.py]"]
  node_batching["Order batching<br/>[batching.py]"]
  node_drivers["Driver dispatch<br/>[drivers.py]"]
  node_traffic["Traffic updates<br/>[traffic.py]"]
end

subgraph group_routing["Routing and prediction"]
  node_routeopt["Route optimization<br/>[route_optimizer.py]"]
  node_algorithms["Pathfinding algorithms<br/>[routing.py]"]
  node_algorithm_router["Dynamic selection"]
  node_genetic["Genetic optimizer"]
  node_eta["ETA prediction<br/>[predict.py]"]
end

subgraph group_data["Inputs and state"]
  node_road["Road network<br/>[road_network.py]"]
  node_graphdata[("Road graph data")]
  node_restaurants[("Restaurant data<br/>[pune_data.py]")]
end

node_user(("Operator"))
node_osm(("OpenStreetMap"))

node_user -->|"configures"| node_app
node_app -->|"renders"| node_dashboard
node_dashboard -->|"renders"| node_map
node_dashboard -->|"renders"| node_controls
node_dashboard -->|"renders"| node_algorithm_ui
node_dashboard -->|"renders"| node_metrics
node_app -->|"renders"| node_benchmark
node_app -->|"starts and stops"| node_api
node_api -->|"streams updates"| node_app
node_api -->|"controls"| node_simulation
node_simulation -->|"loads graph"| node_road
node_simulation -->|"generates orders"| node_orders
node_orders -->|"loads restaurant data"| node_restaurants
node_simulation -->|"batches orders"| node_batching
node_simulation -->|"assigns batches"| node_drivers
node_simulation -->|"updates traffic"| node_traffic
node_simulation -->|"computes routes"| node_routeopt
node_routeopt -->|"uses pathfinding"| node_algorithms
node_routeopt -->|"uses optimizer"| node_genetic
node_algorithms -->|"reads graph"| node_road
node_api -->|"benchmarks routes"| node_algorithms
node_api -->|"predicts ETA"| node_eta
node_simulation -.->|"selects strategy"| node_algorithm_router
node_road -.->|"caches graph"| node_graphdata
node_road -->|"downloads roads"| node_osm

click node_app "https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/App.jsx"
click node_dashboard "https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/Dashboard.jsx"
click node_map "https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/MapView.jsx"
click node_controls "https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/SimControls.jsx"
click node_algorithm_ui "https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/AlgorithmSelector.jsx"
click node_metrics "https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/MetricsPanel.jsx"
click node_benchmark "https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/AlgorithmChart.jsx"
click node_api "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/main.py"
click node_simulation "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/simulation.py"
click node_orders "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/orders.py"
click node_batching "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/batching.py"
click node_drivers "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/drivers.py"
click node_traffic "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/traffic.py"
click node_road "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/road_network.py"
click node_graphdata "https://github.com/notarsal/food-delivery-simulator/tree/main/data"
click node_restaurants "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/pune_data.py"
click node_routeopt "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/route_optimizer.py"
click node_algorithms "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/routing.py"
click node_algorithm_router "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/routing_algorithms/algorithm_router.py"
click node_genetic "https://github.com/notarsal/food-delivery-simulator/blob/main/backend/routing_algorithms/genetic_algorithm.py"
click node_eta "https://github.com/notarsal/food-delivery-simulator/blob/main/ml/predict.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_app,node_dashboard,node_map,node_controls,node_algorithm_ui,node_metrics,node_benchmark toneBlue
class node_api,node_simulation,node_orders,node_batching,node_drivers,node_traffic toneAmber
class node_routeopt,node_algorithms,node_algorithm_router,node_genetic,node_eta toneMint
class node_road,node_graphdata,node_restaurants toneRose
class node_user,node_osm toneIndigo
```

## Components

### Dashboard

- [App state](https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Live dashboard](https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/Dashboard.jsx): `frontend/src/components/Dashboard.jsx`
- [Map view](https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/MapView.jsx): `frontend/src/components/MapView.jsx`
- [Sim controls](https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/SimControls.jsx): `frontend/src/components/SimControls.jsx`
- [Algorithm selector](https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/AlgorithmSelector.jsx): `frontend/src/components/AlgorithmSelector.jsx`
- [Metrics panel](https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/MetricsPanel.jsx): `frontend/src/components/MetricsPanel.jsx`
- [Benchmark chart](https://github.com/notarsal/food-delivery-simulator/blob/main/frontend/src/components/AlgorithmChart.jsx): `frontend/src/components/AlgorithmChart.jsx`

### Simulation service

- [FastAPI and sockets](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/main.py): `backend/main.py`
- [Simulation engine](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/simulation.py): `backend/simulation.py`
- [Order generation](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/orders.py): `backend/orders.py`
- [Order batching](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/batching.py): `backend/batching.py`
- [Driver dispatch](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/drivers.py): `backend/drivers.py`
- [Traffic updates](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/traffic.py): `backend/traffic.py`

### Routing and prediction

- [Route optimization](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/route_optimizer.py): `backend/route_optimizer.py`
- [Pathfinding algorithms](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/routing.py): `backend/routing.py`
- [Dynamic selection](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/routing_algorithms/algorithm_router.py): `backend/routing_algorithms/algorithm_router.py`
- [Genetic optimizer](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/routing_algorithms/genetic_algorithm.py): `backend/routing_algorithms/genetic_algorithm.py`
- [ETA prediction](https://github.com/notarsal/food-delivery-simulator/blob/main/ml/predict.py): `ml/predict.py`

### Inputs and state

- [Road network](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/road_network.py): `backend/road_network.py`
- [Road graph data](https://github.com/notarsal/food-delivery-simulator/tree/main/data): `data`
- [Restaurant data](https://github.com/notarsal/food-delivery-simulator/blob/main/backend/pune_data.py): `backend/pune_data.py`

### Other components

- **Operator**
- **OpenStreetMap**

## Connections

- Operator → App state: configures (evidence: `README.md`)
- App state → Live dashboard: renders (evidence: `frontend/src/App.jsx`)
- Live dashboard → Map view: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Live dashboard → Sim controls: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Live dashboard → Algorithm selector: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- Live dashboard → Metrics panel: renders (evidence: `frontend/src/components/Dashboard.jsx`)
- App state → Benchmark chart: renders (evidence: `frontend/src/App.jsx`)
- App state → FastAPI and sockets: starts and stops (evidence: `frontend/src/App.jsx`)
- FastAPI and sockets → App state: streams updates (evidence: `README.md`)
- FastAPI and sockets → Simulation engine: controls (evidence: `backend/main.py`)
- Simulation engine → Road network: loads graph (evidence: `backend/simulation.py`)
- Simulation engine → Order generation: generates orders (evidence: `backend/simulation.py`)
- Order generation → Restaurant data: loads restaurant data (evidence: `backend/orders.py`)
- Simulation engine → Order batching: batches orders (evidence: `backend/simulation.py`)
- Simulation engine → Driver dispatch: assigns batches (evidence: `backend/simulation.py`)
- Simulation engine → Traffic updates: updates traffic (evidence: `backend/simulation.py`)
- Simulation engine → Route optimization: computes routes (evidence: `backend/simulation.py`)
- Route optimization → Pathfinding algorithms: uses pathfinding (evidence: `backend/route_optimizer.py`)
- Route optimization → Genetic optimizer: uses optimizer (evidence: `backend/route_optimizer.py`)
- Pathfinding algorithms → Road network: reads graph (evidence: `backend/routing.py`)
- FastAPI and sockets → Pathfinding algorithms: benchmarks routes (evidence: `README.md`)
- FastAPI and sockets → ETA prediction: predicts ETA (evidence: `backend/main.py`)
- Simulation engine → Dynamic selection: selects strategy
- Road network → Road graph data: caches graph
- Road network → OpenStreetMap: downloads roads (evidence: `README.md`)
