Design a Real-Time EV Charging Station Reservation System for a City
Company: Geico
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Technical Screen
Design a reservation system for the electric-vehicle charging stations of a city. Drivers see which chargers are available and reserve one in real time, then drive there and charge. The report states only this goal, so the number of stations, how a reservation is held and released, and how the system learns the real state of each charger are open: settle them with the interviewer before designing.
```hint Two drivers, one charger
Think about what guarantees that two drivers who press "reserve" on the same charger at the same moment cannot both succeed.
```
```hint The map can be wrong
A charger can be taken by a driver without a reservation, go offline, or be abandoned by a no-show. Think about where the truth about availability lives and how quickly the app learns about a change.
```
### Clarifying Questions
- Does a driver reserve a specific charger for a time slot later in the day, or only hold an available charger until arrival?
- How many stations and chargers does the city have, and how many drivers search and reserve at peak?
- How long is a reservation held, and what happens when a driver does not arrive or stays plugged in too long?
- Can chargers report their state (free, charging, faulted) to the system, and can a driver without a reservation plug in?
- Do chargers differ in connector type and power, so that search must filter on them?
- Is payment part of this design or handled by another service?
### What a Strong Answer Covers
- Requirements and an estimate of stations, chargers and request rates
- A data model of stations, chargers and reservations, and the life cycle of a reservation
- Concurrency control that prevents double booking, such as a conditional update, a unique constraint or a lock with a lease
- A search path that finds nearby available chargers quickly, separate from the booking path
- Real-time availability from charger reports, pushed to the app, with rules for when the reservation state and the charger disagree
- Expiry of holds, no-shows, failure handling and monitoring
### Follow-up Questions
- A charger goes offline while a reservation on it is active. What do the system and the driver see?
- How would you let drivers book a slot hours in advance while drivers without a reservation can still use idle chargers?
- A popular station receives far more requests than it has chargers at rush hour. How would you allocate them fairly?
- How do you keep the availability shown in the app consistent with what the chargers report?
Overview: Design a city-wide reservation system for electric-vehicle charging stations in which drivers see live availability and reserve a free charger in real time. It tests data modeling, preventing double booking under concurrency, hold expiry and no-shows, charger reports for true availability, and fast nearby search.