Why this matters
- Snapchat Map, Find My, and StreamHub's "friends watching nearby" share the same pattern: frequent writes, infrequent reads, strict privacy boundaries.
- Unlike ride-hailing (millions of strangers), friend graphs are sparse — you query locations for 50–500 friends, not the entire user base.
- Battery drain from constant GPS polling is a product killer; adaptive update intervals are a design requirement, not an optimisation.
Nearby Friends components
- Location publisher — client sends lat/lng on interval (adaptive: 30s stationary, 5s moving).
- Friend graph service — bidirectional friendship with privacy settings (share with all, select friends, ghost mode).
- Location store — per-user latest position with TTL; Redis GEO or geohash-indexed KV.
- Query service — given user A, fetch friend IDs, batch-lookup positions, filter by radius and privacy.
- Push notifier — alert when a friend enters your radius ("Alex is 500m away").
Architecture overview
Proximity / ride-matching
PUT /v1/location
Authorization: Bearer <token>
Content-Type: application/json
{
"lat": 37.7749,
"lng": -122.4194,
"accuracy_m": 12,
"timestamp_ms": 1740847200000
}
GET /v1/friends/nearby?radius_m=1000
Authorization: Bearer <token>
→ 200
[
{ "user_id": "usr_42", "lat": 37.7751, "lng": -122.4188, "distance_m": 320, "updated_at": "..." },
{ "user_id": "usr_99", "lat": 37.7730, "lng": -122.4210, "distance_m": 890, "updated_at": "..." }
]
Privacy model
| Aspect | Setting | Behaviour |
|---|---|---|
| Ghost mode | User invisible to everyone | Location not stored or published |
| Select friends | Whitelist of user IDs | Only listed friends see location |
| Approximate location | Snap to 1 km grid | Hides exact address while showing area |
| Time-limited sharing | Auto-expire after 8 hours | Reduces forgotten-sharing risk |
Ghost mode
SettingUser invisible to everyoneBehaviourLocation not stored or publishedSelect friends
SettingWhitelist of user IDsBehaviourOnly listed friends see locationApproximate location
SettingSnap to 1 km gridBehaviourHides exact address while showing areaTime-limited sharing
SettingAuto-expire after 8 hoursBehaviourReduces forgotten-sharing risk
Privacy checks happen server-side on every query — never trust the client to filter friends.
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 5 sections
- Efficient friend-based lookup
- Adaptive update intervals
- Geofence notifications
- Scale estimates
- Data retention and compliance
Test yourself
Answer these before moving on — recall is what makes it stick.