This question evaluates the ability to design scalable, highly available web services encompassing URL shortening, redirect semantics, API design, click-counting and analytics, plus related trade-offs in consistency, data modeling, and operational concerns.
Design a production-ready service that:
POST /shorten
takes a long URL and returns a short code + short URL.
GET /{code}
redirects (HTTP 301/302) to the long URL.
GET /stats/{code}
returns: