System requirements
Functional:
- User reservation
- payment system
- vehicle parking process
- vehicle departure process - early departure
- no show scenarios
Non-Functional:
- System should prioritize consistency over availability while showing available parking sports
- Should handle concurrent reservations on same spot properly
- should respond with available spaces in ~100ms
- should process payment securely
Capacity estimation
API design
GET /api/spots/available?day=x&start=x&end=x&vehicleType=x -> available spots
POST /api/spots/reserve {spotId:x,day:x,&start:x,end:x,vehicleType:x} -> reserve a spot
POST /api/payment/reservationId -> process payment
PUT /api/spot/park -> {reservationId} -> process vehicle parking
PUT /api/spot/depart -> reservationId -> process vehicle departure
Cron job to handle no show cases
Database design
User{
id: string;
name: string;
age: string;
licenseId: string;
}
Vehicle:{
reg_id: string;
vehicleType: TW0_WHEELER (enum),
}
ParkingLot{
List
}
ParkingSpot{
id: string;
spotType: TW0_WHEELER (enum);
isReserved: boolean;
isOccupied: boolean;
}
Reservation{
vehicleId:string;
userId: string;
start: dateTime;
end:dateTime;
}
High-level design
services:
reservation service
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?