List the key functional requirements for the system (Ask the AI for hints if stuck)...
- 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.
List the key non-functional requirements (performance, scalability, reliability, etc.)...
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
Back of the envelope estimations:
DAU —> 2M
Reads / checking for available spots —> 23/s avg, peak ~115/s
Writes / reservations —> 2.3/s avg, peak ~12/s
QPS —> Read + Write —> 25/s avg, peak ~125/s
Read:Write —> 10:1
Data storage —> user data + parking lots data + reservations data for lets say 5 yrs —> (5M * 1KB) + (500K * 1KB) + (200K * 365 * 5 * 1KB) ~ 6GB
CAP theorem —> System should be CP for writes and AP for reads. We can use an RDBMS like PostgreSQL with strict ACID transactions and distributed locking. If a network partition occurs, we will sacrifice availability and reject incoming reservations for affected zones to absolutely guarantee that we never double-book a physical asset.
Latency —>
i. Read: User —> API gateway/LB —> server —> cache or then DB —> back to client = (30-80ms) + (5-15ms) + (2-5ms) + (20-60ms) + (30-80ms) = 100-150ms
ii. Write: User —> API gateway/LB —> server —> DB (example - acquire lock on parking spot) —> Payment gateway (can be third party, so can take 400-1000ms) —> DB (status update) —> back to user = 700-1500ms
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...
i. /api/v1/parking-spot?city=delhi GET
ii. /api/v1/parking-spot?lat=1&long=2 GET
iii. /api/v1/parking-spot?loc=noida-sec-100 GET
Response for i, ii, iii:
{ "total_results": 2, "parking_spots": [ { "id": "spot_abc123", "parking_lot_id": "lot_7788", "parking_lot_name": "Downtown Central Garage", "vehicle_type": "SUV", "approx_rate": 15.50, "status": "AVAILABLE", "image_url": "https://parkingsystem.com" }, { "id": "spot_xyz789", "parking_lot_id": "lot_7788", "parking_lot_name": "Downtown Central Garage", "vehicle_type": "SEDAN", "approx_rate": 12.00, "status": "OCCUPIED", "image_url": "https://parkingsystem.com" } ] }
iv. /api/v1/parking-spot/{:id}/ GET
Response will be similar to above
v. /api/v1/reservation POST
JSON body:
{ "user_id": "user_usr_99824", "vehicle_id": "veh_vhc_44102", "parking_spot_id": "spot_abc123", "start_date": "2026-10-26T18:00:00Z", "duration_minutes": 120 }
Response:
{
"status": "SUCCESS",
"reservation_id": "res_rsv_773910",
"payment_id": "pay_chg_884021"
}
vi. /api/v1/reservation/{:id}/checkin POST
vii. /api/v1/reservation/{:id}checkout POST
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
We mainly use Microservices architecture to solve this problem. Each service has its own DB and cache for separation of functions and concerns.
i. ParkingLotService: This is the central service which is responsible for the orchestration of all the flows and services from searching for available parking spots to booking the spot.
ii. RateService: This service is solely responsible for providing the rate of a particular parking spot according to varying factors.
iii. PaymentService: This service is for completing the payment during making a reservation.
iv. ReservationService: During reservation process and also during other flows such as check-in and cancellation, this service will be involved as it will be updating the DB for the reservation and its details and status.
v. ParkingLotSearchService: This service will be fetching list of available parking spots according to any search criteria provided, it could be user's current location or city searched by them.
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
Choice of DB - SQL DB like PostgreSQL or MySQL - Reason - Read intensive, structured or static schema and not flexible schema, ACID properties, locks and DB constraints needed for consistency during concurrency.
Tables:
Relationships:
Indexes:
Other techniques - sharding (on basis of user id or parking_lot_id), replication for redundancy and query optimization for fast DB
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
Different flows of the application: