Skip to the guide

Design cab booking (like Uber)

AdvancedCase study11 pages

The interviewer asks you to design the classes that pair riders with drivers. Picture a small taxi office with a board of hooks, and one key tag on a hook for each free car. The controller takes the nearest car's tag and radios the driver. If there is no answer in 15 seconds, the tag goes back and she tries the next car. While a tag is in her hand, nobody can offer that car to anyone else.

It is also asked as "design Uber", and the closest other case study is food ordering. Interviewers like it because a driver can say no or say nothing, and two riders can reach for the same car. This page keeps to one program. Matching supply and demand owns matching at scale, and ride hailing owns the system.

Below is a full 45-minute round on the LLD framework. At each Guess before you read on, stop and answer first. The full runnable project is a download in Java, JavaScript and Python.

Run the full project

This design as a project you can run, with its tests and a demo. You only need Java 21, Node 24 or Python 3.13. The README says how to run it.

Step 1 · Clarify the requirements and cut the scope

Minutes 0–5 · How this step works

Interviewer: Design cab booking.

You: A rider asks for a car, and then what does the driver see?

Interviewer: One driver gets an offer at a time. He can accept, decline or ignore it, and he has 15 seconds.

You: How is the driver chosen?

Interviewer: The nearest free one. If two are equally near, whoever has waited longest. Assume the roads form a grid, and leave out traffic.

You: How is the fare set, and is payment part of this?

Interviewer: $2.50, plus $1.50 per km started, plus 25 cents per minute started. Just return the amount.

You: Can a rider cancel, or have two trips open?

Interviewer: She can cancel until the pickup, with no fee for now. One open trip per rider.