Parking Lot [Low Level Design]

Use Cases :

vipul pachauri
2 min readJun 13, 2023
  1. Generate Ticket when vehicle enters
  2. Generate price when vehicle exit

Few question needs to ask with Interviewer :

  1. Candidate : What details should be in ticket ?
    Interviewer : Vehicle Number,Entry Time,Exit Time,Parking Spot Id and unique id for tracking
  2. Candidate : How do we allocate parking to vehicle ?
    Interviewer : At the time when vehicle enters
  3. Candidate : Are there different type of parking ?
    Interviewer : Yes, 2 Wheeler,4 Wheeler
  4. Candidate : How we are deciding parking spot ?
    Interviewer : We can have multiple strategies like min distance, near lift, first come first serve.
  5. Candidate : How we are generating price ?
    Interviewer : It can have different strategies like based on parking spot (2 Wheeler -> 40 Rs, 4 Wheeler -> 100 Rs), Hourly basis/minute basis

Entity :

  1. Ticket -> id, vehicle, parkingSpot, entryTime, exitTime
  2. Vehicle : id, number
  3. Parking Spot -> id, state, vehicleType
  4. State (enum) -> OCCUPIED,UNOCCUPIED
  5. VehicleType -> TWO_WHEELER,FOUR_WHEELER

APIs :

  1. Parking Service
package systemDesign.ParkingLot;

import systemDesign.ParkingLot.model.Ticket;
import systemDesign.ParkingLot.model.Vehicle;

public interface ParkingService {

Ticket entry(Vehicle vehicle);
double exit(long ticketId);
}

2. Slot Service

package systemDesign;

import systemDesign.ParkingLot.model.ParkingSlot;
import systemDesign.ParkingLot.model.Ticket;

public interface SlotService {

ParkingSlot allocate(Ticket ticket);
boolean unallocate(int parkigSlotId);
}

3. Pricing Service

package systemDesign;

import systemDesign.ParkingLot.model.Ticket;

import java.util.Date;

public interface PricingService {

double generatePrice(Ticket ticket, Date exitTime);
}

Thanks for reading !! Happy Learning !!

--

--