Design Uber – Frontend System Design

We’ll walk through the frontend system design for the Uber rider app on the web: the screen where you pick a destination, compare UberX and Comfort prices, request a car, and watch it drive toward you. You’ll see why the map must live outside React, how the trip lifecycle becomes an explicit state machine, and how a driver marker that only gets a new position every four seconds still glides smoothly along the street.
The interviewer is not asking you to build a dispatch system. Matching, pricing, and routing are backend problems. Your job is the part the rider touches: a map that stays at 60fps on a mid-range phone, a request flow that never double-books a car, and a trip screen that tells the truth after a tunnel, a background tab, or a dead socket.
Problem Statement
Design the frontend for a ride-hailing rider app like Uber, on mobile web and desktop web.
Requirements:
- Show the rider’s location on a map and let them set a pickup point
- Search for a destination with autocomplete
- Show the route and a fare estimate for each product (UberX, Comfort, UberXL)
- Request a ride, then show matching, the assigned driver, and a live car on the map
- Show ETA updates through pickup, the trip, and drop-off
- Cancel, rate, tip, share trip status, and contact the driver
Describe the client architecture, the data model, the trip state flow, and the realtime protocol.
Interviewers are checking three things. Can you keep a heavy map SDK from fighting your UI framework? Can you model a long, multi-actor workflow so the screen is never in an impossible state? And do you treat the server as the source of truth when the network is unreliable?
Clarifying Questions
| # | Question | Interviewer’s Answer |
|---|---|---|
| 1 | Rider app, driver app, or both? | Rider only. The driver app is a black box that sends GPS. |
| 2 | Native or web? | Mobile web first (think m.uber.com), desktop web second. |
| 3 | How often does the driver’s location update? | About every 4 seconds while a trip is active. |
| 4 | Do we build our own map renderer? | No. Use a vector tile map SDK. Focus on how you integrate it. |
| 5 | Is the fare fixed when the rider requests? | Yes. Show an upfront price from a quote that expires. |
| 6 | What networks should we expect? | Anything from office Wi-Fi to a 3G phone in a parking garage. |
| 7 | Scheduled rides, pooling, multiple stops? | Out of scope. Mention how the model would extend. |
Question 3 sets the core rendering problem. Four seconds is far too slow to move a marker by jumping, so you need interpolation. Question 5 tells you the quote is a real object with an id and an expiry, not a number you compute on the client. Question 6 tells you the realtime channel will drop, so reconnect and resync are part of the design, not an edge case.
Uber has publicly described m.uber.com as a lightweight progressive web app built for slow networks, so bundle size and offline behavior are fair game in this interview.
Requirements
Functional
- Detect the rider’s location and place a draggable pickup pin. Reverse geocode the pin to a street address.
- Destination search with autocomplete, recent places, and saved places (Home, Work).
- Route preview polyline from pickup to destination, fitted to the visible part of the map.
- Product list with an upfront price and pickup ETA per product. Payment method picker.
- Request a ride. Show matching, then driver details (name, photo, car, plate) and a live car marker.
- ETA to pickup, then ETA to drop-off. Cancel with a fee preview. Rate and tip after the trip.
- Share trip status with a contact. Call or message the driver without revealing either number.
Non-Functional
- Map pans and the car animates at 60fps on a mid-range Android phone.
- Interactive in a few seconds on a slow 3G connection. The core request flow is a small bundle.
- Exactly one trip per request tap, even with retries and double taps.
- After any disconnect, the screen converges to the server’s trip state within seconds.
- Low battery and data use: no high-accuracy GPS once pickup is confirmed, one socket per active trip.
- Screen reader users hear every trip state change, but not every location update.
Two of those lines drive most of the design. “Exactly one trip per tap” means idempotency keys. “Converges to the server’s state” means the client keeps a versioned copy of the trip and never trusts its own guess over a server snapshot.
Napkin Math
| Metric | Estimate | Calculation | So what? |
|---|---|---|---|
| Location messages per trip | ~375 | (5 min to pickup + 20 min ride) = 1,500 s / 4 s | Bandwidth is not the problem. |
| Data per trip | ~56 KB | 375 × ~150 bytes of JSON | JSON is fine. No need for a binary protocol. |
| Distance between fixes | ~56 m | 50 km/h ≈ 13.9 m/s × 4 s | At ~2 m per CSS pixel, a raw update jumps ~28 px. |
| Frames between fixes | 240 (480 at 120Hz) | 4 s × 60 fps | Per-frame work must be O(1) and skip React. |
| Gateway fan-out | ~250,000 msgs/s | 1M concurrent trips / 4 s (hypothetical) | Server problem. The client subscribes to one trip. |
| Autocomplete calls per search | ~3 instead of ~15 | 15 keystrokes, 200 ms debounce, typing in bursts | Debounce + abort cuts cost and stale results. |
The row that matters is “frames between fixes”. You render 240 frames from one data point. If each of those frames re-renders a React tree, you’ve lost the budget on a phone. That number is why the animation lives in a requestAnimationFrame loop that talks to the map directly.
Architecture
The client has four layers. The key decision is that React renders the panels, but it never owns the map.
| Layer | Owns | Runs on | Talks to |
|---|---|---|---|
| UI Shell | Search sheet, product picker, trip panel, live region | React, main thread | Reads trip store, dispatches events |
| Trip Core | State machine, trip store, quotes, location | Plain TypeScript | Map adapter, network clients |
| Map Layer | Map SDK instance, sources, markers, camera | WebGL canvas, rAF loop | Receives commands, emits camera events |
| Network | WebSocket, REST client, service worker | Main thread + worker | Rider API, realtime gateway, push |
The trip core is framework-free. The same store feeds React (through useSyncExternalStore) and the map adapter (through a plain subscription), so neither can make the other re-render.
“React renders the bottom sheet. The map is an imperative object behind an adapter, and the car marker is moved by a rAF loop, so a location update never touches the React tree.”
Data Model
The trip is the central object, and the server owns it. The client keeps the latest snapshot plus its version, a counter the server increments on every change. Driver locations are a separate stream. They are high frequency, throwaway, and never bump the trip version.
type TripId = string & { readonly __brand: "TripId" };
type ProductId = "uberx" | "comfort" | "uberxl";
type TripStatus =
| "matching"
| "driverEnRoute"
| "arrived"
| "onTrip"
| "completed"
| "canceled"
| "noDriversFound";
interface Place {
id: string;
label: string; // "1 Market St"
lat: number;
lng: number;
accuracyM: number | null; // only for GPS fixes
source: "gps" | "search" | "pin";
}
interface FareQuote {
quoteId: string;
productId: ProductId;
amount: { cents: number; currency: string };
surgeMultiplier: number;
expiresAt: string; // ISO 8601, server clock
pickupEtaSeconds: number;
}
interface Trip {
id: TripId;
status: TripStatus;
version: number; // monotonically increasing per trip
productId: ProductId;
quoteId: string;
pickup: Place;
destination: Place;
route: { polyline: string; distanceMeters: number; durationSeconds: number } | null;
driver: { firstName: string; rating: number; vehicle: string; plate: string; photoUrl: string; contactId: string } | null;
etaSeconds: number | null;
paymentMethodId: string;
}
interface DriverLocation {
tripId: TripId;
seq: number; // per-trip sequence, detects reordering
lat: number;
lng: number;
heading: number; // degrees clockwise from north
recordedAt: number; // epoch ms on the driver’s phone
}
Three choices are worth defending.
A version, not timestamps. Client and server clocks disagree. A version number gives a total order per trip with no clock involved: if an incoming snapshot’s version is not greater than yours, drop it.
Route as an encoded polyline. The route arrives as a compact string in the encoded polyline format (5 decimal places of precision). Decode it once into an array of coordinates and precompute cumulative distances. The marker animator needs both.
No phone number. contactId is an opaque handle the server turns into a relay call or masked number. The driver’s real number is never in the payload, so it can’t leak through devtools, logs, or a screenshot of the network tab.
The Map: Keep It Out of React
A vector tile map SDK (MapLibre GL JS, Mapbox GL JS, or the Google Maps JavaScript API) owns a WebGL canvas, a tile cache, a camera, and its own render loop. It is a stateful imperative object. Recreating it is expensive, and it re-renders itself whenever its sources change.
The common mistake is passing center, markers, and route as props and letting React diff them. Every parent render then risks resetting the camera mid-pinch or rebuilding markers.
Instead, mount the map once into a container, and wrap it in a small adapter with intent-level methods. The rest of the app calls the adapter. Only the adapter knows the SDK.
export interface MapAdapter {
setPickup(p: LngLat | null): void;
setDestination(p: LngLat | null): void;
setRoute(line: LngLat[] | null): void;
setDriver(p: LngLat | null, headingDeg?: number): void;
fitTo(points: LngLat[], padding: Padding): void;
onCameraIdle(cb: (center: LngLat) => void): () => void;
destroy(): void;
}
The React side is a single container component that renders an empty div, creates the adapter in a mount effect, hands it to its parent through a stable callback, and destroys it on unmount. It never re-renders the map. Inside the adapter, each concern (route, pickup, destination, driver) is one GeoJSON source or marker created once on the map’s load event, and each setter updates that source in place. Swapping MapLibre for Google Maps then means writing a second adapter, not touching screens.
Three details make this work in practice.
- Update sources, don’t rebuild layers. The route is one GeoJSON source added on the map’s
loadevent. Changing the route callssetData. Style layers are defined once. - Use a DOM marker or a symbol layer for the car. One car is fine as a DOM marker with
setLngLatandsetRotation. If you show ten nearby cars while idle, a symbol layer fed by one source scales better than ten DOM nodes. - Pad the camera for the bottom sheet. On mobile the sheet covers half the screen.
fitTotakes a padding equal to the sheet height so the route is centered in the visible part of the map, not behind the panel.
Pickup and Destination
Geolocation
The Geolocation API needs a secure context (HTTPS) and a user permission. Use watchPosition rather than one getCurrentPosition call. The first fix is often coarse (Wi-Fi or cell based), and later fixes tighten as GPS warms up.
Wrap this in a location service with one function: start watching, and get back a stop function. It reports fixes as { lat, lng, accuracyM, at } and failures as one of four reasons: "denied", "unavailable", "timeout", or "unsupported". The UI maps each reason to a fallback (see the table below) instead of handling raw GeolocationPositionError codes. Use high accuracy, accept a cached fix up to about 10 seconds old, and time out after about 15 seconds so a rider in a garage isn’t stuck waiting.
Stop the watch with clearWatch once the rider confirms pickup. High-accuracy GPS drains the battery, and you don’t need the rider’s location after that point. The driver’s app is the one that streams position.
Ask for permission in context, after the rider taps “Use my location” or opens the pickup step, not on page load. A prompt with no context gets dismissed, and after repeated dismissals some browsers stop showing it and block the request automatically. Check navigator.permissions.query({ name: "geolocation" }) where supported to decide whether to show the button or the typed fallback first.
| Situation | What the rider sees | Why |
|---|---|---|
| Accuracy under ~50 m | Pin placed on the fix, address shown | Good enough to hail |
| Accuracy 50–500 m | Accuracy circle, “Confirm pickup” with a draggable pin | Wrong side of the block is a real cost |
| Permission denied | Pickup search field focused, map on an approximate city | The flow still works without GPS |
| Timeout or unavailable | Last saved place or typed pickup, retry button | Indoors and garages are common |
The approximate city comes from a server-side IP lookup, so a denied-permission user never sees a blank world map.
The pickup pin
The pin is fixed in the center of the map container and the map moves under it. When the camera settles (the SDK’s moveend or idle event), reverse geocode the center. Don’t geocode on every move event: a single drag fires dozens of them.
Destination autocomplete
Autocomplete has three classic bugs: too many requests, results for an old query overwriting a newer one, and a list that isn’t usable by keyboard. Debounce fixes the first, AbortController fixes the second, and the ARIA combobox pattern fixes the third.
A small places search service owns this, outside the component. Its state is the in-flight AbortController, a debounce timer, a session token, and a per-query result cache.
- Search trims and lowercases the query, returns nothing under two characters, and serves cache hits immediately. Otherwise it waits 200ms of quiet, aborts the previous request, and sends the new one with the rider’s location and the session token.
- Abort errors are swallowed, because an aborted request is not a failure. Any other error returns an empty list so the field stays usable.
- Select fetches place details with the same session token, then rotates the token.
The component only renders the listbox and wires the ARIA combobox attributes. That split keeps the race-condition logic testable without a DOM.
Bias results with the rider’s location (near), so “Starbucks” means the one nearby. If you cache by query, include a coarse location in the key or clear the cache when the pickup city changes.
The session token is a real pattern from place APIs. The Google Places API, for example, groups the keystroke requests and the final details request into one billing session when you pass the same token. Generate a new token after each selection.
Before the rider types, show recent and saved places from local storage. The best autocomplete request is the one you don’t make.
Route preview and fares
Once both ends are set, one call returns the route and every product’s quote together. Draw the polyline, call fitTo with the bottom sheet padding, and render the product list.
A quote is a promise from the server: this price, for this product, until expiresAt. Uber calls this upfront pricing. The client never computes a fare. It displays one.
- Track a clock offset. When a response includes the server time, store
offsetMs = serverNow - Date.now(). The remaining time isDate.parse(quote.expiresAt) - (Date.now() + offsetMs). Without the offset, a phone with a wrong clock shows expired quotes as valid. - Refresh quotes in the background shortly before they expire, and when the tab becomes visible again.
- If the new price differs, highlight the change. Never silently send a request with a price the rider didn’t see.
- If the server answers
409 quote_expiredto a request, fetch a new quote and ask the rider to confirm again.
The payment method sits on the same sheet. Default to the last used method and show it on the request button (“Request UberX · Visa 4242”), so the rider confirms price and payment in one glance.
The Trip State Machine
A trip has more than ten states, three actors (rider, driver, server), and several exits. If you model it with booleans like isSearching, hasDriver, and isCanceled, you will ship a screen that shows a driver card and a “finding your ride” spinner at the same time.
Model it as a discriminated union. Each state carries exactly the data it needs, and the TypeScript compiler won’t let you read trip.driver in a state that has no trip.
There are two kinds of states. The blue ones in the diagram (idle, searching, choosing a product, requesting, rating) exist only on the client. The green ones mirror the server’s trip.status. On the client, they collapse into one state, trip, whose sub-state is whatever the latest snapshot says.
type RiderState =
| { kind: "idle" }
| { kind: "searchingDestination"; pickup: Place | null }
| { kind: "choosingProduct"; pickup: Place; destination: Place; quotes: FareQuote[] }
| { kind: "requesting"; quote: FareQuote; idempotencyKey: string }
| { kind: "trip"; trip: Trip }
| { kind: "rating"; trip: Trip };
type RiderEvent =
| { type: "FOCUS_SEARCH"; pickup: Place | null }
| { type: "QUOTES_LOADED"; pickup: Place; destination: Place; quotes: FareQuote[] }
| { type: "REQUEST"; productId: ProductId; idempotencyKey: string }
| { type: "REQUEST_FAILED" }
| { type: "TRIP_SNAPSHOT"; trip: Trip }
| { type: "OPEN_RATING" }
| { type: "DONE" };
A pure reducer maps (state, event) to the next state. Every event except TRIP_SNAPSHOT is only valid from specific states, and an event in the wrong state returns the current state unchanged rather than throwing. REQUEST only works from choosingProduct and only if the chosen product has a quote. OPEN_RATING only works once the trip status is completed. REQUEST_FAILED and DONE reset to idle.
The rule that matters is in TRIP_SNAPSHOT. It is accepted from any state, as long as it is newer. If the rider reloads the page mid-trip, the app boots in idle, calls GET /trips/active, and jumps straight to the right screen. The client never moves a server state forward on its own. If the ETA hits zero, it does not invent “arrived”. It waits for the server to say so.
Cancel and failure paths
- Rider cancels. Fetch a fee preview first. Cancellation is usually free for a short window after matching, then a fee applies. Show the number before the rider confirms.
- Driver cancels. The server usually re-dispatches, so the status goes back to
matchingwith a new version. The UI says “Your driver canceled. Finding you another ride.” - No drivers found. A server-side timeout. Offer retry, or switch to another product, keeping the destination.
- Request in flight when the tab dies. On the next load,
GET /trips/activefinds the trip. The idempotency key makes a retried POST return the same trip instead of a second one.
Live Driver Tracking
The request is a REST call. Everything after it is pushed. The client opens a WebSocket, subscribes to its trip with the version it already has, and receives two kinds of messages: trip.updated (rare, versioned, drives the state machine) and driver.location (every ~4 seconds, drives the marker).
Keep the two paths separate. A trip update goes through the reducer and React. A location update goes straight to the marker animator.
Interpolation
If you set the marker to each new point, the car teleports ~56 m every four seconds. If you interpolate in a straight line between points, the car cuts corners through buildings. The fix is to animate along the route polyline.
- Drop stale fixes. If
seqis not greater than the last one seen, ignore it. Messages can be duplicated or reordered across a reconnect. - Snap to the route. Project the fix onto the nearest segment of the decoded polyline and convert it to “meters along the route”. A one-dimensional number is trivial to interpolate.
- Retarget from where the marker is now. Start the new animation from the currently displayed distance, not from the previous fix. If a fix arrives mid-animation, the car changes speed slightly instead of jumping.
- Use the fix interval as the duration. Animate over
recordedAtminus the previousrecordedAt, clamped to 1–6 seconds. The marker then moves at the driver’s real speed, about one interval behind. - Hold when data is late. When an animation finishes and no new fix has arrived, stop. Don’t extrapolate ahead. A car that drives past the rider and then snaps back looks broken.
The marker animator is a plain object created per trip with the map adapter and the decoded route. It exposes one method, onFix, and keeps its state in a closure: last seq, last recorded time, the displayed distance along the route, the animation’s start and end distances, and the current heading.
- Snap or fall back. Each fix is projected to meters along the route. If it is more than about 40 m off the route, the animator draws the raw point and the app asks for an updated route.
- Jump instead of animate on the first fix, after a gap over 30 seconds, or when the tab is hidden. Animating a two-minute gap looks like a car on fast forward.
- Hold on backward jitter. A fix behind the displayed distance is ignored, so the car never reverses.
- Animate from the displayed distance to the target over the clamped fix interval, using one
requestAnimationFrameloop that stops when the animation completes.
Details that are easy to miss:
- Heading takes the shortest arc. Rotating from 350° to 10° should turn 20° clockwise, not 340° the long way. Compute the turn as a signed delta in the range −180° to 180° and ease toward it.
- The heading follows the road, not the fix. GPS heading is noisy at low speed. Use the bearing of the route segment the marker is on, and only fall back to the fix’s heading when the car is off route.
- The loop stops when idle. No rAF runs once the animation finishes. A permanent 60fps loop costs battery for nothing.
- Off route means reroute. If a fix is more than ~40 m from the polyline, the driver took a different road. Draw the raw point and ask the server for the updated route, which arrives as a new trip version.
ETA updates
ETA comes from the server, which knows traffic. It arrives as a trip update with a version bump when the rounded minute changes, not on every location tick. Between updates, count down locally so the display doesn’t freeze.
State and Data Flow
Every piece of state has exactly one owner. Most bugs here come from two places owning the same thing, like a local “arrived” flag that disagrees with the server.
| State | Owner | Lives in | Updated by |
|---|---|---|---|
| Trip status, driver, ETA | Server | Trip store (versioned) | Snapshots from socket or REST |
| Car position on screen | Marker animator | Closure + map SDK | Location fixes, rAF |
| Camera, zoom, pan | Map SDK | SDK instance | User gestures, fitTo |
| Pickup, destination, quotes | Client | State machine | User events |
| Recent places, last payment | Client | localStorage | Completed trips |
Reconnect and resync
Tunnels, elevators, Wi-Fi to cellular handoffs, and background tabs all close the socket. Recovery has to be boring and deterministic.
A trip connection module owns the socket lifecycle for one trip. It takes the trip id, the API client, the trip store, and the marker animator, and returns a disconnect function.
- Open: fetch a short-lived, trip-scoped realtime ticket over REST, open the socket, and subscribe with the ticket and the store’s current version. If the ticket request fails, go straight to reconnect.
- Route messages:
trip.updateddispatches aTRIP_SNAPSHOTto the store,driver.locationgoes to the animator, andresync_requiredtriggers a REST refetch. - Close: unless the caller disconnected on purpose, wait a randomized backoff delay, resync over REST, then open again. A successful open resets the attempt counter.
- Resync over REST first, then resubscribe. The snapshot fixes anything you missed. The subscribe message carries the new version, so the gateway only sends what comes after it.
- Full jitter backoff. If a gateway node restarts, a million clients reconnect at once. Random delays spread them out.
- App-level heartbeats. The browser WebSocket API can’t send protocol ping frames. Send a small
pingmessage every ~20 seconds and reconnect if nopongarrives. A half-open socket on a mobile network can look connected for minutes. - Polling fallback. Some corporate proxies block WebSockets. After repeated failures, poll
GET /trips/:idevery few seconds. The UI doesn’t care which transport delivered the snapshot. - Listen to
online. When the browser fires theonlineevent, reset the backoff and reconnect right away. Don’t trustnavigator.onLine === trueto mean the internet works, only that a network interface is up.
Unlike a chat application, there is no message history to replay. Only the latest trip snapshot matters.
Background tabs
A rider requests a car, then switches to a messaging app. When the tab is hidden, browsers stop running requestAnimationFrame and throttle timers. Mobile browsers may freeze the page entirely and drop the socket.
- On
visibilitychangeto hidden, stop the animator. There is nothing to draw. - On
visibilitychangeto visible, resync the trip and jump the marker to the latest fix. Don’t replay a backlog of animations: the rider wants to know where the car is now.
Push and SMS fallback
The most important moment is “Your driver has arrived”, and it often happens while the tab is in the background. Don’t rely on the page to tell the rider.
- Web push. With permission, the service worker receives a
pushevent and callsshowNotification. Use the trip id as the notificationtagso “arriving” is replaced by “arrived” instead of stacking. On iOS, web push only works for web apps added to the Home Screen (iOS 16.4 and later). - SMS. The server knows whether the client acknowledged the update. The client sends
{ type: "ack", version }for each trip update. If an important state change is not acknowledged within a few seconds and there is no push subscription, the server sends a text message.
API
REST for request-response actions, one WebSocket per active trip for pushed updates.
// REST
GET /v1/places/autocomplete?q=&lat=&lng=&session= // suggestions
GET /v1/places/:placeId?session= // lat/lng, address
GET /v1/places/reverse?lat=&lng= // address + suggested pickup spots
POST /v1/quotes { pickup, destination } // { route, quotes: FareQuote[], serverTime }
POST /v1/trips { quoteId, paymentMethodId } // header Idempotency-Key; 201 Trip | 409 quote_expired | 402
GET /v1/trips/active // Trip | 204, used on boot
GET /v1/trips/:id // resync snapshot
GET /v1/trips/:id/cancel-preview // { feeCents }
POST /v1/trips/:id/cancel // Trip (status canceled)
POST /v1/trips/:id/share // { url, expiresAt }, read-only link
POST /v1/trips/:id/contact // { relayNumber } or in-app call session
POST /v1/trips/:id/rating { stars, tipCents? }
POST /v1/realtime/ticket { tripId } // { ticket, expiresAt }
// WebSocket: wss://rt.example.com/v1
type ClientMessage =
| { type: "subscribe"; ticket: string; tripId: TripId; sinceVersion: number }
| { type: "ack"; tripId: TripId; version: number }
| { type: "ping"; t: number };
type ServerMessage =
| { type: "trip.updated"; trip: Trip }
| { type: "driver.location"; location: DriverLocation }
| { type: "resync_required"; tripId: TripId }
| { type: "pong"; t: number };
The Idempotency-Key header is the most important line in the API. Generate a UUID when the rider taps Request, store it in the requesting state, and send the same key on every retry. The server returns the original trip for a repeated key. A double tap, a retried timeout, or a refresh during the request all produce one trip.
Send the trip as a full snapshot in trip.updated, not a patch. A trip is a few hundred bytes. Full snapshots mean a missed message can never leave the client with a half-applied state.
Optimizations
| Problem | Technique | Effect |
|---|---|---|
| Map SDK is a large bundle | Load it in parallel with the shell, show a static placeholder | Search is usable before the map is |
| React re-renders on location | Location goes to the animator, not the store | Zero React work per fix |
| Marker jumps every 4 s | Interpolate along the route at display rate | Smooth, believable motion |
| Autocomplete floods the API | Debounce, abort, cache, recent places | A few requests per search |
| Reverse geocode on every drag frame | Geocode on camera idle only | One request per pin drop |
| Slow first load on 3G | Service worker caches the app shell and map style | Repeat visits open instantly |
| Battery drain | Stop watchPosition after pickup, stop rAF when idle |
No idle GPS or render loop |
Handling Edge Cases
- Offline at request time. Disable the Request button and say why. Never queue a ride request to send later. A car that shows up 20 minutes after the rider gave up is worse than an error.
- Quote expires on the sheet. Refetch quietly. If the price went up, show the new price and require a new tap.
- Payment declined. A
402keeps the rider on the product sheet with the payment picker open. Card challenges such as 3-D Secure open in the payment provider’s flow and return to the same state. - Driver GPS freezes. The marker holds at the last fix. After ~30 seconds without a fix, show “Location updating” next to the car instead of pretending it is parked.
- Driver reassigned. A new version arrives with a different
driver. Replace the card, reset the animator (newseqspace), and announce the change.
Accessibility and Security
Accessibility
The map is a canvas. A screen reader can’t read a moving car. So everything the map shows must also exist as text in the trip panel: driver name, car, plate, ETA, and pickup address.
- Announce state changes, not ticks. Put a polite live region (
aria-live="polite") in the trip panel. Write to it when the trip status changes: “Driver found. Alex, white Toyota Camry, plate 7ABC123, 4 minutes away.” Never write location updates to it. One announcement every four seconds makes a screen reader unusable. - Throttle ETA announcements. Announce ETA only when it changes by a meaningful amount or crosses a threshold such as “1 minute away”.
- Autocomplete as a combobox. The search
<input>getsrole="combobox",aria-expanded,aria-controlspointing at arole="listbox", andaria-activedescendantfor arrow-key selection. - Keyboard paths. Pickup can be typed, not only dragged. Focus moves to the new panel heading when the state changes.
- Reduced motion. With
prefers-reduced-motion, use instant camera moves instead of fly animations. Keep the car moving, because its position is information.
Security and privacy
- Masked contact. Calls and messages go through a relay identified by
contactId. Neither party sees the other’s phone number, and the relay stops working after the trip. - Scoped tokens. The realtime ticket is short-lived and scoped to one trip. Send it in the first socket message rather than the URL, so it doesn’t end up in proxy logs.
- Location only while it matters. The rider receives the driver’s location only between match and drop-off. The gateway stops the stream when the trip ends, and the client discards the route.
- Share trip links. The link from
POST /trips/:id/shareis read-only, shows the route, car, and ETA, and expires when the trip ends. Usenavigator.share()where supported, and fall back to copying the link withnavigator.clipboard.writeText. - Payment data. Card entry uses the payment provider’s hosted fields, so the card number never touches your JavaScript or your servers.
- Safety UI. Show the plate prominently so the rider can check it before getting in. Keep an emergency button on the trip screen that opens a
tel:link to the local emergency number.
What a Strong Answer Sounds Like
| Topic | Junior answer | Senior answer |
|---|---|---|
| Map | <Map markers={…} /> component | Mount once, imperative adapter, sources updated in place |
| Trip flow | Booleans in a store | Discriminated union, server-owned states, versioned snapshots |
| Driver location | Set marker on each message | Snap to route, retarget, hold when late, shortest-arc heading |
| Reliability | “WebSocket reconnects” | REST resync, sinceVersion, jittered backoff, polling fallback |
| Requesting | POST on click | Quote id, expiry with clock offset, idempotency key |
| Accessibility | Alt text on the map | Text trip panel, live region for state changes only |
Conclusion: How to Design Uber
Start with the boundary: React renders the panels, an imperative adapter owns the map, and a small trip core owns state. Model the trip as a state machine where the client owns the steps before the request and the server owns everything after it. Every server state arrives as a versioned snapshot, and older versions are dropped.
Then show the interviewer the two details most candidates skip. A request is a quote id plus an idempotency key, so it can be retried safely. And a driver marker that updates every four seconds is animated along the route from wherever it is drawn now, with the socket, REST resync, and push all feeding the same snapshot. If you can explain why the car should hold instead of guessing ahead, you’ve shown you understand realtime UI on unreliable networks.
