Phase 1: Clarify, Scope & Constraints
Interviewer: "Let's design a 'Nearby Friends' feature — like Facebook's. Users can opt in to share their real-time location and see which of their friends are physically nearby. How do you approach this?"
Candidate: "Interesting — this combines real-time location tracking, a social graph, and privacy controls. Let me clarify the core user journeys:
- Enable journey — User opts into location sharing; their phone starts sending location updates to the server
- Discovery journey — User opens the app and sees a list of friends who are currently nearby (within N km), with approximate distances ('~0.5 km away', '~2 km away')
- Privacy journey — User can pause sharing, set a 'ghost mode', or choose which friends can see them
- Notification journey — User receives a push notification when a specific friend enters their vicinity
The dominant complexity is real-time location at social graph scale. With millions of users simultaneously sending location updates every 30 seconds, and then computing 'which of my friends are near me' in near-real-time — the write throughput and the per-user spatial query are both significant challenges.
WHY: The secondary complexity is privacy. Broadcasting precise GPS coordinates to your friends violates user trust. We must show approximate locations (fuzzy to ~100m) and make the entire feature opt-in with granular controls.
Non-goals for V1:
- Turn-by-turn navigation to a friend's location
- Location history / replay ('where have you been')
- Group location sharing for events
- Persistent location storage (GDPR compliance requires ephemeral data)
- Location-based ads
Interviewer: "What's the acceptable…
In the full tutorial
- Phase 2: High-Level Architecture
- Phase 3: Deep Dive & Evolution
- Phase 4: Robustness & Operations