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:


  • high availability 99.9% of the time
  • the site should not take more than 100ms to come up.
  • security to prevent malicious user trying to access the site.


API Design

POST /shorten

GET /url/shorturl (Id)

DELETE /Url/Id

UPDATE (url/Id)

GET GetAllURLs()

GET Url/Redirect/shorturl


High-Level Design

Load Balancer: Use load balancer to redirect the services to the appropriate app server.

app server: Handle the appropriate request and serve the user

database: store the mapping between shortened URL and original URL in the database.

Redirect the user to the original URL.

Cache Layer : cache the frequently used URL on the API services. The cache layer exists in api or web server.


Overview :

The shortening URL will map the shortened URL to the original URL. When the user actually access the shortened URL but the system will fetch the mapped shortened URL to the original URL and will redirect the user to the original URL. The Redirect URL will happen in the front end. The user will type the shortened URL on the browser, the system will call the Shortened URL api services to get the original URL for the shortened URL and send a redirect response to the UI which will redirect the user to original URL.