List functional requirements for the system (Ask the chat bot for hints if stuck.)..
Estimate the scale of the system you are going to design...
POST: /api/v1/submitLongUrl
request body:
{
"originalUrl": "www.randomwebsitesssss.com",
"short_url_id": "abc123"
}
return {
"shortenedUrl": "www.abc123.com"
}
POST: /api/v1/redirect
request body{
"originalUrl": ""
}
POST: /api/v1/createProfile
{
"username", "password", "DOB"
}
GET: /api/v1/getClickedOnTimes
request body:
{
"short_url_id"
}
UserProfile
username (PK)
password
DOB
websites
location
URL
short_url_id(PK)
long_url
created_at
expired_at
clicked_on_time
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...
create user account: client -> API gateway -> User Profile Service -> User Metadata DB -> Notification Service -> client
shorten URL request:
client -> API gateway -> URL shortening Service -> URL DB -> Notification Service -> client
view clieck counts and geo location:
client -> API gateway -> Analytics Service -> Notification Service -> client
client -> API gateway -> Geo Service -> Notification Service -> client
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
URL shortening Service will check if the user provided short URL exists in the DB, if not it will insert a short URL to long url mapping into the URL DB.
Geo Service will use geo hashing and store the location info into URL DB for tracking purposes.
Analytics Service will use monitoring service like Splunk to track click counts and logging. Redirect will take a shortend URL, look up the URL DB to get the origin URL, and redirect to the origin URL.
Explain any trade offs you have made and why you made certain tech choices...
MySQL for URL DB, lower performance but stronger consistency and relational mapping.
NoSQL for User Metadata DB for scalability and Performance, but no complexy query and less consistency.
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?