The system must allow users to input a long URL and generate a concise shortened version.
The system should accommodate growth in the number of users, URLs, and requests without impacting performance.
POST /api/shorten2nd
GET /api/users/{userId}/urlsid: Unique identifier for each user.username: The name chosen by the user to identify themselves.password_hash: Securely stored password hash for authentication.email: Email address for account recovery and notifications.id: Unique identifier for each shortened URL record.user_id: References the user who created this shortened URL.short_url: The generated shortened version of the URL.created_at: Timestamp when the shortening occurred.expiry_date: Optional field to determine if the shortened URL will expireflowchart TD
B["client"];
C{"server"};
D["Database"];
R["Redis"];
B --> C;
C --> D;
C --> R;
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...
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...
Explain any trade offs you have made and why you made certain tech choices...
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?