User provides a long url to the client (input field on the frontend)
FE makes request to the Backend and receives a shortened url
When user submit a shorted url in browser, they should get redirected to the actual page.
System should be able to scale under more requests for redirect - for example, when link is shared
Link endcoding into a short version will likely not have scenarios with burst load
Endpoint to shorten the url
Request:
POST /shorten
body: {
url: 'provided url'
}
Response:
body: {
url: 'provided url',
shortened_url: 'encoded url'
}
Dynamo tables:
Urls
id url shortened_url last_accessed_at created_at
Potential indexes - index by url, by shortened_url and last_accessed_at
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Setup a scheduled job to delete records in db that are older than defined time or was not accessed for provided period of time.
Define a servide for url encoding
Explain any trade offs you have made and why you made certain tech choices...
Need to make sure that urls are uniquely encoded
Potentilly use Redis or memcached to have less db load
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?