Requirements


Functional Requirements:


  • Allow reservation of a parking spot.
  • Support different types of vehicles.
  • 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.
  • Show parking spot availability by vehicle type at entrance/check-in
  • Handle no show.
  • Support space optimization
    • e.g. if user does not want to pick a spot themselves
    • for different vehicles types, e.g. to reduce friction during parking in/out
  • Strong consistency regarding pricing, parking spot reservation, ad-hoc spot availability and spots for certain vehicle types
    • Users should be able to rely on their reservations even with high user concurrency during booking/check-in
    • Users should be able to rely on the shown price during booking
  • Monitoring of key usage metrics
    • e.g. about parking spot utilization during certain hours



Non-Functional Requirements:


  • High availability
  • High reliability
  • Medium to low latency
  • Medium to high scalability
    • Especially during expected peak hours
    • Concurrent user support of roughly 150% of parking spot capacity
    • Horizontal scaling support (with load balancing) to handle increased load
    • Caching for frequently accessed data


API Design

  • GET /parking-spots/summary
    • Takes start time and end time as parameters
    • Returns number of available and unavailable parking spots by type for the given time interval
  • GET /parking-spots
    • Takes start time and end time as parameters
    • Returns all existing spots with id, status, type and position for the given time interval
  • GET /parking-spots/available
    • Takes start time and end time as parameters
    • Returns all available spots with id, status, type and position for the given time interval
  • POST /parking-spots/{spot-id}/_reserve
    • Reserves a parking slot for a user
    • User data is in the body
      • User id
      • Start time
      • End time
      • Expected price
    • Returns reservation id, user id, start time, end time, final price
  • POST /parking-spots/{spot-id}/_check-in
    • Checks the user into the spot
    • Data in the body
      • Reservation id
    • Returns success/failure
  • GET /pricing
    • Takes start time and end time as parameters
    • Returns pricing based on the current pricing patterns for the given time interval



High-Level Design

Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.




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.