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:


  • the length of short URL is in range of 6 to 10 characters
  • the redirection from short to long URL must be under 0.3 seconds
  • all short URLs must be unique for 10 million daily users
  • short URL must be easy to type, so it would only consist of letters and digits
  • the short URL is formed by selecting integer from range 0 to 62^6 that equals 56800235584 and then encoded using Base62, so at most url with 6 characters would be generated
  • optional: short-url expiration time parameter


API Design

POST /short-url {

longUrl: ...

}

this post method will create a short url based on long one and return it


GET /{short-url}

this methods redirects to the appropriate long-url page



High-Level Design

the front-end is functioning as a client.

the microservice arhitecture is used.

there would be only one service: the one that is responsible for url translation and redirection.

for each service a separate database is created




Detailed Component Design

url database entities:

urls:

long_url:

short_url:

created_at:

expired_at: