POST: / v1/ shortURL/{post body}
{
longURL:
}
Get: /v1/ shortUrl/{shortuRL}
we need 2 services one for shortening of URL nad other for redirection of URL.
Shortening service- uses POST api to create the short URL for corresponding longURL and save it into DB.
RedirectionService- user enters short url and the service fetches the corresponding long url from db and redirects to that URL.
Shortening Service- uses base 62 to shorten the URL. Before shortening the service will check the db if this URL is already present or not. Once a short Url is calculated it is stored in a DB( NOSQL) .
DB- We use No Sql because the data is non relational and we need very fast reads on the data. We will use a Key Value pair DB.
Redirection Service- once a Url is shortened and user enters the short URL in the browser the api GET call will be hit and it will fetch the Long URL from the DB and will redirect to it.