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...
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...
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 keep a table of spaces and a table of sections to keep track of the spaces we have.
When a car wants to enter, we check if there is a space available for them and what section it is in. We query the database for a space matching the required space type not associated with a current car entry (one that doesn't have an exit_timestamp). We then tell the driver what section the free spaces are in, so they know where to go.
When a car enters, we insert a record of them in the car table. It will associate the space_num with the car, identified by its license plate, and the entry_timestamp.
When a car exits, we look up their record and calculate how much time has elapsed. We then calculate how much they must pay based on our formula. We set exit_timestamp in their car table record.
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...
Table space
space_num - integer
section_id - integer
type - enum (can be regular, bus, trailer etc.)
Table section
section_id - integer
Table car
space_num - integer
entry_timestamp - integer
license_plate - string
exit_timestamp - integer
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.