Search This Blog

Friday, April 29, 2022

Design Parking Garage

 Let's discuss designing parking garage as a problem statement.

At high level what all we need to consider and think about while designing a parking garage.

Product Requirements:

  • Need to be able to reserve a parking spot and receive some kind of ticket or receipt.
  • Need to be able to pay for a parking spot.
  • System needs to have a high consistency (no two people should be able to reseve the same spot at the same time).
  • 3 types of vehicles (compact, regular and large).
  • flat rate, but different rates depending of the type of parking.

APIs:
  • Public Endpoints
    • /reserve
      • Params : garage_id, start_time, end_time
      • Returns : (spot_id, reservation_id)
    • /payment
      • Params : reservation_id
      • Note : Likely using an existing API to handle (Stripe, Square etc...)
    • /cancel
      • Params : reservation_id
  • Internal Endpoints
    • /calculate_payment
      • Params : reservation_id
    • /freespots
      • Params : garage_id, vehicle_type, time
      • Note : Smaller vehicles can fit into larger spots if necessary and therefore should be included in the overall number of spots
    • /allocate_spot
      • Params : garage_id, vehicle_type, time
    • /create_account
      • Params ; email, password, first_name, last_name
    • /login
      • Params : email, password

Data Schema:
  • Reservations
    • id : primary key
    • garage_id : foreign key
    • spot_id : foreign key
    • start: timestamp
    • end : timestamp
    • paid : boolean
  • Garage
    • id : primary key
    • zipcode : varchar
    • rate_compact : decimal
    • rate_regular : decimal
    • rate_large : decimal
  • Spots
    • id : primary key
    • garage_id : foreign key
    • vehicle_type : enum
    • status : enum
  • Users
    • id : primary key
    • email : varchar
    • password : varchar (note that this probably SHA-256 hash)
    • first_name : varchar
    • last_name : varchar
  • Vehicles
    • id : primary key
    • user_id : foreign key
    • licence : varchar



No comments:

My Profile

My photo
can be reached at 09916017317