Problem statement
Design the object model and core APIs for the software that controls the lights at a road intersection: the in-process brain that decides which approaches see green, yellow, or red, and drives them through their timed phases. Whatever hardware or simulator sits underneath merely obeys the light commands this engine emits; the engine owns all the timing and safety rules.
Operating context. One intersection with a fixed set of approaches (a plain four-way has North, South, East, West; a T-junction has three). Each approach runs its own signal head through a state cycle (green then yellow then red), and non-conflicting approaches may be grouped so opposing straight-through traffic goes green together. Timing is configurable per phase (green duration, fixed yellow, an all-red clearance gap) and may differ by time of day. A clock ticks the controller forward; on each tick it decides whether to hold the current phase or advance to the next. An emergency-vehicle preemption request can force a chosen approach to green out of turn. There is no network and no concurrency across intersections here — one controller, driven by one caller on one thread.
Out of scope. The physical lamp/relay wiring and device drivers, pedestrian-crossing buttons and walk signals, vehicle-detector hardware calibration, cross-intersection coordination or a city-wide green wave, and any UI or telemetry dashboard. Design only the in-process control engine and its object model, not the transport or hardware around it.
What to produce. The class hierarchy (entities such as Intersection, Approach, SignalHead, Phase, PhasePlan, and value objects like SignalColor or a Duration), the public API each class exposes, and the state transitions for a signal head (green, yellow, red) and for the controller's phase cycle. Be explicit about: how the per-approach state machine advances only through legal color transitions, how phase timing and the all-red clearance are configured and enforced, how conflicting approaches are never green at once, how an emergency preemption safely interrupts and later resumes the normal cycle, and how the design extends to sensor-driven adaptive timing without rewriting the phase engine.
Requirements
This assessment is a Premium feature.
The statement above is free to read. The functional and non-functional requirements, and the graded canvas that scores your design against them, come with Premium.
Topics
- System Design LLD
- Statemachine
- Oop Solid
- Patterns Strategy
- Extensibility