Location and maps system-design interview
Case study: courier tracking
Requirements: courier route recording, customer live map, intermittent connectivity, low battery impact, privacy, and delivery arrival alerts.
- Courier explicitly starts a delivery session while visible.
- Location foreground service owns updates and persistent notification.
- Request balances interval, minimum distance, batching, and accuracy by trip phase.
- Samples carry monotonic measurement time, accuracy, sequence, and trip ID.
- Room stores an outbox; uploader batches, retries idempotently, and preserves order.
- Server validates plausibility and authorization, then streams latest authorized state.
- Customer map separates camera tracking mode from user-pan mode and clusters nearby deliveries if needed.
- Arrival is not one coordinate: use dwell/radius/accuracy plus server/domain evidence.
- Raw history has strict retention; customer sees only necessary current state.
- Stop ends updates/service and reconciles remaining outbox work.
Failure-injection checklist
- approximate rather than precise permission;
- permission revoked during active trip;
- device location disabled or no fix indoors;
- batch delivered out of order after offline period;
- process killed and service/session recreated;
- duplicate sample upload;
- user pans map while live driver updates arrive;
- 50,000 markers and rapid viewport movement;
- geofence enter delayed or missing;
- mock/impossible trajectory;
- API key quota exhausted;
- account switch while a prior route is cached;
- deletion job fails in one data replica.
Interview questions
- Last location versus current location? Cached cheap result versus a bounded attempt to obtain a sufficiently fresh result.
- Does fine permission guarantee GPS-level accuracy? No. User choice, hardware, environment, settings, and provider quality still govern the fix.
- Why foreground service for active tracking? It is ongoing, user-visible work expected beyond UI lifetime and must comply with location FGS restrictions.
- Can a geofence trigger exactly at its boundary? No. Position estimates and batched best-effort detection introduce uncertainty/latency.
- How do you reduce battery use? Lower priority/frequency, min distance, batching, bounded duration, remove updates, geofence/passive signals, and phase-aware requests.
- How do you handle out-of-order locations? Order by measurement timestamp/sequence, preserve idempotent identities, and define late-event policy.
- Why not move camera on every location? It steals control from a user who is exploring the map. Model tracking versus free-pan mode.
- How do you render many markers? Viewport queries, clustering, stable IDs, cached icons, diffing, and server/geospatial indexing.
- Does
isMockprove fraud? No. It is one risk signal with false-positive/evasion limits. - What does privacy-by-design add beyond permission? Minimization, purpose limitation, retention, authorization, logging controls, transparency, deletion/export, and audits.
Review checklist
- Feature works or degrades safely with no/approximate permission.
- Freshness and accuracy acceptance rules are explicit.
- Continuous requests have a clear lifecycle owner and stop path.
- Background access/FGS has visible user value and policy justification.
- Geofences are treated as delayed/duplicate/missing best-effort signals.
- Location events retain measurement time and idempotent identity.
- Map camera ownership and viewport fetching are modeled.
- Large datasets cluster/query rather than render blindly.
- Offline and API quota behavior are explicit.
- Collection, logs, authorization, retention, export, and deletion are reviewed.
Exercises
- Choose request settings for navigation, nearby stores, weather, fitness, and emergency sharing.
- Draw courier upload reconciliation after 45 minutes offline and clock changes.
- Threat-model an attendance app that pays employees based on geofence transitions.