Skip to main content

Design Uber (Mobile)

Concepts Utilized: Real-Time Location (GPS/Core Location), WebSocket for Updates, Map Rendering, Geofencing, Battery Optimization, Push Notifications, Payment SDK Integration, Offline Handling

This document covers the mobile architecture for a ride-sharing application with real-time location tracking, map rendering, and ride state management.

Features

FeatureDescription
Real-time location trackingContinuous GPS updates during active rides
Map displayRendering driver positions and route visualization
Ride request and matchingDriver assignment and acceptance flow
ETA updatesDynamic arrival time calculations
Payment processingIn-app payment via integrated SDKs
Push notificationsRide status and driver arrival alerts

Real-time Location

Location Service

The location service manages GPS accuracy levels and transmits coordinates to the server.

Implementation approach: Create a location manager and configure desired accuracy and distance filter. Start tracking to receive location updates. In the delegate callback, extract the latest location, send it to the server via WebSocket, and update local state for UI rendering.

WebSocket for Real-time Updates

WebSocket connections provide bidirectional communication for ride state changes.

Implementation approach: Create a WebSocket connection to a ride-specific endpoint. Set up a message handler that decodes incoming messages and dispatches appropriate state updates based on message type (driver location, ETA update, or ride status change). The unidirectional data flow updates the UI automatically when state changes.

Map Rendering

Marker Update Optimization

Differential updates minimize rendering overhead when driver positions change.

Implementation approach: Compare current marker IDs with new driver IDs. Remove markers for drivers no longer in the set. For drivers in the new set, either animate the existing marker to the new position or create a new marker. This differential approach avoids recreating all markers on each update, providing smooth animations and better performance.

Battery Optimization

Location accuracy settings vary based on ride state to balance precision and power consumption.

Implementation approach: Adjust location manager settings based on ride state:

  • Searching: Use low accuracy (hundred meters) and large distance filter to conserve battery while still showing approximate location
  • Matched/In ride: Use best accuracy and small distance filter for precise tracking during active rides
  • Idle: Stop location updates entirely to minimize battery drain

Technical Constraints

ConstraintImpactMitigation
Battery drainContinuous GPS polling depletes battery within hoursAdaptive accuracy based on ride state
BandwidthFrequent location updates consume dataBatch coordinates and compress payloads
Offline mapsConnectivity loss renders maps unusableCache map tiles for the local region
Location accuracyHigh accuracy increases power consumption; low accuracy causes marker jitterUse appropriate accuracy for each ride state