Yelp is a platform where users can discover local businesses like restaurants, cafes, and services through reviews and ratings. It helps people decide where to go by providing user-generated feedback, photos, and business details.
Product Design Requirements
Functional Requirements
- Users should be able to search business by name, category or location.
- Users should be able to view details of a business.
- Users should be able to give rating and leave comments for a business
Non-Functional Requirements
- This system should prioritize availability over consistency
- The system should provide low-latency search for businesses (target: < 500 ms).
- The system should scale to support ~100M users and ~10M businesses.
Design Setup
Data Model
- User represents a Yelp user who can search for businesses, leave reviews, and rate businesses.
- Business represents a listed entity (e.g., restaurant, service) and includes fields like name, location, and other metadata.
- Review represents feedback left by users for businesses, including rating, comments, and timestamps.
API Design
For a Yelp-like system, the API design should focus on three main flows: business search, business detail retrieval, and review submission. Since these operations are mostly request/response based, a REST API is a good fit.
GET /v1/businesses/search?name=thai&category=restaurant&location=San Francisco
This endpoint allows users to search businesses by name, category, or location. The response should include a paginated list of businesses with basic fields such as businessId, name, category, rating, reviewCount, and distance.
GET /v1/businesses/{businessId}
This endpoint returns detailed business information, including name, address, category, hours, photos, average rating, and recent reviews. Since business detail pages are read-heavy, this endpoint can be cached aggressively.
POST /v1/businesses/{businessId}/reviews { "rating": 5, "comment": "Great food and friendly service." }
This endpoint allows an authenticated user to leave a rating and comment for a business. The backend should validate the rating range, prevent duplicate or abusive reviews if needed, persist the review, and asynchronously update the business’s average rating and review count.