Skip to main content
PreparationZone Logo
PrepZone

Nearby Friends Location

Continuous location sharing with privacy controls and efficient geospatial queries.

Pass checkpoint below

Read these first

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

WebSocketCLIENT
Driver appGPS every 4s
INTEGRATION
Kinesislocation stream
DATABASE
ElastiCache G…GEORADIUS
COMPUTE
Match APIEKS
CLIENT
Rider appWS assigned
Driver GPS → Kinesis → Redis GEO → match API → WebSocket to rider.
Java
PUT /v1/location
Authorization: Bearer <token>
Content-Type: application/json

{
  "lat": 37.7749,
  "lng": -122.4194,
  "accuracy_m": 12,
  "timestamp_ms": 1740847200000
}
Java
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

AspectSettingBehaviour
Ghost modeUser invisible to everyoneLocation not stored or published
Select friendsWhitelist of user IDsOnly listed friends see location
Approximate locationSnap to 1 km gridHides exact address while showing area
Time-limited sharingAuto-expire after 8 hoursReduces forgotten-sharing risk
  • Ghost mode

    SettingUser invisible to everyone
    BehaviourLocation not stored or published
  • Select friends

    SettingWhitelist of user IDs
    BehaviourOnly listed friends see location
  • Approximate location

    SettingSnap to 1 km grid
    BehaviourHides exact address while showing area
  • Time-limited sharing

    SettingAuto-expire after 8 hours
    BehaviourReduces 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.