System Architecture
Rider App
Users enter pickup and drop-off locations using Google Places autocomplete. The app shows available vehicle types (economy, premium, SUV) with fare estimates for each. After booking, the system matches the nearest available driver and shows their name, photo, vehicle details, and live location on the map. During the ride, the tracker shows real-time progress. After drop-off, the rider rates the driver and pays via card or wallet.
Driver App
Drivers toggle availability. When online, their location is broadcast to the matching engine every 5 seconds. Incoming ride requests show the pickup location, distance, estimated fare, and the rider's rating. Drivers accept or decline within 15 seconds before the request goes to the next driver. The app provides turn-by-turn navigation, one-tap calling to the rider, and ride completion with fare confirmation.
Matching Algorithm
When a rider requests a ride, the system queries nearby available drivers using PostGIS geospatial indexes. Drivers are ranked by distance, rating, and acceptance rate. The nearest qualifying driver gets the first request. If they decline or don't respond in 15 seconds, the next driver is notified. The algorithm handles high-demand scenarios where multiple riders request simultaneously -- each driver is locked to one request at a time to prevent double-assignment.
Fare Calculation
Fares combine base fare + per-km rate + per-minute rate + surge multiplier. The system computes route distance and estimated duration using the Google Directions API. Surge pricing activates automatically when demand exceeds supply in a geographic zone. Surge multipliers (1.2x, 1.5x, 2.0x) are configurable by zone and time of day. The rider sees the estimated fare before confirming the booking.