System Design Medium Software Engineer Backend Data Engineer

Design a location-based nearby places service (like Yelp or Google Maps nearby search).

Practise this question with AI feedback

Record your spoken answer or type your response to receive immediate scoring and STAR improvements.

💡 Suggested Approach & Sample Answer

Architecture & Spatial Indexing:
- Goal: Return nearby businesses within a given radius (e.g., 5km) of a user's latitude and longitude in under 50ms.

1. Spatial Indexing Technology:
- Relational bounding box queries (WHERE lat BETWEEN ... AND lon BETWEEN ...) require full table scans on large datasets.
- Geohashing: Encodes 2D coordinates into a 1D alphanumeric string. Points sharing a common prefix reside in the same geographic box. Querying the prefix retrieves nearby locations quickly.
- Uber H3 / Google S2: Hexagonal hierarchical spatial indexes. Hexagons offer uniform neighbor distances, ideal for radius searches.

2. Storage Architecture:
- Primary Datastore: PostgreSQL with PostGIS extension or DynamoDB with Geohash partition keys.
- In-Memory Spatial Cache: Redis with Geospatial indexes (GEOADD, GEORADIUS), which internally use sorted sets scored by 52-bit Geohash integers.

3. Read Query Flow:
- User sends (lat, lon, radius) -> API Gateway -> Convert coordinates to spatial cell IDs -> Query Redis spatial index -> Filter by business categories/ratings -> Return hydrated metadata.

4. Data Updates:
- Business location changes are rare (write-light, read-heavy). Updates write to DB and asynchronously update Redis cache.

🎯 What Interviewers Listen For

How would you answer this in a real interview?

Use our free AI mock practice tool to test your response, analyze speaking pacing, and refine your STAR structure.

🧭 New to system design interviews?

Read the step-by-step system design interview guide: a 45-minute framework, the building blocks interviewers expect, and common mistakes.

🔗 Related System Design Questions