A Traffic Control Signal System is an automated system used to manage the movement of vehicles and pedestrians at road intersections by controlling traffic lights (red, yellow, green) in a coordinated and safe manner.
Its main objectives are to:
In this chapter, we will explore the low-level design of a traffic control signal system in detail.
Lets start by clarifying the requirements:
Before starting the design, it's important to ask thoughtful questions to uncover hidden assumptions and better define the scope of the system.
Here is an example of how a conversation between the candidate and the interviewer might unfold:
Candidate: Should the system manage a single intersection or multiple intersections?
Interviewer: Let’s design it to handle multiple intersections.
Candidate: Do we need to handle emergency scenarios like green light overrides for ambulances or fire trucks?
Interviewer: Not for this version. Assume normal conditions.
Candidate: Should the signal cycle support left/right turns with dedicated turn signals?
Interviewer: Yes, each direction can optionally have a dedicated turn signal in the cycle, though it's not mandatory for all intersections.
Candidate: Should we support a control panel or admin interface to start/stop or override signals?
Interviewer: Yes, provide basic manual override functionality via a simple admin interface.
After gathering the details, we can summarize the key system requirements.
SignalController
, Light
, Timer
, and AdminPanel