ShortSnap wants to build a URL shortener similar to Bitly. Core features:
- Shorten URLs - given a long URL, generate a unique short code (e.g., `short.sn/abc123`). Users can optionally provide a custom alias.•Redirect - when someone visits the short URL, redirect them to the original URL with a 301/302 response. This must be fast (< 50 ms).•Click analytics - track clicks per link: total count, clicks over time, referrer, country, device type.•Expiration - links can optionally expire after a set date.•Rate limiting - prevent abuse by limiting URL creation to 100 per hour per user.
The service handles 1 million short links and 10 million redirects per day.
Design a URL shortening service (like Bitly) that creates short links and tracks click analytics. Build this architecture under realistic production constraints, then validate tradeoffs in the design lab simulation.
Request path: The solution keeps ingress, service logic, and stateful dependencies separated so each layer can scale independently.
Reference flow: Web Clients -> API Gateway -> API Service -> Primary SQL DB -> Redis Cache