Design Traffic Signal Control System
| Difficulty: Easy | Source: awesome-low-level-design |
Requirements
- Control traffic at intersection with multiple roads
- Signal types: red, yellow, green
- Configurable signal durations
- Smooth transitions between signals
- Detect and handle emergency situations
- Scalable and extensible
Class Diagram

Classes, Interfaces and Enumerations
| Class/Interface | Description |
|---|---|
| Signal | Enum for red, yellow, green |
| Road | id, name, associated traffic light |
| TrafficLight | id, current signal, durations; methods for changing signals |
| TrafficController | Singleton; manages roads and traffic lights |
Design Patterns Used
| Pattern | Application |
|---|---|
| Singleton | TrafficController has a single instance managing all intersections |
| Observer | Traffic lights notify the controller of state changes; emergency overrides |
Code Implementations
| Language | Source Code |
|---|---|
| Java | View on GitHub |
| Python | View on GitHub |
| C++ | View on GitHub |
| C# | View on GitHub |
| Go | View on GitHub |