Requirements


Functional Requirement

  1. Allow reservation of a parking spot.
  2. Process payment for the reservation.
  3. Enable parking of a car in the reserved spot.
  4. Support early departure before reservation time expires.
  5. Gate check-in/out.
  6. User gets notified on booking confirmation, booking reminder, booking cancellation, delay arrival, booking end time.
  7. Handle no show.
    1. Giving a grace period for user if did not arrive on the booking time. After the grace time release the booking.
    2. Cancellation policy where user has to cancel the booking in a configured time before else user has to pay a penalty. 



Non-Functional Requirements:


  1. Availability: The system should be highly available.
  2. Consistency:
    1. Tow user trying to book and parking spot should not allocate the same spot.
    2. No two user should get the same parking spot
  3. Durability: Once spot is created needs to ensure that data never lost
  4. 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
  5. Reliability
    1. The System should behave correctly and deliver the functional requirement even in case of failure, request spikes and other outage.


API Design

  1. User Can book the parking spot
    1. HTTP Method: POST
    2. Endpoint: /api/v1/booking
    3. Request body: User Id, Vehicle Number, booking date, start time, end time
    4. Response: Booking Confirmation Id, Parking Spot number
  2. User Can get the details of the parking spot
    1. HTTP Method: GET
    2. Endpoint: /api/v1/booking/{vehicle-number}/{booking date}
    3. Request Path Variable: Vehicle Number and booking date
    4. Response: Booking Details such as booking spot, booking date, start and end time.
  3. User Can cancel the parking
    1. HTTP Method: PATCH
    2. Endpoint: /api/v1/booking/{booking-id}
    3. Request Path Variable: booking id
    4. Response: Cancellation confirmation details.
  4. User Can get the Available parking spot
    1. HTTP Method: GET
    2. Endpoint: /api/v1/booking/availability
    3. Request Body: Vehicle Type, Booking Date or booking start and end time.
    4. Response: List of all available parking spots for the given criteria
  5. Check in/check out
    1. HTTP Methos: PATCH
    2. Endpoint: /api/v1/booking/{booking-id}/{status}
    3. Request Path Variable: booking id, status(checkin/checkout)
    4. Response: Confirmation on the status update


High-Level Design

  1. Parking Service
    1. This component of the system supports the operations such as look up parking slot, availability and pricing, reserve a paring slot, Check in and check out of the Vehicle.
    2. User request for a parking slot booking for a date and time and vehicle type. on the bases of user input user will get the available slot along with pricing details.
    3. The Available slot and pricing details will be fetch from the Cache and incase if details are not present in cache fallback to the database.
    4. Once user agrees on the available slot and pricing user will process for a payment. System will allocate the parking slot for a user and lock it for a 5 minutes to complete the booking process.
    5. Once Slot will be allocated and locked for the user, user will redirected to the payment on the third party payment system.
    6. Once User made a payment the marking lot will be confirm to the user. if user fail to make a payment or complete the process within 5 minutes the user will be notified and the locked slot will be release and available of the booking.
    7. User Will be notified about the booking confirmation.
    8. As a part of check-in process user will have to scan the QR code or Vehicle Number plat and once details match with the booking slot user will be allow to park the vehicle.
    9. If the user did not arrive at the parking location on time then system will allow the grace period for the user and also notify user through the Mail/Message. The grace period will be configurable and default will be 30 minutes. if user fail to arrive within grace period the booking will be cancelled by the system and user will be notify accordingly.
    10. As a part of check-out process user will have to scan the OR code or Vehicle number plat and system will check the check out time set by user if its within the check-out time then user will be allow to check out if user check out time me after the selected out time then additional fees will calculated for each 15 minutes from the out time will be charge to user.
  2. Batch Processing Service
    1. There will be s scheduler which executed after every interval and verify the if user has not yet arrive at the booking time and within the grace period. by looking into the case it either sent a notification or cancelled the booking.
    2. It send the message on the queue where user needs to notify for a specific actions such as Check-in time reminder, check-in timeout, cancellation of the booking if user not arrive after the grace time etc.
  3. Notification service
    1. Notification service is responsible to sent an notification to the user vie a mail/message.
    2. This services gets an event from the queue and it take an action on the event as per the event type.



Detailed Component Design

  1. 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.
  2. 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.
  3. Database table where reservation details maintain will have a daily partition.