Requirements


Functional Requirements:


  • service must generate unique shortned url for every original url submitted.
  • it should allow users to access the original url via the shortner url



Non-Functional Requirements:


  • it should redirect to short url within 100 ms
  • it should handdle million of request means hight scalibilty
  • availbility it should be 99% avaialable
  • security it should not accept malicious url or spam abuse url



API Design

  1. post. /generate_url

request body:{

"url":}

response {shorten url:}

  1. api to retrive the bit url for provided small url /retrive_url/{small_url}


High-Level Design

system will contain UI interface, backend service and database. ui will have functionality to create small url for user provided big url. another part will be where user search with small url and gets redirected to corresponding large url



Detailed Component Design

First part will be node based ui which will have landing page where first part will be to take url and send to backend with api /generate_url/{large_url} and then backend will be java application which will loaad this url and from it with use of hasing to get small string from url, then it is dumpped to db in same api. then after sucessfull updation in db it will return sucess message. second part of ui is the searching for specific url with short url. when user uploads small url and try to search then with this api /retrive_url/{small_url} backend java application will search in db and look for corresponding large url and return it and then in ui will direct user to that url.


now comes explansion part, as mentioned here required to consider large users so for fast retrival from db we will user redis caching which will provide cache and in it when comes to selection of mechanis we will use write through option as here we will have less write command and more read commands. with this we will create shared db where we will have 3 read db and one write db. we will longer ttl and wil user id we can make retrival more fast here. we will keep in db user id also. so basically i am targating to usre cache sharding here.