Needs to record when a vehicle enters
Needs to record when a vehicle exits
Need to keep track of available parking spots
List the key non-functional requirements (performance, scalability, reliability, etc.)...
Accomodate diff types of vehicles (Electric/gas, car/truck, wide/narrow)
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...
Client sends a post request to enter the parking lot and find a spot
Server receives the client's post request, looks through available parking slots that match the client's vehicle criteria, sends a get request to the database to find an available parking slot
Database receives the servers get request, finds an appropriate parking spot, packages the spot in response body, sends response back to server
Server sends response back to client with parking spot
For leaving, client sends a post request to server to leave
Server receives request, makes request to database to clear parking spot
Databse clears spot, sends response back to server
Server receives response, responds to client with all-clear
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.
Client, where the users will interface with the parking system and enter
Server, where the users will make a request for vehicle entry
Database, keeps track of the parking spots and will fill or clear for entry or exit
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...
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
Keep track of parking spots with hashing, divide up the parking spots into separate sections, give each car a hash, so it knows what section to go to, and then use collisions for cars in the same slot
Lock and key feature for assigning or releasing parking spots, in the case of multiple parking entrances, you don't want to assign a spot to one car that another car has received a slot for, once a car is in the assignment process, acquire a lock to access the database and fill out/empty a slot, then release the lock once the change is done in the database