# bhushanchavan04/ai---smart-control-traffic-light architecture

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

- Interactive diagram: https://gitdiagram.com/bhushanchavan04/ai---smart-control-traffic-light
- Repository: https://github.com/bhushanchavan04/ai---smart-control-traffic-light

## Overview

This repository combines a PyGame four-way traffic simulation with a separate YOLO vehicle-counting script and a standalone distance-based tracker. The documented product workflow is vehicle detection and classification, density-based signal timing, then simulated traffic movement and visualization. The excerpts show the simulator’s thread startup and the detector’s video/model processing, but do not show the detector wired into the simulator; that integration is therefore not represented as an implemented connection.

Main entry points: [`vehicle_count.py`](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/vehicle_count.py) (YOLO Detection), [`simulation.py`](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/simulation.py) (Simulation Main), [`tracker.py`](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/tracker.py) (Distance Tracker), [`video.mp4`](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/video.mp4) (Video Input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Traffic Simulation"]
  node_main["Simulation Main<br/>[simulation.py]"]
  node_signal["Signal Timing<br/>[simulation.py]"]
  node_vehicles["Vehicle Movement<br/>[simulation.py]"]
  node_visuals["PyGame Display<br/>[simulation.py]"]
end

subgraph group_detection["Vehicle Detection"]
  node_detection["YOLO Detection<br/>[vehicle_count.py]"]
  node_counting["Line Counting<br/>[vehicle_count.py]"]
end

subgraph group_tracking["Object Tracking"]
  node_tracker["Distance Tracker<br/>[tracker.py]"]
end

subgraph group_inputs["Input Data"]
  node_video["Video Input<br/>[video.mp4]"]
  node_weights["YOLO Weights<br/>[yolov8s.pt]"]
  node_labels["COCO Labels<br/>[coco.names]"]
end

node_user(("Operator"))

node_user -->|"runs"| node_main
node_main -->|"starts thread"| node_signal
node_main -->|"starts thread"| node_vehicles
node_main -.->|"runs display"| node_visuals
node_signal -->|"controls movement"| node_vehicles
node_detection -->|"reads frames"| node_video
node_detection -->|"loads model"| node_weights
node_detection -->|"reads labels"| node_labels
node_detection -->|"tracks crossings"| node_counting
node_tracker -.->|"provides IDs"| node_user

click node_main "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/simulation.py"
click node_signal "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/simulation.py"
click node_vehicles "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/simulation.py"
click node_visuals "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/simulation.py"
click node_detection "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/vehicle_count.py"
click node_counting "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/vehicle_count.py"
click node_tracker "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/tracker.py"
click node_video "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/video.mp4"
click node_weights "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/yolov8s.pt"
click node_labels "https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/coco.names"

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_signal,node_vehicles,node_visuals toneBlue
class node_detection,node_counting toneAmber
class node_tracker toneMint
class node_video,node_weights,node_labels toneRose
class node_user toneIndigo
```

## Components

### Traffic Simulation

- [Simulation Main](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/simulation.py): `simulation.py`
- [Signal Timing](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/simulation.py): `simulation.py`
- [Vehicle Movement](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/simulation.py): `simulation.py`
- [PyGame Display](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/simulation.py): `simulation.py`

### Vehicle Detection

- [YOLO Detection](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/vehicle_count.py): `vehicle_count.py`
- [Line Counting](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/vehicle_count.py): `vehicle_count.py`

### Object Tracking

- [Distance Tracker](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/tracker.py): `tracker.py`

### Input Data

- [Video Input](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/video.mp4): `video.mp4`
- [YOLO Weights](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/yolov8s.pt): `yolov8s.pt`
- [COCO Labels](https://github.com/bhushanchavan04/ai---smart-control-traffic-light/blob/main/coco.names): `coco.names`

### Other components

- **Operator**

## Connections

- Operator → Simulation Main: runs (evidence: `README.md`)
- Simulation Main → Signal Timing: starts thread (evidence: `simulation.py`)
- Simulation Main → Vehicle Movement: starts thread (evidence: `simulation.py`)
- Simulation Main → PyGame Display: runs display (evidence: `simulation.py`)
- Signal Timing → Vehicle Movement: controls movement (evidence: `README.md`)
- YOLO Detection → Video Input: reads frames (evidence: `vehicle_count.py`)
- YOLO Detection → YOLO Weights: loads model (evidence: `vehicle_count.py`)
- YOLO Detection → COCO Labels: reads labels (evidence: `vehicle_count.py`)
- YOLO Detection → Line Counting: tracks crossings (evidence: `vehicle_count.py`)
- Distance Tracker → Operator: provides IDs
