List functional requirements for the system (Ask the chat bot for hints if stuck.)...
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
Define what APIs are expected from the system...
This endpoint is used to create a new paste by sending the text content and user information.
POST/pastebin/storeapplication/json| Field | Type | Description |
text | string | The text content to be stored. |
userid | string | The unique identifier for the user. |
Example Request:
{
"text": "This is a new paste for the service.",
"userid": "user-12345"
}
201 Createdapplication/json| Field | Type | Description |
url | string | The unique URL for the newly created paste. |
Example Response:
{
"url": "[https://pastebin.example.com/abcdef123] (https://pastebin.example.com/abcdef123)"
}
This endpoint is used to retrieve the text content of a paste using its unique hash.
GET/{hash}200 OKapplication/json| Field | Type | Description |
text | string | The raw text content of the paste. |
Example Response:
{
"text": "This is a new paste for the service."
}
404 Not Found status.Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
In database design we have two things one we are going to store data in aws s3 and metadata in relational database.
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...
This is the core service that orchestrates the entire process. Its responsibilities are:
encoded_url in the database, and the final URL is constructed as domain/hash.The URL creation process is a key part of the service's design. The service combines two unique identifiers—a UUID (Universally Unique Identifier) and the User ID—to create a unique hash. This approach ensures that the URL is not easily guessable and is unique to a specific user and a specific "paste" session. The hash is then appended to the domain to form the complete URL, like domain/hash.
AWS S3 (Simple Storage Service) is an object store used to hold the raw text data. It's chosen for its key features:
The database's primary role is to act as a metadata store. It's crucial for the service's functionality and stores information such as:
encoded_url: The unique hash used in the URL.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...
The Client is the user-facing component, which can be a web browser, a mobile app, or a command-line utility.
Key Responsibilities:
POST requests to the API to store new pastes and GET requests to retrieve existing ones.The API Gateway acts as the entry point for all client requests. It provides a single, unified interface for the backend services.
Key Responsibilities:
/pastebin/store and /{hash}).This is the core business logic component of the system. It orchestrates the storage and retrieval of data by interacting with the data tier components.
Key Responsibilities:
text and userid from the API Gateway.userid and a newly created UUID. A robust hashing algorithm (e.g., SHA-256) should be used, truncated to a URL-friendly length (e.g., 8-12 characters).text data to AWS S3 and receives a unique s3Key in return. This asynchronous operation is crucial for efficiency, as it prevents the service from blocking while waiting for S3.hash, s3Key, userid, and creation timestamp) in the Database. This operation should also be handled with robust error handling, with a retry mechanism if the database is temporarily unavailable.expiryTimestamp (e.g., 24 hours from creation) and includes it in the metadata record before storing it in the database.hash from the API Gateway.s3Key using the hash as the key. This significantly improves performance for frequently accessed pastes.hash to retrieve the corresponding s3Key and expiryTimestamp. The database should have an index on the encodedUrl column for fast lookups.expiryTimestamp.410 Gone HTTP status code.404 Not Found response, preventing a request to S3.s3Key.AWS S3 is the primary storage component for the raw text content.
Key Responsibilities:
The Database is responsible for storing and providing fast lookups for the metadata associated with each paste.
Key Responsibilities:
encodedUrl (hash), the s3Key, the userId, and now an expiryTimestamp.s3Key by querying the encodedUrl.Explain any trade offs you have made and why you made certain tech choices...
You've correctly identified the primary trade-off with this choice: performance versus cost and scalability.
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?
we improve this service in future by spending time on choose other object store.