Design an Admin Trip Assignment System
Design the APIs, data model, concurrency controls, and critical flow for administrators assigning available drivers to trips.
Problem statement
Design a trip-management system in which administrators can view trips and assign drivers. Cover the API contracts, database schema, high-level architecture, and bounded pseudocode for the concurrency-sensitive assignment flow.
For this exercise, assume trips and drivers already exist. An administrator directly assigns one available driver to one unassigned trip; rider matching, route optimization, payments, and driver payouts are out of scope.
Admin list data may be up to five seconds stale, but the assignment write must recheck authoritative state. A trip may have at most one active driver, and a driver may have at most one active trip. Every assignment request carries an idempotency key and the trip and driver revisions observed by the administrator.
Preserve an append-only audit trail. You may choose direct indexed reads or derived read views, and if you add asynchronous propagation, explain how it remains reliable.
What to build
- Administrators can page and filter trips and drivers, including unassigned trips and currently available drivers.
- An authorized administrator can assign one available driver to one unassigned trip.
- Administrators receive a stable success or conflict result and can review the durable assignment history.
At scalePractice assumption
- Retain 30 million trips and 500,000 drivers, with up to 100,000 drivers available at once.
- Serve 3,000 trip or driver list reads per second and 300 assignment attempts per second at peak.
- Admin list data may be up to five seconds stale; a committed assignment should complete within one second at p95.