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 First Look for an all available parking slot using(/api/v1/booking/availability) based on the lookup criteria such as Booking Date and time window and vehicle type.
Once User Identify the design booking slot user will select the parking slot and process with the next details at the same time the parking slot will be locked by the user for a configurable time default is 5 minutes. This will happen through the distributed cache where the parking slot if and the user id will be store with the time to leave(TTL) of 5 Minutes.
In the given time user has to fill up the details such as time, vehicle details, payment details and make a payment.
Once User Made a payment the reservation details will be persist into database using API /api/v1/booking and removed from the cache. If user fail to complete the reservation process within a given time then user will be prompted and slot will be marked as available.
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.
User Can see the booking details using/api/v1/booking/{vehicle-number}/{booking date}.
User can cancelled the booking using PATCH /api/v1/booking/{booking-id}. The panties will be applicate as the configured business rules.
The check in and check-out will be manage by PATCH API/api/v1/booking/{booking-id}/{status}
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
API Gateway is responsible to route the request to the parking service . In the case of multiple instance of the parking service the round robin algorithm will be use to route the request.
Parking service component service is responsible to perform all the parking related operations such as get available parking spots, reserve the parking spot, cancel the reservation, check in and checkout tracking etc.
Database table where reservation details maintain will have a daily partition.