Requirements


Functional Requirements:


  • 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.
  • Handle no show.



Non-Functional Requirements:


  • Need to ensure reliability and high-availability of the system.
  • provide low latency so users can check-in or out quickly.
  • System needs to be scalable to handle more traffic.
  • Strong consistency in the system
  • Idempotency
  • Rate limiting on request from user in a minute


API Design

We will require 4 REST API:

GET /reserve get all reservation.

GET /reserve/ get reservation for a user

POST /reserve to reserve a parking spot in advance.

UPDATE /reserve/ update a timing of reservation

DELETE /reserve/ to remove reservation on a spot.

POST /check-in check if spot is reserved or assign new

POST /check-out free the spot



High-Level Design

We can build 2 microservice one for reserving and unreserving and other to handle check in and check out and scale them independently depending on workload. Both will write to the same database. Reserve service allows booking a spot for a specific duration. Checkin service handles all customers at the parking entrance and either reserved spot is assigned or nearest. if parking duration is more far spot will be assigned if short duration closer spot.



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.