# xdefox/intelligent-traffic-control-system architecture

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

- Interactive diagram: https://gitdiagram.com/xdefox/intelligent-traffic-control-system
- Repository: https://github.com/xdefox/intelligent-traffic-control-system

## Overview

Smart Crossroads is a traffic-control prototype combining a Unity intersection simulation with an asynchronous FastAPI service. The main loop sends batched camera detections to the API, where the orchestrator evaluates emergency priority and signal phases using the network model, then returns per-camera signal commands. A cloud coordinator handles network-wide green-wave commands and statistics; the Flet dashboard presents traffic, topology, and analytics. Unity and several backend subsystems are represented from README and the source index where implementation details were not excerpted, so their internal links are limited to documented relationships.

Main entry points: [`backend/services/orchestrator.py`](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/orchestrator.py) (Intersection orchestrator), [`backend/main.py`](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/main.py) (FastAPI endpoints), [`Scene/Diplom_scene/Assets/Scripts/IntersectionVisionManager.cs`](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/IntersectionVisionManager.cs) (Intersection client), [`backend/services/graph_manager.py`](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/graph_manager.py) (Road graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Unity Simulation"]
  node_unity_vision["Camera vision"]
  node_unity_intersection["Intersection client"]
  node_unity_lights["Signal display"]
  node_unity_navigation["Vehicle navigation"]
  node_unity_generator["Traffic generation"]
end

subgraph group_api["Telemetry API"]
  node_api_server["FastAPI endpoints<br/>[main.py]"]
  node_dto["Telemetry DTOs<br/>[traffic.py]"]
end

subgraph group_control["Traffic Control"]
  node_orchestrator["Intersection orchestrator<br/>[orchestrator.py]"]
  node_emergency["Emergency detection<br/>[emergency.py]"]
  node_phase["Phase manager<br/>[phase_manager.py]"]
  node_cloud["Cloud coordinator"]
  node_greenwave["Green-wave coordinator<br/>[green_wave.py]"]
end

subgraph group_insight["Dashboard and Analytics"]
  node_statistics[("Traffic statistics<br/>[statistics.py]")]
  node_admin["Dashboard entry<br/>[admin_panel.py]"]
  node_panels["Control panels<br/>[panels.py]"]
  node_map["Network map<br/>[map.py]"]
end

subgraph group_foundation["Traffic Model"]
  node_graph[("Road graph<br/>[graph_manager.py]")]
  node_roadconfig["Road configuration<br/>[road_config.py]"]
  node_laneutils["Lane utilities<br/>[lane_utils.py]"]
end

node_driver(("Simulation operator"))
node_client(("Unity client"))
node_dashboard_user(("Dashboard user"))

node_driver -.->|"starts simulation"| node_unity_generator
node_unity_vision -.->|"sends detections"| node_unity_intersection
node_unity_intersection -.->|"posts telemetry"| node_api_server
node_api_server -->|"validates payload"| node_dto
node_api_server -->|"routes batch"| node_orchestrator
node_orchestrator -->|"detects priority"| node_emergency
node_orchestrator -->|"reads topology"| node_graph
node_orchestrator -->|"chooses phase"| node_phase
node_orchestrator -->|"gets wave commands"| node_cloud
node_orchestrator -->|"builds response"| node_dto
node_api_server -.->|"returns commands"| node_unity_intersection
node_unity_intersection -.->|"updates signals"| node_unity_lights
node_unity_navigation -->|"requests congestion"| node_api_server
node_cloud -->|"calculates waves"| node_greenwave
node_greenwave -->|"reads topology"| node_graph
node_cloud -->|"records traffic"| node_statistics
node_graph -->|"loads network"| node_roadconfig
node_graph -->|"parses lane IDs"| node_laneutils
node_admin -->|"starts dashboard"| node_panels
node_panels -->|"updates topology view"| node_map
node_panels -->|"shows analytics"| node_statistics
node_dashboard_user -.->|"opens dashboard"| node_admin
node_unity_generator -.->|"creates traffic"| node_unity_navigation

click node_unity_vision "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/EdgeVisionCamera.cs"
click node_unity_intersection "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/IntersectionVisionManager.cs"
click node_unity_lights "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/TraddicLightViewer.cs"
click node_unity_navigation "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/WaypointNavigator.cs"
click node_unity_generator "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/TrafficGenerator.cs"
click node_api_server "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/main.py"
click node_dto "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/models/traffic.py"
click node_orchestrator "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/orchestrator.py"
click node_emergency "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/core/emergency.py"
click node_phase "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/phase_manager.py"
click node_cloud "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/cloud_orchestrator.py"
click node_greenwave "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/green_wave.py"
click node_graph "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/graph_manager.py"
click node_roadconfig "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/core/road_config.py"
click node_laneutils "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/core/lane_utils.py"
click node_statistics "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/statistics.py"
click node_admin "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/UI/admin_panel.py"
click node_panels "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/UI/ui/panels.py"
click node_map "https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/UI/ui/map.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_unity_vision,node_unity_intersection,node_unity_lights,node_unity_navigation,node_unity_generator,node_client,node_dashboard_user toneBlue
class node_api_server,node_dto toneAmber
class node_orchestrator,node_emergency,node_phase,node_cloud,node_greenwave toneMint
class node_statistics,node_admin,node_panels,node_map toneRose
class node_graph,node_roadconfig,node_laneutils,node_driver toneIndigo
```

## Components

### Unity Simulation

- [Camera vision](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/EdgeVisionCamera.cs): `Scene/Diplom_scene/Assets/Scripts/EdgeVisionCamera.cs`
- [Intersection client](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/IntersectionVisionManager.cs): `Scene/Diplom_scene/Assets/Scripts/IntersectionVisionManager.cs`
- [Signal display](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/TraddicLightViewer.cs): `Scene/Diplom_scene/Assets/Scripts/TraddicLightViewer.cs`
- [Vehicle navigation](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/WaypointNavigator.cs): `Scene/Diplom_scene/Assets/Scripts/WaypointNavigator.cs`
- [Traffic generation](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/Scene/Diplom_scene/Assets/Scripts/TrafficGenerator.cs): `Scene/Diplom_scene/Assets/Scripts/TrafficGenerator.cs`

### Telemetry API

- [FastAPI endpoints](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/main.py): `backend/main.py`
- [Telemetry DTOs](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/models/traffic.py): `backend/models/traffic.py`

### Traffic Control

- [Intersection orchestrator](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/orchestrator.py): `backend/services/orchestrator.py`
- [Emergency detection](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/core/emergency.py): `backend/core/emergency.py`
- [Phase manager](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/phase_manager.py): `backend/services/phase_manager.py`
- [Cloud coordinator](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/cloud_orchestrator.py): `backend/services/cloud_orchestrator.py`
- [Green-wave coordinator](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/green_wave.py): `backend/services/green_wave.py`

### Dashboard and Analytics

- [Traffic statistics](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/statistics.py): `backend/services/statistics.py`
- [Dashboard entry](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/UI/admin_panel.py): `backend/UI/admin_panel.py`
- [Control panels](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/UI/ui/panels.py): `backend/UI/ui/panels.py`
- [Network map](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/UI/ui/map.py): `backend/UI/ui/map.py`

### Traffic Model

- [Road graph](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/services/graph_manager.py): `backend/services/graph_manager.py`
- [Road configuration](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/core/road_config.py): `backend/core/road_config.py`
- [Lane utilities](https://github.com/xdefox/intelligent-traffic-control-system/blob/main/backend/core/lane_utils.py): `backend/core/lane_utils.py`

### Other components

- **Simulation operator**
- **Unity client**
- **Dashboard user**

## Connections

- Simulation operator → Traffic generation: starts simulation (evidence: `README.md`)
- Camera vision → Intersection client: sends detections (evidence: `README.md`)
- Intersection client → FastAPI endpoints: posts telemetry (evidence: `README.md`)
- FastAPI endpoints → Telemetry DTOs: validates payload (evidence: `backend/main.py`)
- FastAPI endpoints → Intersection orchestrator: routes batch (evidence: `backend/main.py`)
- Intersection orchestrator → Emergency detection: detects priority (evidence: `backend/services/orchestrator.py`)
- Intersection orchestrator → Road graph: reads topology (evidence: `backend/services/orchestrator.py`)
- Intersection orchestrator → Phase manager: chooses phase (evidence: `backend/services/orchestrator.py`)
- Intersection orchestrator → Cloud coordinator: gets wave commands (evidence: `backend/services/orchestrator.py`)
- Intersection orchestrator → Telemetry DTOs: builds response (evidence: `backend/services/orchestrator.py`)
- FastAPI endpoints → Intersection client: returns commands (evidence: `README.md`)
- Intersection client → Signal display: updates signals (evidence: `README.md`)
- Vehicle navigation → FastAPI endpoints: requests congestion (evidence: `backend/main.py`)
- Cloud coordinator → Green-wave coordinator: calculates waves (evidence: `backend/services/cloud_orchestrator.py`)
- Green-wave coordinator → Road graph: reads topology (evidence: `backend/services/green_wave.py`)
- Cloud coordinator → Traffic statistics: records traffic (evidence: `backend/services/cloud_orchestrator.py`)
- Road graph → Road configuration: loads network (evidence: `backend/services/graph_manager.py`)
- Road graph → Lane utilities: parses lane IDs (evidence: `backend/services/graph_manager.py`)
- Dashboard entry → Control panels: starts dashboard (evidence: `backend/UI/admin_panel.py`)
- Control panels → Network map: updates topology view (evidence: `backend/UI/ui/panels.py`)
- Control panels → Traffic statistics: shows analytics (evidence: `backend/UI/ui/panels.py`)
- Dashboard user → Dashboard entry: opens dashboard (evidence: `README.md`)
- Traffic generation → Vehicle navigation: creates traffic (evidence: `README.md`)
