Requirements
Functional Requirements:
- Create a short URL for a given long URL.
- Return the long URL associated with a given short URL.
- we have to redirect the short url to the actual long url
- url should be unique
Non-Functional Requirements:
- low latency
- supports high read tracfic
- strong availabilty
- scalable
- durable storage
API Design
- post /shorten {
req.body -> long url from the user
return short url;
}
- get /actualurl {
input -> short url from the user;
return mapped url (actual long url)
}
High-Level Design
- in post ->
user send's long url we have to create a dictornary and store it in the key value paire
note before storing the repeated long url try to check weather the url present if yes then dont store again just get that url and return so we can save db size
- in get->
the user will give short url we have to check weather the url present in the dictnory if yes send the mapped url to the user as a response