Part 3 of 8 · 1 min read
Design
Location service, matching, trips.
Services.
- Location service: receives driver updates, keeps the latest position of each driver in a geospatial index.
- Matching (dispatch) service: finds candidate drivers for a request and assigns one.
- Trip service: owns the state of each trip and its history.
- Pricing service: estimates fare and applies surge.
- ETA and routing service: uses the map data of page 3.
- Notification service: pushes offers to drivers and updates to riders (WebSocket, with push notification as fallback, page 1).
- Payments service: charges the rider and pays the driver, with the care of page 9.
Flow of a ride.
- The rider opens the app and sees nearby drivers (a read from the location index).
- The rider asks for a price. The pricing service estimates distance and time, then applies the current multiplier.
- The rider confirms. The trip service creates a trip in state REQUESTED.
- The matching service finds nearby available drivers, ranks them, and offers the trip to the best one.
- The driver accepts within a time limit, or the offer expires and the next driver is tried.
- On acceptance the trip becomes MATCHED. The rider sees the driver and ETA.
- The driver arrives, the trip starts, and ends. The fare is computed and charged.
Dispatch
Dispatch is the step that chooses a driver for a ride request and sends the offer.
Example: a request at a station finds 12 free drivers within 2 km, ranks them by pickup time, and offers the trip to the one who is 3 minutes away.
Check yourself: 1. Which load dominates, and why? 2. What does the location service keep per driver? 3. What happens if the first driver does not accept?