Uber Clone Scenario
DDD/CQRS/Event Sourcing model for a ride-hailing platform inspired by Uber. Deep dive into building blocks, lifecycle, and data flows.
Context
Users request rides; drivers accept; rides are started, completed, and paid. System must handle surge pricing, routing, and safety checks across multiple regions.
Key Building Blocks
- Actors: Rider, Driver
- Aggregates: Ride
- Domain Events: RideRequested, DriverAssigned, RideStarted, RideEnded, RideCancelled
- Commands: RequestRide, AcceptRide, StartRide, EndRide, CancelRide
- Read Models: RideDetails, DriverAvailability
Lifecycle
- Rider requests a ride (RequestRide).
- System assigns a nearby Driver (DriverAssigned).
- Driver begins trip (RideStarted).
- Trip ends at destination (RideEnded).
- Payment processed and recorded (PaymentProcessed).
Policies
- Surge pricing policy during demand spikes.
- Cancellation penalties and refunds.
- Driver safety checks and rider verification.
Integrations
- Maps and routing services
- Payment gateways
- Notification channels
Historical Events
Event history allows reconstruction of each ride lifecycle for auditing and analytics.
RideRequested | DriverAssigned | RideStarted | RideEnded | PaymentProcessed