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:
- Strong consistency when reserving so two people cannot reserve same spot
- Low latency when reserving the spot
- Strong security and auth with payments
- Must be available, so has to handle large traffic so reservation and payment process is always available
- Handle a full parking lot and not allow users to make reservations if full
API Design
POST /reserve
Request{
- user
- paymentInfo
- vehicleInfo
- startTime
- endTime
}
Reponse{
- parkingSpot
- reservationID
}
POST /reservation/{reservationId}/checkOut
Request
{
- reservationID
}
Response{
- checkOut
- payment
- status
}
POST /checkIn/{reservationId}
Request
{
- reservationID
- vehicleInfo
}
Response:
{
- endTime
- checkInTime
- status
}
GET /availability?parkingSpot=X&startTime=X&endTime=X
Request
{}
Response
{
- status
- parkingSpot
- reservationTime
}
High-Level Design
Client -> Loadbalancer & Payment Provider -> APIGateway -> Two services (reservation and payment) -> Cache & db
Detailed Component Design
Reservation service will cache any existing reservations so we can save time when checking if there is an existing reservation
Load balance the different services to ensure availability
we'll use a relational db so we can handle concurrent calls if two people attempt to reserve same spit