Skip to content

Commit 87697f1

Browse files
committed
docs: Add comprehensive documentation
Added: - README.md with project overview and setup instructions - API.md with detailed endpoint documentation and examples - openapi.yaml with OpenAPI 3.0 specification Documentation includes: - Installation and setup guide - Configuration options - API endpoints with examples - Rate limiting details - Error handling - Project structure - Contributing guidelines
1 parent d660d5a commit 87697f1

File tree

3 files changed

+481
-59
lines changed

3 files changed

+481
-59
lines changed

README.md

Lines changed: 107 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,161 @@
1-
# Jump - Ephemeral Share Service
1+
# Jump Service
22

3-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4-
[![Rust](https://github.com/rust-lang/rust/workflows/CI/badge.svg)](https://github.com/rust-lang/rust/actions)
5-
6-
7-
Jump is a secure and efficient ephemeral sharing service built with Rust. It allows users to share content that automatically expires after a set duration, ensuring data privacy and security.
3+
A high-performance, Redis-backed temporary payload storage service with rate limiting.
84

95
## Features
106

11-
- **Ephemeral Sharing**: Content automatically expires after a configurable duration
12-
- **Secure**: Content is encrypted and only accessible via unique hash IDs
13-
- **Rate Limited**: Built-in protection against abuse
14-
- **Type Safe**: Strict MIME type validation for content
15-
- **Fast**: Built with Rust for optimal performance
16-
- **Simple API**: RESTful API for easy integration
7+
- Create, retrieve, and delete temporary payloads
8+
- Built-in rate limiting
9+
- Automatic payload expiration
10+
- High performance with Redis backend
11+
- Comprehensive logging
12+
- Detailed error handling
1713

18-
## Getting Started
14+
## Quick Start
1915

2016
### Prerequisites
2117

22-
- Rust 1.70 or higher
23-
- Redis 6.0 or higher
24-
- Cargo (Rust's package manager)
18+
- Rust (latest stable)
19+
- Redis server (6.0 or higher)
20+
- Cargo (comes with Rust)
2521

2622
### Installation
2723

2824
1. Clone the repository:
29-
```bash
30-
git clone https://github.com/yourusername/jump.git
31-
cd jump
32-
```
25+
```bash
26+
git clone https://github.com/codevalley/jump.git
27+
cd jump
28+
```
3329

34-
2. Copy the example environment file:
35-
```bash
36-
cp .env.example .env
37-
```
30+
2. Start Redis:
31+
```bash
32+
# Using Docker
33+
docker run --name jump-redis -p 6379:6379 -d redis
3834

39-
3. Update the environment variables in `.env` with your configuration.
35+
# Or use your system's Redis
36+
systemctl start redis # Linux
37+
brew services start redis # macOS
38+
```
4039

41-
4. Build the project:
42-
```bash
43-
cargo build --release
44-
```
40+
3. Build and run:
41+
```bash
42+
cargo run
43+
```
4544

46-
5. Run the server:
47-
```bash
48-
cargo run --release
49-
```
45+
The service will start on `http://localhost:8080`.
5046

51-
## Usage
47+
## API Overview
5248

53-
### Creating a Share
49+
### Health Check
50+
```http
51+
GET /api/health
52+
```
5453

55-
```bash
56-
curl -X POST http://localhost:8080/api/v1/payloads \
57-
-H "Content-Type: application/json" \
58-
-d '{
59-
"content": "Your content here",
60-
"mime_type": "text/plain",
61-
"expiry_time": "2024-03-14T12:00:00Z"
62-
}'
54+
### Create Payload
55+
```http
56+
POST /api/v1/payloads
57+
Content-Type: application/json
58+
59+
{
60+
"content": "Your content here",
61+
"mime_type": "text/plain",
62+
"expiry_time": "2025-03-28T00:00:00Z" // Optional
63+
}
6364
```
6465

65-
### Retrieving a Share
66+
### Get Payload
67+
```http
68+
GET /api/v1/payloads/{hash_id}
69+
```
6670

67-
```bash
68-
curl http://localhost:8080/api/v1/payloads/{hash_id}
71+
### Delete Payload
72+
```http
73+
DELETE /api/v1/payloads/{hash_id}
6974
```
7075

76+
For detailed API documentation, see [API.md](docs/API.md).
77+
7178
## Configuration
7279

7380
The service can be configured using environment variables:
7481

75-
- `SERVER_HOST`: Host to bind the server to (default: "127.0.0.1")
76-
- `SERVER_PORT`: Port to listen on (default: 8080)
77-
- `REDIS_URL`: Redis connection URL
78-
- `RATE_LIMIT_REQUESTS`: Number of requests allowed per window
79-
- `RATE_LIMIT_WINDOW_SECS`: Rate limit window in seconds
80-
- `MAX_PAYLOAD_SIZE`: Maximum payload size in bytes
81-
- `DEFAULT_EXPIRY_HOURS`: Default expiry time in hours
82+
```bash
83+
# Server configuration
84+
PORT=8080
85+
HOST=127.0.0.1
86+
87+
# Redis configuration
88+
REDIS_URL=redis://localhost:6379
89+
REDIS_POOL_SIZE=16
90+
REDIS_TIMEOUT=5
91+
92+
# Rate limiting
93+
RATE_LIMIT_REQUESTS=100
94+
RATE_LIMIT_WINDOW=60 # seconds
95+
96+
# Payload limits
97+
MAX_PAYLOAD_SIZE=10485760 # 10MB
98+
DEFAULT_EXPIRY=86400 # 24 hours
99+
```
82100

83101
## Development
84102

85103
### Running Tests
86104

87105
```bash
106+
# Run all tests
88107
cargo test
108+
109+
# Run specific test suite
110+
cargo test test_api_integration
89111
```
90112

91-
### Documentation
113+
### Code Style
92114

93-
Generate and view the documentation:
115+
The project follows Rust standard formatting. Format your code using:
94116

95117
```bash
96-
cargo doc --open
118+
cargo fmt
97119
```
98120

99-
## API Documentation
121+
### Logging
100122

101-
The API documentation is available at `/api/docs` when running the server.
123+
The service uses `tracing` for structured logging. Log levels can be configured using the `RUST_LOG` environment variable:
124+
125+
```bash
126+
RUST_LOG=debug cargo run
127+
```
128+
129+
## Project Structure
130+
131+
```
132+
src/
133+
├── api/ # HTTP API layer
134+
│ ├── middleware/ # Rate limiting, logging
135+
│ └── v1/ # API version 1 endpoints
136+
├── application/ # Business logic
137+
│ ├── use_cases/ # Core operations
138+
│ └── dto/ # Data transfer objects
139+
├── domain/ # Core domain models
140+
├── infrastructure/ # External services
141+
│ └── redis/ # Redis implementation
142+
└── main.rs # Application entry point
143+
```
102144

103145
## Contributing
104146

105147
1. Fork the repository
106148
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
107-
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
149+
3. Commit your changes (`git commit -m 'Add amazing feature'`)
108150
4. Push to the branch (`git push origin feature/amazing-feature`)
109151
5. Open a Pull Request
110152

111153
## License
112154

113155
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
156+
157+
## Acknowledgments
158+
159+
- Built with [actix-web](https://actix.rs/)
160+
- Storage powered by [Redis](https://redis.io/)
161+
- Logging with [tracing](https://docs.rs/tracing)

docs/API.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Jump Service API Documentation
2+
3+
## API Version 1
4+
5+
Base URL: `/api/v1`
6+
7+
## Endpoints
8+
9+
### Create Payload
10+
11+
Creates a new temporary payload.
12+
13+
```http
14+
POST /payloads
15+
Content-Type: application/json
16+
```
17+
18+
#### Request Body
19+
20+
```json
21+
{
22+
"content": "string",
23+
"mime_type": "string",
24+
"expiry_time": "2025-03-28T00:00:00Z" // Optional, ISO 8601 format
25+
}
26+
```
27+
28+
| Field | Type | Required | Description |
29+
|-------|------|----------|-------------|
30+
| content | string | Yes | The content to store |
31+
| mime_type | string | Yes | MIME type of the content |
32+
| expiry_time | string | No | When the content should expire (ISO 8601) |
33+
34+
#### Response
35+
36+
##### Success (201 Created)
37+
```json
38+
{
39+
"hash_id": "string",
40+
"expiry_time": "2025-03-28T00:00:00Z"
41+
}
42+
```
43+
44+
##### Errors
45+
- 400 Bad Request: Invalid request body or MIME type
46+
- 413 Payload Too Large: Content exceeds size limit
47+
- 429 Too Many Requests: Rate limit exceeded
48+
- 500 Internal Server Error: Server error
49+
50+
### Get Payload
51+
52+
Retrieves a payload by its hash ID.
53+
54+
```http
55+
GET /payloads/{hash_id}
56+
```
57+
58+
#### Parameters
59+
60+
| Name | In | Type | Required | Description |
61+
|------|-----|------|----------|-------------|
62+
| hash_id | path | string | Yes | The unique identifier of the payload |
63+
64+
#### Response
65+
66+
##### Success (200 OK)
67+
```json
68+
{
69+
"content": "string",
70+
"mime_type": "string",
71+
"expiry_time": "2025-03-28T00:00:00Z"
72+
}
73+
```
74+
75+
##### Errors
76+
- 404 Not Found: Payload not found or expired
77+
- 429 Too Many Requests: Rate limit exceeded
78+
- 500 Internal Server Error: Server error
79+
80+
### Delete Payload
81+
82+
Deletes a payload by its hash ID.
83+
84+
```http
85+
DELETE /payloads/{hash_id}
86+
```
87+
88+
#### Parameters
89+
90+
| Name | In | Type | Required | Description |
91+
|------|-----|------|----------|-------------|
92+
| hash_id | path | string | Yes | The unique identifier of the payload |
93+
94+
#### Response
95+
96+
##### Success (204 No Content)
97+
No response body
98+
99+
##### Errors
100+
- 404 Not Found: Payload not found
101+
- 429 Too Many Requests: Rate limit exceeded
102+
- 500 Internal Server Error: Server error
103+
104+
## Rate Limiting
105+
106+
The API implements rate limiting based on client IP address:
107+
108+
- Default limit: 100 requests per 60 seconds
109+
- Rate limit headers:
110+
- `X-RateLimit-Limit`: Maximum requests per window
111+
- `X-RateLimit-Remaining`: Remaining requests in current window
112+
- `X-RateLimit-Reset`: Time when the rate limit resets (Unix timestamp)
113+
114+
## Error Responses
115+
116+
All error responses follow this format:
117+
118+
```json
119+
{
120+
"error": "string" // Human-readable error message
121+
}
122+
```
123+
124+
## Examples
125+
126+
### Creating a Payload
127+
128+
Request:
129+
```bash
130+
curl -X POST http://localhost:8080/api/v1/payloads \
131+
-H "Content-Type: application/json" \
132+
-d '{
133+
"content": "Hello, World!",
134+
"mime_type": "text/plain",
135+
"expiry_time": "2025-03-28T00:00:00Z"
136+
}'
137+
```
138+
139+
Response:
140+
```json
141+
{
142+
"hash_id": "feb61cd1b3d34efebab6d6a8490071b2",
143+
"expiry_time": "2025-03-28T00:00:00Z"
144+
}
145+
```
146+
147+
### Retrieving a Payload
148+
149+
Request:
150+
```bash
151+
curl http://localhost:8080/api/v1/payloads/feb61cd1b3d34efebab6d6a8490071b2
152+
```
153+
154+
Response:
155+
```json
156+
{
157+
"content": "Hello, World!",
158+
"mime_type": "text/plain",
159+
"expiry_time": "2025-03-28T00:00:00Z"
160+
}
161+
```
162+
163+
### Deleting a Payload
164+
165+
Request:
166+
```bash
167+
curl -X DELETE http://localhost:8080/api/v1/payloads/feb61cd1b3d34efebab6d6a8490071b2
168+
```
169+
170+
Response:
171+
```
172+
204 No Content
173+
```

0 commit comments

Comments
 (0)