# bhaveshchhimwal/smart-traffic-system architecture

> Architecture diagram of the GitHub repository bhaveshchhimwal/smart-traffic-system, 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/bhaveshchhimwal/smart-traffic-system
- Repository: https://github.com/bhaveshchhimwal/smart-traffic-system

## Overview

This is a compact multithreaded traffic-intersection simulator. The executable starts a traffic-generation thread and a controller loop; the generator changes lane state, while the controller selects a green lane using ambulance priority and a vehicle/wait-time score, updates waiting times, and displays the state. The graph separates those runtime responsibilities from the lane model. Relationships are grounded in the README and excerpts; no external services are shown.

Main entry points: [`main.cpp`](https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/main.cpp) (Simulation driver), [`models/Lane.cpp`](https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/models/Lane.cpp) (Lane state), [`core/TrafficController.cpp`](https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/core/TrafficController.cpp) (Signal update)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Simulation runtime"]
  node_main["Simulation driver<br/>[main.cpp]"]
  node_generator["Traffic generator"]
  node_display["State display"]
end

subgraph group_control["Signal control"]
  node_update["Signal update"]
  node_scheduler["Lane scheduler"]
end

subgraph group_domain["Traffic model"]
  node_lane["Lane state<br/>[Lane.cpp]"]
end

node_user(("Process start"))

node_user -->|"starts"| node_main
node_main -->|"starts thread"| node_generator
node_main -->|"updates signals"| node_update
node_main -->|"displays state"| node_display
node_generator -->|"adds cars"| node_lane
node_update -->|"selects lane"| node_scheduler
node_scheduler -->|"reads priority"| node_lane
node_update -->|"passes cars"| node_lane
node_display -->|"reads state"| node_lane

click node_main "https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/main.cpp"
click node_generator "https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/core/TrafficController.cpp"
click node_display "https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/core/TrafficController.cpp"
click node_update "https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/core/TrafficController.cpp"
click node_scheduler "https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/core/TrafficController.cpp"
click node_lane "https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/models/Lane.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_main,node_generator,node_display toneBlue
class node_update,node_scheduler toneAmber
class node_lane toneMint
class node_user toneIndigo
```

## Components

### Simulation runtime

- [Simulation driver](https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/main.cpp): `main.cpp`
- [Traffic generator](https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/core/TrafficController.cpp): `core/TrafficController.cpp`
- [State display](https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/core/TrafficController.cpp): `core/TrafficController.cpp`

### Signal control

- [Signal update](https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/core/TrafficController.cpp): `core/TrafficController.cpp`
- [Lane scheduler](https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/core/TrafficController.cpp): `core/TrafficController.cpp`

### Traffic model

- [Lane state](https://github.com/bhaveshchhimwal/smart-traffic-system/blob/main/models/Lane.cpp): `models/Lane.cpp`

### Other components

- **Process start**

## Connections

- Process start → Simulation driver: starts (evidence: `README.md`)
- Simulation driver → Traffic generator: starts thread (evidence: `main.cpp`)
- Simulation driver → Signal update: updates signals (evidence: `main.cpp`)
- Simulation driver → State display: displays state (evidence: `main.cpp`)
- Traffic generator → Lane state: adds cars (evidence: `core/TrafficController.cpp`)
- Signal update → Lane scheduler: selects lane (evidence: `core/TrafficController.cpp`)
- Lane scheduler → Lane state: reads priority (evidence: `core/TrafficController.cpp`)
- Signal update → Lane state: passes cars (evidence: `core/TrafficController.cpp`)
- State display → Lane state: reads state (evidence: `core/TrafficController.cpp`)
