KatInterview

Building a Local Business Review Service and a Link Shortener

System DesignModel answer
HardModel answerSystem Designsystem-designgeospatial-searchcaching

Last updated

Design a location-aware business discovery and review platform, then a short-link service, covering data models, search, caching, scaling reads and writes, and operational trade-offs.

You are asked to design two services in one session. Plan on spending roughly two-thirds of your time on the first and one-third on the second.

Part 1: Local business discovery and reviews

Design a platform where people find nearby businesses and read and write reviews.

Cover the following:

  • Data model: users, businesses (with coordinates and categories), reviews and ratings, photos, and check-ins. Mention keys and indexes.
  • Read scaling: replication, caching, CDN usage, and search indexes.
  • Write scaling: sharding, queues and asynchronous pipelines, consistency choices, and how you would run backfills.
  • Search: text search and geospatial queries, ranking, and how to keep latency low.
  • Cache invalidation and overall performance considerations.

Part 2: Short-link service

Design a service that turns long URLs into short ones and redirects visitors.

Cover the following:

  • Key or ID generation and how to handle collisions.
  • Storage layout.
  • Redirect behavior and CDN usage.
  • Rate limiting and abuse control.
  • Click analytics.
  • Expiry (TTL) and deletion.
  • Custom aliases.
  • How to scale for heavy read and write traffic.

State your assumptions about scale up front, sketch the architecture, and call out the trade-offs you are making.

Hints

Hint 1

Start with numbers: both systems are heavily read-dominated, so estimate QPS, storage per entity, and the read:write ratio before choosing components. Business metadata is small, reviews are medium, photos are huge.

Hint 2

For nearby search, think in terms of a spatial index (geohash with neighbouring cells, quadtree, S2/H3, or a search engine's geo_point) followed by an exact distance filter. Rank with a smoothed rating rather than a raw average.

Hint 3

Keep the user-facing write path short and synchronous (idempotent insert), then push everything else (aggregates, reindexing, cache invalidation) through a change stream to asynchronous consumers.

Hint 4

For the shortener, compare hashing the URL, random codes, and a counter encoded in base62. Decide how each handles collisions, predictability, and coordination across servers, and make the redirect path cacheable.