Request Path Variable: Vehicle Number and booking date
Response: Booking Details such as booking spot, booking date, start and end time.
User Can cancel the parking
HTTP Method: PATCH
Endpoint: /api/v1/booking/{booking-id}
Request Path Variable: booking id
Response: Cancellation confirmation details.
User Can get the Available parking spot
HTTP Method: GET
Endpoint: /api/v1/booking/availability
Request Body: Vehicle Type, Booking Date or booking start and end time.
Response: List of all available parking spots for the given criteria
Check in/check out
HTTP Methos: PATCH
Endpoint: /api/v1/booking/{booking-id}/{status}
Request Path Variable: booking id
Response: Cancellation confirmation details.
High-Level Design
User sent a request for different operations to the server it first go through the API gateway.
API Gateway route the request to the parking service. where api gateway route the request using round robin technique
Parking service performs the operations requested by user.
For the Parking reservation request once user select the parking slot it will be locked for a user for a configurable time default 5 minutes. if all the processing between the given time is completed the unique parking id will be generated else use transaction will be marked as cancelled and the parking slot will be make available to the other user. this technique also make help to maintain the consistency.
Once Parking slot is reserved for the user the event will be generated and sent the messaging broker from where Notification service will consume it and make the notification for the user and sent as a mail or a phone message.
The Batch Processing service will execute a batch for every five minutes and load all the reserved slot details (Before and after reservation time) and cache into memory, another batch process executes every minute and check for a slot in memory which start time about start or passed the start time and notify the user accordingly.
Detailed Component Design
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.