Design a consumer service that returns nearby businesses with ratings, opening hours, and recent reviews. A user supplies a location, an optional query or category, and filters such as “open now.” Results shoul…
Question
## Scenario
Design a consumer service that returns nearby businesses with ratings, opening hours, and recent reviews. A user supplies a location, an optional query or category, and filters such as “open now.” Results should feel fresh and should rank useful places ahead of merely close places.
Assume a metropolitan launch with tens of millions of businesses globally, high read traffic, and continuous updates from business owners and reviewers.
## Core requirements
- Search by latitude/longitude and radius, optionally constrained by text or category.
- Return business identity, distance, aggregate rating, current open/closed state, and a review preview.
- Add or edit a review and update aggregate rating without losing accepted writes.
- Update business hours, including exceptions such as holidays and overnight schedules.
- Paginate results consistently while nearby businesses and rankings change.
- Prevent one abusive client or business from dominating availability or ranking.
## Start with these APIs
```text
GET /places/search?lat=&lon=&radius=&query=&open_now=&cursor=
GET /places/{place_id}
POST /places/{place_id}/reviews
PUT /places/{place_id}/hours
```
You may refine the contracts, but explain identifiers, pagination, validation, and consistency semantics.
## Discussion areas
1. Data model for places, locations, schedules, reviews, and rating aggregates.
2. Geographic indexing and how candidate places are combined with text relevance.
3. Ranking signals for distance, quality, popularity, freshness, and query intent.
4. Read and write paths, cache invalidation, and treatment of delayed aggregate updates.
5. Time-zone and daylight-saving handling for “open now.”
6. Observability, abuse prevention, and experiments for ranking changes.
## Follow-ups
- Support map movement with stable, low-latency refreshes.
- Add personalized ranking without creating a cold-start dead end.
- Handle a sudden citywide event that makes many hours inaccurate.
- Explain how you would measure search quality offline and online.The public brief is identical for people and crawlers. Account access changes tools, not the indexed description.