External API
1.Create Paste
Method: POST
Endpoint: /{version}/paste
Request Body:
paste_text: string (required) : text included in paste
Response:
Success:
status: ENUM: SUCCESS
status_code: int: 200
paste_id: id: id of paste
Error:
status: ENUM: ERROR
status_code: int: 4xx | 5xx
2.Get Paste
Method: GET
Endpoint: /{version}/paste/{paste_id}
Path Variable:
paste_id: {id}: id of the paste
Response:
Success:
status: ENUM: SUCCESS
status_code: int: 200
Error:
status: ENUM: ERROR
status_code: int: 4xx | 5xx
3.Update Paste
Method: PATCH
Endpoint: /{version}/paste/{paste_id}
Path Variable
paste_id: id: id of the paste
Request Body:
new_text: string: new text
Response:
Success:
status: ENUM: SUCCESS
status_code: int: 200
Error:
status: ENUM: ERROR
status_code: int: 4xx | 5xx
4.Delete Paste
Method: DELETE
Endpoint: /{version}/paste/{paste_id}
Path Variable:
paste_id: id: id of the paste
Response:
Success:
status: ENUM: SUCCESS
status_code: int: 200
Error:
status: ENUM: ERROR
status_code: int: 4xx | 5xx
Service Component:
Diagram
Gen UID Service:
Database:
Paste expiration:
As we allow the user to set expiration condition for every paste we need efficient way to invalidate a balk of paste. For time condition we just need to map expiration_date with the id. If there is request after expiration timestamp we can easily know that this paste is invalid and delete it. In addition we can have the cron job that will periodically check if at the current time are there any paste that is expired if so we can delete them all for reducing storage cost.
Cache:
Scalability:
We will deploy stateless service on container orchestration service such as AWS ECS. In this case we can scale up/down our container on a whim. We can also set up condition for scaling such as when the request amount of certain service exceed our predefine value. They will add more instance to serve the upcoming load. Also we can adopt fault tolerant architecture by using spot instance to save the cost of infrastructure.