Requirements


Functional Requirements:


  • Create a short URL for a given long URL.
  • Return the long URL associated with a given short URL.



Non-Functional Requirements:


  • Low latency. We want those urls to be resolved fast.
  • Redirection if the id changes from a generated id to a custom-id.
  • scalability, How we we resolve urls fast
  • High availability
  • Not sure the eventual consistency.


API Design

From an API design POV it's quite simple. Let's start with the endpoingt:


  • POST /create
    • Body: url, possibly a custom id



High-Level Design


Components needed:

  • Client: let say the url shortener's UI
  • API
  • Database: To store the id, url, redirect



Detailed Component Design

Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.