System requirements


Functional:

Reservation of Parking Spot: Users should be able to reserve their parking spot in advance

Payment Processing: User's need to be able to pay for their parking reservation

Early Exit: User's should be able to leave the parking before their reservation expire

Parking Expiration: User's should have additional fees added to their payment if they leave the parking after their reservation expires

No Show Policy: System need to able to handle charges if the customer doesn't show up


Non-Functional:

Consistency: Needs to prevent double-booking

Availability: System must be available for process over 99.999% of time

Scalability: The system should be able to handle pacrking reservations across different locations and handle a large number of parking lot and requets.




Capacity estimation

Given the situation where we have a parking lot with 250 available spot and we expect to have occupancy rate of 80%, and that on average each car use the parking space for at least an hour.

Additionally, the parking pass is divided accross Car types

60% --> Standard Cars

20% --> Compact Cars

20% --> Electric Cars


We need to handle 200 traffic requests at any given time. If the system is being used in 3 parking lot with the same capacity we'll account for 600 request/hour


14400 requests/day

432000 requests/month

And around 5.4 million requests/year


Each Reservation request include

Current TimeStamp ------> 13 bytes

Car Type ------> 1 byte

Reservation ID ------> 8 Byte

Reservation EndTime ------> 8 Byte


For a total of 30 bytes per request

162 MB per year


API design

The API Needs to be control user's interaction and the activity controled by the gate control service


Gate Control Service:

Operation Controlled

-Vehicle Entered(ReservationID, CarType, CurrentTimeStamp, ReservationEndTime)

/api/vehicle/start

-Vehicle Leaving(ReservationID, ReservationEndTime, CurrentTimeSTAMP)

/api/vehicle/leave


User Contol Services:

Reservation (This is endpoint allow user's to book a reservation for their parking spot)

api/reservation/booking [reservationID, LotID, CarType]


Payment (This endpoint process payment gateway for reservation booking)

api/service/payment [reservationID, reservationTime(number of hours booked), customer_name, paymentInformation]


CheckCapacity (This endpoint check the capacity of the parking lot and will be used in the reservation process)

api/service/capacity [LotID, startTime, Endtime, CarType]


CancelReservation (This endpoint will allow user's to cancel their previous registration)

api/reservation/cancel

[UserID, PaymentInformation, LotID, CarType]



Database design

the Database show incorporate these tables:

Users, Reservation, Transaction, Parking_Lot


User

UserID ---> INT [PK]

Name ---> VARCHAR

Payment Information ---> VARCHAR


Reservation

ReservationID ---> INT [PK]

UserID ---> INT [FK]

TransactionID ---> INT [FK]

ParkingID ---> INT [FK]

TimeBooked ---> INT

LotID ---> ENUM

CarType ---> ENUM

STATUS ---> ENUM

Payment_Status ---> ENUM


Parking_Lot

ParkingID ---> INT [PK]

Capacity ---> INT


Transaction

TransactionID ---> INT[PK]

UserID ---> INT[FK]

start_time

end_time



High-level design

Core Components:

  1. User Interface (UI): This can be a mobile app or web application where users can iteract with the system
  2. API Gateway: Serves as an entry point for client requests. It manages traffic, provides security features (like rate limiting), and directs requests to the appropriate services.
  3. Reservation Service: Handles all operations related to reservations
  4. Payment Processing Service: Responsible for managing payment transactions
  5. Transaction Service: Manages the check-in and checkout process for vehicles
  6. Database: This will be a relational database to store critical data:
  7. Monitoring and Notification Service: Responsible for tracking system performance and notifying users about important events







Request flows

Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...








Detailed component design

Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...






Trade offs/Tech choices

Explain any trade offs you have made and why you made certain tech choices...






Failure scenarios/bottlenecks

Try to discuss as many failure scenarios/bottlenecks as possible.






Future improvements

What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?