- Paste retrieval must have low latency, especially for frequently accessed or viral pastes.
- The system must support a read-heavy workload where paste retrieval traffic is significantly higher than paste creation traffic.
- Paste URLs must be cryptographically unguessable to prevent enumeration.
- Paste content must be stored durably for the duration of its configured retention period.
- The system must be highly available and avoid single points of failure.
- Cached paste content should remain readable during temporary backend degradation when the cached entry is still valid.
- The system must fail closed if content moderation is unavailable, preventing unscanned content from being published.
- The create operation must be idempotent so client retries do not create duplicate pastes.
- The system must enforce a maximum paste size before content scanning and storage.
- Expired or deleted pastes must not remain accessible through CloudFront or browser caches.
- The system must use encryption in transit and at rest.
- The system must expose logs, metrics, and alerts for failed creations, moderation failures, expired-paste access, cache behavior, and storage errors.
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
openapi: 3.0.3
info:
title: Pastebin API
version: 1.0.0
description: API for creating and retrieving temporary text pastes.
servers:
- url: https://api.example.com/v1
paths:
/pastes:
post:
summary: Create a paste
operationId: createPaste
tags:
- Pastes
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/CreatePasteRequest"
example:
text: |
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
language: java
expirationDays: 7
responses:
"201":
description: Paste created successfully
content:
application/json:
schema:
$ref: "#/components/schemas/PasteCreatedResponse"
example:
pasteId: "550e8400-e29b-41d4-a716-446655440000"
url: "https://paste.example.com/p/550e8400-e29b-41d4-a716-446655440000"
language: java
status: active
createdAt: "2026-08-04T23:00:00Z"
expiresAt: "2026-08-11T23:00:00Z"
"400":
description: Invalid request
"413":
description: Paste exceeds the maximum allowed size
"422":
description: Paste was rejected by content moderation
"503":
description: Content scanning service is unavailable
/pastes/{pasteId}:
get:
summary: Retrieve a paste
operationId: getPaste
tags:
- Pastes
parameters:
- name: pasteId
in: path
required: true
description: Unique, unguessable identifier of the paste
schema:
type: string
format: uuid
responses:
"200":
description: Paste retrieved successfully
headers:
Cache-Control:
description: Controls CloudFront and browser caching
schema:
type: string
example: "public, max-age=300, s-maxage=3600"
content:
application/json:
schema:
$ref: "#/components/schemas/PasteResponse"
example:
pasteId: "550e8400-e29b-41d4-a716-446655440000"
text: |
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello world");
}
}
language: java
createdAt: "2026-08-04T23:00:00Z"
expiresAt: "2026-08-11T23:00:00Z"
"404":
description: Paste does not exist or is not active
"410":
description: Paste has expired
components:
schemas:
CreatePasteRequest:
type: object
required:
- text
properties:
text:
type: string
minLength: 1
maxLength: 5242880
description: Paste content, with a maximum size of 5 MB
language:
type: string
default: plain_text
description: Language used for syntax highlighting
enum:
- plain_text
- java
- javascript
- typescript
- python
- go
- csharp
- cpp
- sql
- json
- xml
- yaml
- html
- css
- shell
expirationDays:
type: integer
default: 7
minimum: 1
maximum: 7
description: Number of days before the paste expires
PasteCreatedResponse:
type: object
required:
- pasteId
- url
- language
- status
- createdAt
- expiresAt
properties:
pasteId:
type: string
format: uuid
url:
type: string
format: uri
language:
type: string
status:
type: string
enum:
- active
createdAt:
type: string
format: date-time
expiresAt:
type: string
format: date-time
PasteResponse:
type: object
required:
- pasteId
- text
- language
- createdAt
- expiresAt
properties:
pasteId:
type: string
format: uuid
text:
type: string
language:
type: string
createdAt:
type: string
format: date-time
expiresAt:
type: string
format: date-time
| ServiceOne-sentence explanation | |
| CloudFront | Caches GET /pastes/{id} responses at edge locations so popular pastes load faster and cached reads may continue during temporary backend degradation. |
| API Gateway | Receives HTTP requests, exposes the paste endpoints, and routes each request to the correct Lambda function. |
| CreatePaste Lambda | Validates the request, generates an unguessable paste ID, scans the content with Bedrock, stores the text and metadata, and returns the shareable URL. |
| GetPaste Lambda | Checks the paste status and expiration in DynamoDB, retrieves the text from S3, and returns it to the client. |
| DeletePaste Lambda | Verifies that the authenticated user owns the paste, deletes or deactivates its metadata and content, and invalidates the cached response when necessary. |
| Amazon Bedrock | Moderates submitted text before the paste becomes active and publicly accessible. |
| Amazon S3 | Stores the actual paste text as durable and low-cost object storage, with lifecycle cleanup for expired objects. |
| Amazon DynamoDB | Stores paste metadata such as owner, status, visibility, creation time, expiration time, idempotency key, and S3 object key. |
| Amazon Cognito | |
| Handles user registration, login, authentication tokens, and identity for paste creation, history, and deletion. |
WAF for preventing spam
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.