Design a Yelp-style proximity service with nearby search and reviews
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Other
Design a proximity service similar to Yelp. Users upload attractions, search for them, and review them. An attraction is a place that offers a service, such as a business, stored with its location.
The system must support:
1. Create an attraction.
2. Search attractions near a location, filtered by specific properties such as category.
3. Review an attraction: a signed-in user posts a rating and an optional comment on one attraction.
```hint Radius queries
Separate indexes on latitude and longitude do not answer "everything within 5 km of me" quickly. Think about how to turn a two-dimensional position into a key that an ordinary index can range-scan, and check what happens to a place that sits just across a cell edge from the user.
```
```hint Read path versus write path
Compare the read rate with the write rate in your estimate. Decide which data must be visible right after a write and which can lag briefly, and let that drive caching, replication and indexing.
```
### Constraints & Assumptions
- About 50 million daily active users.
- About 1,000 new attractions a day. An attraction with its metadata and images averages about 500 KB.
- Each user posts about 2 reviews a month, and a review averages about 2 KB.
- Each user makes about 20 reads (searches or attraction page views) a month.
- Nearby search returns in under 300 ms at p95.
- 99.9% uptime overall, with search held to 99.99%.
- Availability matters more than consistency: a new attraction or review may appear in search results after a short delay.
### Clarifying Questions to Ask
- What search radius can a user choose, and is there a maximum?
- Do users search by free text on names and descriptions, or only by category and other filters?
- How should results be ranked: by distance, rating, review count, or a mix?
- Can anyone create an attraction, and does it need moderation before it appears?
- Can a user review the same attraction more than once, and can reviews be edited or deleted?
### What a Strong Answer Covers
- Requirements and a storage and traffic estimate that separates reads from writes and media from structured records.
- How a radius query is answered quickly, including places near cell edges and areas with very different densities.
- A storage choice for each entity (attractions, media, metadata, reviews), justified by how that entity is read and written.
- The create, search and review flows end to end: what runs synchronously, what goes through a queue, and where caches sit.
- How reads scale and where the design accepts eventual consistency.
### Follow-up Questions
- A popular attraction gets a new review every second. How do you keep its average rating and review count correct and cheap to read?
- An attraction moves or closes. How does the change reach the search index and the caches, and how stale can results get?
- How would the design change if search traffic grew to 100k requests per second and writes to 10k per second?
- How would you detect fake reviews and spam attractions?
Overview: Design a proximity service where users add places, search for attractions near a location with filters, and post ratings and reviews. It tests geospatial indexing for radius queries, capacity estimates, a storage choice for each entity, caching for a read-heavy workload, and trading consistency for availability.