Requirements
Functional Requirement
- Allow reservation of a parking spot.
- Process payment for the reservation.
- Enable parking of a car in the reserved spot.
- Support early departure before reservation time expires.
- Gate check-in/out.
- User gets notified on booking confirmation, booking reminder, booking cancellation, delay arrival, booking end time.
- Handle no show.
- Giving a grace period for user if did not arrive on the booking time. After the grace time release the booking.
- Cancellation policy where user has to cancel the booking in a configured time before else user has to pay a penalty.
Non-Functional Requirements:
- Availability: The system should be highly available.
- Consistency:
- Tow user trying to book and parking spot should not allocate the same spot.
- No two user should get the same parking spot
- Durability: Once spot is created needs to ensure that data never lost
- scalability: parking service, notification service can scale to multiple instance. API gateway will route the request using round robin and notification service consumer can scale with consumer group
- Reliability
- The System should behave correctly and deliver the functional requirement even in case of failure, request spikes and other outage.
API Design
- User Can book the parking spot
- HTTP Method: POST
- Endpoint: /api/v1/booking
- Request body: User Id, Vehicle Number, booking date, start time, end time
- Response: Booking Confirmation Id, Parking Spot number
- User Can get the details of the parking spot
- HTTP Method: GET
- Endpoint: /api/v1/booking/{vehicle-number}/{booking date}
- 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, status(checkin/checkout)
- Response: Confirmation on the status update
High-Level Design
- User first Logged in into the System.
- User will look for an available parking spot for a specific vehicle type and for a date and time bases.
- User will select the available parking spot and processed for payment.
- On the successful payment user will get the confirmation notification on mail/phone message.
- User will also get the reminder notification mail/phone message before the parking 15 minutes of booking.
- User will check in to parking place by providing all the required details such as booking ID, Vehical details etc.
- User will get a 5-10 minutes(configurable) of grace period on the late arrival. If user fail to arrive withing the grace period then
- the reserve slot status will be updated to available
- 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.