System requirements
Functional:
- User should be able to reserve a parking spot in advance, and pay for their reservation online in advance
- User should be able to see in real-time the availability of parking spots, to cancel their reservation online, and to update the booking details
- Entering and exiting vehicles should be tracked in real-time, with an optional billing adjusmtent for early departure and late check-out
- User should be penalized if not showing up at their reservation time, and space should be reallocated past a certain period after the reservation time
Non-Functional:
- The system should prioritize consistency over availability, not allocating a parking spot if not available at the time
- The system should operate on a real-time timescale (~1 minute) to be able to reallocate a parking spot if a vehicle just exited, or conversely block a parking spot if a vehicle just entered
- The system should handle dense concurrent searches (before and after rush hour, with ~100 users at the same time), prioritizing the first reservation and/or the closest vehicle to the parking
- The system should implement specific rules to reallocate spots if the reservation was not honored, and to penalize users who did not follow through with their reservation
Capacity estimation
- Maximum of 100 online simultaneous searches
- Maximum of 10 vehicles simultaneously entering or simultaneously exiting
- Parking lot can contain a maximum of 1,000 vehicles
API design
POST /reservations
{
"vehicleType": string,
"reservationDateAndTime": timestamp,
"reservationDuration": timestamp,
"userID": string,
"paymentStatus": boolean
}
GET /reservations/{id}
UPDATE /reservations/{id}
GET /availability
Database design
The database should be a Relational Database Management System that includes the reservation data (userID, vehicleType, reservationDateAndTime, reservationDuration, paymentStatus) and the tracking data (enteredUserID, exitedUserID, noShowUserID)
High-level design
The Track server tracks in real-time the number of vehicles that enter and exit, and their size. Based on this tracking, it makes a calculation of the amount of available parking lots. This estimate is stored in the Database. The client makes an online reservation, inputting: their name, their vehicle type, the date and time of the reservation, and the expected duration for parking. Based on this data, the Reserve server queries the database, checking if there is any matching availability. If there is a matching availability, the Reserve server let the client pays the reservation, and the server updates the Database. If there is no availability, the Reserve server proposes to the client alternative time that best matches the reservation. The Track server checks if the reservation has been honored, and otherwise calculates the discrepancy in time between the reservation and the actual entering in the parking lot. Past a certain time, the Reserve server cancels the reservation. Before this time, the Reservation implements a penalty fee that is function of the discrepancy in time.
Request flows
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Detailed component design
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Trade offs/Tech choices
Explain any trade offs you have made and why you made certain tech choices...
Failure scenarios/bottlenecks
Try to discuss as many failure scenarios/bottlenecks as possible.
Future improvements
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?