⭐ 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

Non-functional requirements & scale

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

API design

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

What interviewers expect by level

Practice more system design case studies

PrepGrind runs entirely in your browser, free, no installation required. Loading the interactive playground…