List the key functional requirements for the system (Ask the AI for hints if stuck)...
User can input any valid URL and receives a new URL with shortened characters
User can click on new URL and arrive at the webpage for the initially sent URL
List the key non-functional requirements (performance, scalability, reliability, etc.)...
URL generation should be fast
There should be a minimal loss in loading time when pressing a new URL vs the original
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
A Get endpoint that takes the original URL as a parameter and returns the shortened URL
Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
Client on front end enters URL into a field which is sent to the backend Server. Server processes the URL and generates a new, shortened URL that also points to the same web location the original URL does. Both the original URL and the new URL are stored in the database in case the shortened URL needs to be retrieved.
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
URL Generation - A function to hash a given URL to a new URL that is only 7 characters long (after domain name) as that should be able to service a reasonable amount of URLs before running out of unique character combinations.
URL Retrieval - When the frontend requests a URL, the function will first check the database for if the URL has already had a shortened version generated, and if it has, fetch that shortened URL stored in the database and return it. If it hasn't been generated, it will then instead move onto the URL generation function.