Design Uber SOS Feature
Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2024-04-17
Problem Statement
Design the SOS / Emergency Alert feature of a ride-hailing platform like Uber, which allows a rider (or driver) to trigger an emergency alert during a ride. The system should immediately notify emergency contacts, Uber's safety team, and optionally local law enforcement or a safety helpline.
🎯 Functional Requirements:
1.SOS Button
•Available in-app during a ride
•One-tap trigger for emergencies
2.Emergency Alert Flow
•Send alerts to user’s registered emergency contacts
•Notify Uber's backend safety team instantly
•Optionally call or send info to local emergency services
3.Live Location Sharing
•Share real-time ride location and driver details
•Continuously update until the alert is cleared
4.Event Logging & Monitoring
•Log event with timestamp, location, ride ID, user ID
•Safety team dashboard to view and respond
5.Post-Incident Handling
•Ability to mark alert as resolved
•Feedback collection or follow-up call
⚙️ Non-Functional Requirements:
•High availability and reliability
•Low-latency alert propagation (<1 second)
•Secure and tamper-proof logging
•Scalable to millions of active rides
•Data privacy (encrypt sensitive data at rest and in transit)
🧱 Key System Components:
1.Client App (Rider/Driver)
•UI for SOS trigger
•Access GPS/location and ride metadata
•Fallback option for SMS or offline SOS (optional)
2.Emergency Alert Service
•Receives SOS event from client
•Publishes event to all relevant subsystems (via Kafka/pub-sub)
3.Location Streaming Service
•Starts streaming live GPS coordinates
•Sends updates every few seconds to backend and contacts
4.Notification Service
•Push notifications to Uber safety team app
•SMS/email to emergency contacts
•API integration with emergency services (if applicable)
5.Safety Team Dashboard
•Internal UI for real-time monitoring of active SOS incidents
•Contact options: call rider, contact law enforcement, view ride
6.Audit Logging Service
•Stores SOS event data for compliance and follow-up
•Immutable, tamper-proof logs
7.User Preferences Service
•Stores emergency contacts, alert settings, previous reports
🗂️ Data Models (Simplified):
SOSAlert
1json
2CopyEdit
3{
4 "alert_id": "uuid",
5 "ride_id": "ride123",
6 "user_id": "user456",
7 "triggered_at": "2025-07-23T12:00:00Z",
8 "status": "ACTIVE | RESOLVED",
9 "location": {
10 "lat": 12.9716,
11 "lng": 77.5946
12 }
13}EmergencyContact
1json
2CopyEdit
3{
4 "user_id": "user456",
5 "contacts": [
6 {"name": "Dad", "phone": "+911234567890"},
7 {"name": "Sister", "phone": "+911112223334"}
8 ]
9}🔁 Sequence Flow:
1.Rider presses SOS button
2.Client sends SOS request with ride/location to Emergency Alert Service
3.System:
•Triggers real-time location sharing
•Sends alerts to emergency contacts
•Notifies Uber Safety Team
4.Live GPS continues streaming until SOS is resolved
5.Safety Team can view ride, call rider, dispatch help
6.User manually resolves or system auto-resolves after timeout (e.g., 15 minutes)
7.Event is logged and archived for compliance
🔐 Security & Privacy:
•Use TLS for data transmission
•Encrypt user data at rest
•Access to safety dashboard only via RBAC
•Redact sensitive details after X days (for GDPR compliance)
📈 Scalability Considerations:
•Use Kafka to decouple alert triggering and downstream processing
•WebSocket or GRPC stream for live location updates
•Scalable push/SMS infra (e.g., Firebase, Twilio, SendGrid)
•High-availability DB (PostgreSQL/CockroachDB) for logs
🧪 Optional Enhancements:
•Background trigger (e.g., shake phone 3x)
•Auto-SOS if trip goes off expected route
•AI-based anomaly detection (prolonged stops, deviation, no movement)
•Real-time audio recording (with consent)