Preparing your design workspace

Loading the problem and your saved attempt…

Design and Implement Ride Dispatch and Trip Lifecycle

Model the objects and executable core for requesting a ride, assigning one available driver, and completing or cancelling the trip safely.

Design and implement the core domain layer of a ride-hailing service. For this exercise, assume a rider requests a ride with a pickup and destination, the service selects one nearby available driver, and the driver may accept before the trip moves through arrived, in-progress, and completed states.

A rider or driver may have at most one active trip, and one driver must never be assigned to two riders concurrently.

For the bounded implementation, keep pricing, payments, route optimization, maps, persistence, networking, and real-time GPS streaming outside scope; use in-memory state and no external services. Use an injectable driver-matching strategy so a simple deterministic nearest-driver implementation can be replaced later.

Invalid state transitions and assignment conflicts must return explicit errors. Implement the dispatch and lifecycle core in the language of your choice and make it testable without external services.

For the design-only follow-ups, assume the same state and assignment invariants must survive after durable storage is introduced and committed trip-state events are published asynchronously to Kafka; no database, broker, or networking code is required.