Requirements


Functional Requirements:


  • Users must register and authenticate in the application.
  • Users can search nearby parking lots using a map.
  • Users can view real-time parking availability.
  • Users can reserve a parking spot for a specific time window.
  • Users must complete payment before reservation confirmation.
  • Users can check in and check out through parking gates.
  • Users can leave earlier than the reservation expiration time.
  • The system should automatically release unused reservations.
  • The system should notify users about reservation status and expiration.


Non-Functional Requirements:


  • the app must support thousands of reservations
  • two users cannot reserve the same parking space
  • evaluate traffic conditions
  • Gate systems must continue operating even if some backend services fail.



API Design

Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...




High-Level Design


Client App: users search and reserve parking spots.

API Gateway: routes requests and handles authentication.

Reservation Service: manages reservations and prevents double booking.

Parking Service: tracks parking spot availability.

Payment Service: processes payments.

Gate Service: handles check-in and check-out at parking gates.

Database: stores users, reservations, and parking data.





Detailed Component Design


1. Reservation Service

Responsibilities:

  • create reservations
  • check availability
  • avoid double booking

To prevent two users from reserving the same spot, the service uses database transactions and row locking.


Flow:

  1. User selects a spot
  2. Service checks availability
  3. Spot is locked
  4. Payment is completed
  5. Reservation is confirmed


2. Gate Service

Responsibilities:

  • validate reservations
  • allow vehicle entry/exit
  • update occupancy status


Flow:

  1. User scans QR code
  2. Gate Service checks reservation
  3. Gate opens
  4. Spot status becomes occupied