System requirements
Functional:
List functional requirements for the system (Ask the chat bot for hints if stuck.)...
- store text and return url to access that .
- use login and signup and session management
Non-Functional:
List non-functional requirements for the system...
- Availability
- Scalability
Capacity estimation
Estimate the scale of the system you are going to design...
API design
Define what APIs are expected from the system...
1. Store Data
This endpoint is used to create a new paste by sending the text content and user information.
- Method:
POST - Path:
/pastebin/store
Request Body
- Content-Type:
application/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"
}
Response
- Status Code:
201 Created - Content-Type:
application/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)"
}
2. Fetch Data
This endpoint is used to retrieve the text content of a paste using its unique hash.
- Method:
GET - Path:
/{hash}
Response
- Status Code:
200 OK - Content-Type:
application/json
| Field | Type | Description |
text | string | The raw text content of the paste. |
Example Response:
{
"text": "This is a new paste for the service."
}
- Note: If the hash is not found, the API will return a
404 Not Foundstatus.
Database design
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.
High-level design
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...
Pastebin Service ⚙️
This is the core service that orchestrates the entire process. Its responsibilities are:
- Data Storage: It's responsible for the primary action of the service—storing text data. It writes the raw text content to AWS S3 and saves the corresponding metadata to the database.
- URL Creation: It's tasked with generating the unique, shareable URL for each paste. This is done by creating a hash based on a UUID and User ID, which ensures uniqueness for each session. This hash is stored as
encoded_urlin the database, and the final URL is constructed asdomain/hash. - URL and Data Retrieval: When a user accesses a URL, the service must:
- Extract the hash from the URL.
- Use the hash to query the database and retrieve the associated metadata (including the UUID and User ID).
- Use the S3 key from the metadata to fetch the actual text data from AWS S3.
- Return the text content to the user.
How URLs are Created
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.
Service Components
AWS S3 ☁️
AWS S3 (Simple Storage Service) is an object store used to hold the raw text data. It's chosen for its key features:
- Cost-Effectiveness: It's a cheap and scalable storage solution, making it ideal for storing large volumes of data without high costs.
- High Scalability: It can handle virtually unlimited data, ensuring the service can grow as needed.
Database 💾
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.- S3 Key: The pointer or key that links the database record to the actual text data stored in S3.
- User Details: Information about the user who created the paste.
- Other Metadata: This could include things like the creation date, expiration date, or privacy settings for the paste.
Request flows
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...
Detailed component design
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...
Pastebin Service ⚙️
This is the core service that orchestrates the entire process. Its responsibilities are:
- Data Storage: It's responsible for the primary action of the service—storing text data. It writes the raw text content to AWS S3 and saves the corresponding metadata to the database.
- URL Creation: It's tasked with generating the unique, shareable URL for each paste. This is done by creating a hash based on a UUID and User ID, which ensures uniqueness for each session. This hash is stored as
encoded_urlin the database, and the final URL is constructed asdomain/hash. - URL and Data Retrieval: When a user accesses a URL, the service must:
- Extract the hash from the URL.
- Use the hash to query the database and retrieve the associated metadata (including the UUID and User ID).
- Use the S3 key from the metadata to fetch the actual text data from AWS S3.
- Return the text content to the user.
How URLs are Created
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.
Service Components
AWS S3 ☁️
AWS S3 (Simple Storage Service) is an object store used to hold the raw text data. It's chosen for its key features:
- Cost-Effectiveness: It's a cheap and scalable storage solution, making it ideal for storing large volumes of data without high costs.
- High Scalability: It can handle virtually unlimited data, ensuring the service can grow as needed.
Database 💾
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.- S3 Key: The pointer or key that links the database record to the actual text data stored in S3.
- User Details: Information about the user who created the paste.
- Other Metadata: This could include things like the creation date, expiration date, or privacy settings for the paste.
Trade offs/Tech choices
Explain any trade offs you have made and why you made certain tech choices...
Failure scenarios/bottlenecks
Try to discuss as many failure scenarios/bottlenecks as possible.
Future improvements
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?