⭐ Design Yelp — System Design Interview Guide
Medium · Geospatial & Reviews
Design a local business discovery platform like Yelp or Google Maps where users can find nearby restaurants, services, and attractions; read/write reviews; and see ratings.
Open the interactive Yelp design on PrepGrind → Drag load balancers, caches, databases, and queues onto a canvas, run a live traffic simulation to watch latency and bottlenecks under load, and follow the full interview walkthrough below — free, in your browser.
Functional requirements
- Search businesses by name, category, or keyword near a location
- View business details: hours, photos, menu, contact
- Write and read reviews with star ratings (1-5)
- Filter by rating, distance, price range, open-now
- Business owner portal: manage business info
- Add/upload photos to business or review
Non-functional requirements & scale
- 100M businesses worldwide; 500M reviews
- Search results < 200ms P95
- Proximity search: find businesses within N km
- Review write latency < 1 second
- Rating aggregation always consistent with stored reviews
- Photo CDN: images served < 500ms globally
Capacity estimation
Geospatial search + rich text search combined. Business search = proximity (geospatial) + keyword match + filter. Geohash or S2 cells for proximity indexing. Elasticsearch natively supports geo_point and text search combined. Reviews: write-heavy on popular businesses (rate limiting), read-heavy always.
Core entities
- Business — businessId, name, category, location (lat/lng), address, geohash, rating, reviewCount, priceRange, hours, photos[]
- Review — reviewId, businessId, userId, rating (1-5), text, photos[], createdAt, helpfulCount
- User — userId, username, reviewCount, profilePhoto, elite (bool)
API design
GET /api/v1/search?q=pizza&lat=37.7&lng=-122.4&radius=2km&sort=rating— Search businesses near location.POST /api/v1/businesses/:id/reviews— Write review. Body: { rating, text, photos? }.GET /api/v1/businesses/:id— Business details with paginated reviews.
High-level design
Search: Elasticsearch with geo_point + text + filters. Reviews: MySQL with denormalized rating on Business table. Photos: S3 + CDN. Geohash-based proximity index partitions the geographic search space.
Deep dives
📍 Geospatial Search with Geohash
Geohash: encode lat/lng as string prefix. Properties of geohash string: (1) Shared prefix = geographic proximity. (2) Longer prefix = smaller area. "9q8yy" = San Francisco 1×1km cell. Business geohash stored in Elasticsearch geo_point field. Search: filter by geohash prefix = fast proximity search. Edge case: businesses near geohash boundaries → query adjacent cells (8 neighbors).
⭐ Rating Calculation
Naive: SELECT AVG(rating) FROM reviews WHERE businessId = X. Slow on 10K reviews. Better: denormalize — Business table has ratingSum and reviewCount. On new review: UPDATE business SET ratingSum = ratingSum + ?, reviewCount = reviewCount + 1. Rating = ratingSum / reviewCount. Must use database transaction: INSERT review + UPDATE business atomically. Review deletion: subtract from ratingSum.
🛡️ Review Spam Prevention
Yelp has sophisticated anti-gaming: (1) Review gating: new business owner cannot solicit reviews. (2) IP/device fingerprinting: multiple reviews from same source. (3) Review history: new account + only 1 review to competitor = suspicious. (4) ML model: scores review authenticity. (5) "Not currently recommended" section for filtered reviews. Elite users: trusted reviewers with verified history.
🗺️ Maps Integration
Business location displayed on map. Google Maps Embed API or Mapbox for map display. Geocoding: convert address to lat/lng on business creation (Google Geocoding API). Reverse geocoding: "restaurants near me" uses browser geolocation API → lat/lng. Routing: show directions from user to business (Google Maps link or native map app). Map tiles served from CDN.
Scaling considerations
- Elasticsearch for combined geo + text search (native support)
- MySQL sharded by businessId; reviews partitioned by businessId
- Redis cache for popular businesses (top 10K businesses get 80% of traffic)
- CDN for all photos — critical for perceived performance
- Geohash search: query precision = balance between accuracy and over-fetching
What interviewers expect by level
- Junior: Describe business search with location filter, review creation, star rating.
- Mid: Geohash proximity search, denormalized rating, Elasticsearch geo_point queries.
- Senior: Adjacent geohash cells for boundary cases, anti-spam review system, rating denormalization with transactions.
- Staff: Personalized ranking (preferences + history), global CDN for 500M review photos, GDPR for review deletion.
Practice more system design case studies
- Design URL Shortener
- Design Social Media Feed
- Design Chat System
- Design Video Streaming
- Design Ride-Sharing Platform
- Design E-Commerce Platform
- Design UPI Payment Gateway
- Design Google Docs
- Design Tinder
- Design Google Drive / Dropbox
- Design Instagram
- Design Type-Ahead Search
- Design Web Crawler
- Design Ticket Booking (BookMyShow)
- Design Pastebin
- Design Notification System
- Design Rate Limiter (Standalone)
- Design Simple Web App
- Design Food Delivery (Swiggy)
- Design Stock Trading System
- Design Live Streaming (Twitch)
- Design Distributed Key-Value Store
- Design Ad Click Aggregation
- Design Monitoring / Metrics (Datadog)
- Design Online Judge (LeetCode)
- Design FB Post Search
- Design Cache Layer
- Design Message Queue
- Design Full Production Stack
PrepGrind runs entirely in your browser, free, no installation required. Loading the interactive playground…