Skip to content

Commit 556403e

Browse files
committed
Initial commit: Project setup with jump service implementation
0 parents  commit 556403e

File tree

15 files changed

+1477
-0
lines changed

15 files changed

+1477
-0
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Generated by Cargo
2+
/target/
3+
**/target/
4+
5+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
7+
Cargo.lock
8+
9+
# Backup files generated by rustfmt
10+
**/*.rs.bk
11+
12+
# MSVC Windows builds of rustc generate these, which store debugging information
13+
*.pdb
14+
15+
# Environment files
16+
.env
17+
.env.*
18+
19+
# IDE specific files
20+
.idea/
21+
.vscode/
22+
*.swp
23+
*.swo
24+
.DS_Store
25+
26+
# Debug files
27+
*.log
28+
29+
# Local development files
30+
dev.db
31+
*.local
32+
/tmp/

docs/brief.md

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# Ephemeral Share - v0 Product Requirements Document
2+
3+
Version: 1.0
4+
5+
Date: August 30, 2024
6+
7+
## 1. Introduction
8+
9+
Ephemeral Share is a simple API service that allows users to temporarily share text or binary data (like images) via a generated URL. The service focuses on ease of use, disposability, and minimal friction. It's designed for quick sharing of information that doesn't require permanent storage. This PRD outlines the requirements for the initial v0 release.
10+
11+
## 2. Goals
12+
13+
- Provide a simple, functional API for sharing ephemeral data.
14+
- Ensure data privacy and security (within the constraints of ephemerality).
15+
- Deliver a fast and reliable service.
16+
- Establish a foundation for future features (like authentication, more granular control over expiry, etc.).
17+
- Keep the v0 scope _extremely_ limited to ensure a quick launch.
18+
19+
## 3. Target Audience
20+
21+
- Developers who need a quick way to share data snippets, logs, or debug information.
22+
- Individuals who want to share temporary information (like one-time passwords, configuration details, or images) without relying on email or messaging platforms that retain data.
23+
- Users who need a simple, no-frills data-sharing solution without account creation.
24+
25+
## 4. Release Criteria (Definition of Done)
26+
27+
- All core features (listed below) are implemented and tested.
28+
- Basic API documentation is complete and publicly available.
29+
- The service is deployed to a stable environment (e.g., a cloud provider like AWS, Google Cloud, or Heroku).
30+
- Basic monitoring and logging are in place to track API usage and errors.
31+
- Rate limiting is implemented and tested.
32+
33+
## 5. Core Features (v0)
34+
35+
- **Data Upload:**
36+
37+
- Users can upload a payload (text or binary data) via a POST request.
38+
- The API accepts a `content` field (the data itself) and an optional `mime_type` field.
39+
- The API accepts an optional `expiry_time` field (ISO 8601 format). If not provided, a default expiry time (e.g., 24 hours) is used.
40+
- The API returns a unique `hash_id` (a short, URL-safe string) that represents the shared data.
41+
- Maximum payload size: 1MB.
42+
- Supported MIME types (initial list):
43+
- `text/plain`
44+
- `text/html`
45+
- `application/json`
46+
- `image/jpeg`
47+
- `image/png`
48+
- `image/gif`
49+
- The API returns standard HTTP status code `201 Created` in case the resource is created successfully.
50+
- **Data Retrieval:**
51+
52+
- Users can retrieve the payload via a GET request using the `hash_id`.
53+
- The API returns the payload with the correct `Content-Type` header based on the stored `mime_type`.
54+
- The API updates the `viewed_at` timestamp.
55+
- The API returns a 404 Not Found error if the `hash_id` is invalid or the data has expired.
56+
- **Data Expiry:**
57+
58+
- Data is automatically deleted after the `expiry_time` is reached.
59+
- A background process (e.g., a scheduled task or cron job) is responsible for cleaning up expired data.
60+
- **Rate Limiting:**
61+
62+
- Implement basic rate limiting based on the `X-Client-Token` header.
63+
- Limits:
64+
- Create: 100 requests/hour
65+
- Show: 1000 requests/hour
66+
- Default: 50 requests/hour
67+
- The API returns a 429 Too Many Requests error when the rate limit is exceeded. The response should include a `Retry-After` header indicating when the client can retry.
68+
- **API Versioning:**
69+
70+
- Use URL-based versioning (e.g., `/api/v1`).
71+
72+
## 6. API Endpoints (v0)
73+
74+
- **Base URL:** `/api/v1`
75+
76+
- **1. Add Payload**
77+
78+
- **Method:** `POST`
79+
- **Endpoint:** `/api/v1/payloads`
80+
- **Request Header:** `X-Client-Token: <token>` (for rate limiting)
81+
- **Request Body:**
82+
83+
JSON
84+
85+
```
86+
{
87+
"payload": {
88+
"content": "Your payload content here",
89+
"mime_type": "text/plain",
90+
"expiry_time": "2024-03-14T12:00:00Z"
91+
}
92+
}
93+
```
94+
95+
- **Response (Success - 201 Created):**
96+
97+
JSON
98+
99+
```
100+
{
101+
"hash_id": "a1b2c3d4e5f6",
102+
"content": "Your payload content here",
103+
"mime_type": "text/plain",
104+
"created_at": "2024-08-30T06:39:26.692Z",
105+
"updated_at": "2024-08-30T06:39:26.692Z",
106+
"viewed_at": null,
107+
"expiry_time": "2024-03-14T12:00:00.000Z"
108+
}
109+
```
110+
111+
- **Response (Error - 422 Unprocessable Entity):**
112+
113+
JSON
114+
115+
```
116+
{
117+
"error": "Invalid payload: content is required"
118+
}
119+
```
120+
121+
- **Response (Error - 429 Too Many Requests):**
122+
123+
JSON
124+
125+
```
126+
{
127+
"error": "Rate limit exceeded",
128+
"retry_after": 60
129+
}
130+
```
131+
132+
With the response header `Retry-After: 60`
133+
- **2. Get Payload**
134+
135+
- **Method:** `GET`
136+
- **Endpoint:** `/api/v1/payloads/:hash_id`
137+
- **Request Header:** `X-Client-Token: <token>` (for rate limiting)
138+
- **Response (Success - 200 OK):**
139+
140+
JSON
141+
142+
```
143+
{
144+
"hash_id": "a1b2c3d4e5f6",
145+
"content": "Your payload content here",
146+
"mime_type": "text/plain",
147+
"created_at": "2024-08-30T06:39:26.692Z",
148+
"updated_at": "2024-08-30T06:39:26.692Z",
149+
"viewed_at": "2024-08-30T07:15:00.000Z",
150+
"expiry_time": "2024-03-14T12:00:00.000Z"
151+
}
152+
```
153+
154+
- **Response (Error - 404 Not Found):**
155+
156+
JSON
157+
158+
```
159+
{
160+
"error": "Payload not found or expired"
161+
}
162+
```
163+
164+
- **Response (Error - 429 Too Many Requests):** Similar to the POST request.
165+
166+
## 7. Non-Functional Requirements
167+
168+
- **Performance:** The API should respond quickly (target: < 200ms for most requests).
169+
- **Scalability:** The architecture should be designed to handle a reasonable load (initial target: 1000 requests/second).
170+
- **Availability:** The service should aim for high availability (target: 99.9% uptime).
171+
- **Security:**
172+
- The `hash_id` should be sufficiently random and long to prevent guessing.
173+
- HTTPS should be enforced for all API communication.
174+
- Consider a Web Application Firewall (WAF).
175+
- **Maintainability:** The codebase should be well-documented and easy to understand.
176+
177+
## 8. Technology Stack (Suggestions)
178+
179+
- **Language:** Python (with Flask or FastAPI), Node.js (with Express), Go
180+
- **Database:** Redis, PostgreSQL, or a managed NoSQL database (like DynamoDB). _Redis is strongly recommended for v0._
181+
- **Deployment:** AWS (Lambda + API Gateway + DynamoDB/Redis), Google Cloud (Cloud Run + Cloud SQL/Memorystore), Heroku.
182+
- **Monitoring:** Basic logging and a monitoring service (Datadog, New Relic, Prometheus).
183+
184+
## 9. Future Considerations (Out of Scope for v0)
185+
186+
- Authentication (API keys or OAuth 2.0).
187+
- User Accounts.
188+
- Custom Expiry Times.
189+
- One-Time Links.
190+
- Password Protection.
191+
- Web UI.
192+
- File Uploads via Web UI.
193+
- Statistics.
194+
- Webhooks.
195+
- Data encryption at rest.
196+
197+
## 10. Open Issues
198+
199+
- Finalize the technology stack.
200+
- Determine the specific Redis/database schema.
201+
- Define the exact algorithm for generating the `hash_id`.
202+
203+
---

0 commit comments

Comments
 (0)