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
- High availability
- AutoScaling
API Design
POST parking/checkin
GET parking/availableSlots
POST parking/checkout
GET parking/payment
Detailed Component Design
SQL DB - Lock for update to be used
Tables involved are
Vehicle
Slots
Bills
Race conditions can be managed with select for update that applies locking the slot
Cache is used to get the available slots, not to hit the DB for each and every call
Microservices architecture