List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
Assumptions:
Estimations:
RDB is a preferred solution because:
Define what APIs are expected from the system...
APIs used by user:
APIs used by gate checking service:
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
Reservation:
User:
Contact_Info:
Vehicle
Parking_Spot
Parking_Lot
Transactions:
Don't need the `parking_lot_ID` and `parking_spot_ID` as attributes of the the `Transactions` table because vehicles reservation overlaps are not to be expected
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
API Gateway to:
RDB:
Redis Cache:
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
First client will call check_capacity(), which will be handled by the Reservation Service, which reads the lot capacity information fro the database.
The client would then call reserve_spot(), also handled by the Reservation Service, which will create a new reservation in the Reservation db table.
This will create a request for payment (a redirect URI), which is returned to the client.
reserve_spot() may fail if multiple users trying to book the same spot. If error, ask client to call reserve_spot() again.
reserve_spot() will also fail if the lot is full. Should not prompt them to try again in this case. Instead can display when the lot will be available again.
Client makes the payment and sends the payment token (confirmation) via complete_reservation().
vehicle_arrived() and vehicle_left() are handled by the Transaction Service, which modifies the Transaction table to keep track of vehicle check-ins and checkouts.
Transaction Monitor service periodically checks db for non-arrivals. If user doesn't arrive within 8 hours of reservation, then reservation canceled and user charged for 24 hours.
If vehicle_left() is called before vehicle_arrived() then the admin at the lot should be notified. The service should assume the vehicle arrived around reservation start time.
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Explain any trade offs you have made and why you made certain tech choices...
RDB provides strong consistency. This is a transaction based service which requires consistency, so RDB over NoSQL is preferred. The estimated data over 2 years is less than 1 TB too so RDB performance won't be a concern.
NoSQL would provide better horizontal scalability, but consistency and relational queries outweigh the benefit of scalability.
Try to discuss as many failure scenarios/bottlenecks as possible.
The main scalability bottleneck would be the amount of data stored and thus the database choice. All other components can be scaled because they are stateless (reservation service and transaction service) or support scalability natively (cache, API gateway).
To enhance read performance, can have READ replicas and also partition the db across nodes with logical groupings like parking lots and locations.
For fault tolerance, the database should be replicated across AZs for disaster recovery.
Monitoring systems should be in place for all servers and components.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?
Optimizing based on user's geographic location with a CDN like Cloudflare or using a Global Load Balancer to route client traffic to the nearest data center. Databases can also be replicated across geographic regions to ensure backups in case of a regional disaster.