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:
- Reliability
- Availability
- Secure
- Consistent (Users can park cars in same place)
API Design
RESERVE PLACE
POST /reserve
{
"car_plate": "str",
"lot_id": "str",
"check_in_time": "timestamp",
"check_out_time": "timestamp"
}
RESPONSE
{
"reserve_id": "str",
"price": "str"
}
CheckIn
REQUEST
POST /lot/check-in
{
"car_plate": "str
}
RESPONSE
SUCCESS
or
NO ACTUAL RESERVATION FOR THIS VEHICLE FOUND
CheckOut
POST /lot/check-out
{
"cat_plate": "str
}
RESPONSE
SUCCESS
or
THERE IS A PARKING DEBT FOR A VEHICLE
List of parking lots
GET /parking
{
lot_ids: ["str", "str", ...]
}
GET /parking?free=ture&size=medium
{
lot_ids: ["str", "str", ...]
}
GET /parking/{id}
{
lot_id: "str"
}
POST /parking/debt
{
"car_plate": int
}
POST /parking/pay
REQUEST
{
"car_data": "str"
"car_plate": "str"
}
High-Level Design
- There should be 3 types of business entities: parking lots, reservations and actions.
- System should be simple, data should be consistent, everything can be stored in simple RDBMS.
- BackEnd handles all bussiness logic except payment
- All Payment are delegated to PaymentProcessor. PaymentProcessor just validates data a send it to some credit card payment processor (Bank or Merchant)
Detailed Component Design
- RDBMS structure:
- Parking lot has: ID, Size (Small, Medium, Big), Price
- Reservation has: ID, car_plate, check_in_time, check_out_time, payed, create_time, expired
- Action has datetime, action [check_in, check_out]
- When user create reservation it considers as non free for 15 minutes. 15 minutes after create_time it becomes free if not payed. Free/Non Free logic is Bussiness logic, not something that is saved in db but determined on request
- check-in works only if there is payed reservation found in correct timescope for the car_plate
- Parking debt exist in case if there is created parking which is not payed or in case checkout hasn't happened and there is 5 minute after checkout time
- If parking debt > 0 checkout won't happen