Skip to content

Commit ebb300d

Browse files
nullcoderclaude
andauthored
docs: add TODO tracker and update documentation for Cloudflare Workers
Added comprehensive implementation tracking and updated all documentation to accurately reflect Cloudflare Workers deployment architecture. Key additions: - Created TODO.md with 9-phase implementation roadmap covering setup, development, testing, and deployment - Organized tasks by logical dependencies with progress tracking checkboxes - Updated all documentation from Next.js 14 to Next.js 15 Documentation updates for Cloudflare Workers: - Clarified that GhostPaste runs entirely on Cloudflare's edge network using native R2 bindings - Replaced AWS SDK references with Workers-specific R2 bucket bindings - Added Workers runtime limits (100MB request size, 50ms CPU time) - Updated development setup to use wrangler.toml instead of environment variables - Added scheduled worker configuration for CRON-based expiry cleanup - Enhanced README with Wrangler CLI setup and deployment instructions - Added reminders to use official documentation and CLI tools The project now has clear guidance for building a Next.js application deployed to Cloudflare Workers with native R2 integration, providing better performance and simpler configuration than traditional approaches. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d66a73e commit ebb300d

File tree

4 files changed

+408
-45
lines changed

4 files changed

+408
-45
lines changed

CLAUDE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,8 @@ For detailed architecture, API specs, and data models, refer to `docs/SPEC.md`.
7474
7. When merging, write commit summary from all commits in the pull request
7575
8. Use a comprehensive summary (not a commit list) as the squash merge commit message, describing the overall work accomplished in the PR
7676
- Prefer rebase over merge to keep history clean
77-
- Always pull latest changes from `main` before starting new work
77+
- Always pull latest changes from `main` before starting new work
78+
79+
## Best Practices
80+
81+
- Always check official documentation of frameworks, UI components, Cloudflare, CodeMirror before implementing changes. If they provide generator or command line, please follow the documentation instead of manually generate them.

README.md

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ Simply open the shared link - the decryption key is in the URL fragment and neve
4242

4343
## 🛠️ Technical Stack
4444

45-
- **Frontend**: Next.js 14+ with React
45+
- **Framework**: Next.js 15 with React
46+
- **Runtime**: Cloudflare Workers (Edge)
4647
- **UI Components**: shadcn/ui
4748
- **Code Editor**: CodeMirror 6
4849
- **Encryption**: Web Crypto API (AES-GCM)
49-
- **Storage**: Cloudflare R2
50-
- **Deployment**: Cloudflare Workers
50+
- **Storage**: Cloudflare R2 with native bindings
5151

5252
## 📊 Limits
5353

@@ -63,8 +63,9 @@ Simply open the shared link - the decryption key is in the URL fragment and neve
6363
### Prerequisites
6464

6565
- Node.js 18+
66-
- npm or yarn
67-
- Cloudflare account (for R2 storage)
66+
- npm or yarn
67+
- Cloudflare account (for Workers and R2)
68+
- Wrangler CLI (`npm install -g wrangler`)
6869

6970
### Setup
7071

@@ -76,29 +77,56 @@ cd ghostpaste
7677
# Install dependencies
7778
npm install
7879

79-
# Copy environment variables
80-
cp .env.example .env.local
80+
# Login to Cloudflare
81+
wrangler login
8182

82-
# Configure your Cloudflare R2 credentials in .env.local
83+
# Create R2 bucket
84+
wrangler r2 bucket create ghostpaste-bucket
85+
86+
# Copy wrangler configuration
87+
cp wrangler.toml.example wrangler.toml
8388

8489
# Run development server
8590
npm run dev
8691
```
8792

88-
### Environment Variables
93+
### Configuration
94+
95+
Create a `wrangler.toml` file:
96+
97+
```toml
98+
name = "ghostpaste"
99+
compatibility_date = "2024-12-01"
100+
101+
[[r2_buckets]]
102+
binding = "GHOSTPASTE_BUCKET"
103+
bucket_name = "ghostpaste-bucket"
104+
105+
[vars]
106+
NEXT_PUBLIC_APP_URL = "https://ghostpaste.dev"
107+
```
108+
109+
For local development secrets, create `.dev.vars`:
110+
111+
```
112+
# Any additional secrets go here
113+
```
114+
115+
### Deployment
116+
117+
```bash
118+
# Build for Cloudflare Workers
119+
npm run build
89120

90-
```env
91-
CLOUDFLARE_ACCOUNT_ID=your_account_id
92-
CLOUDFLARE_R2_ACCESS_KEY_ID=your_access_key
93-
CLOUDFLARE_R2_SECRET_ACCESS_KEY=your_secret_key
94-
CLOUDFLARE_R2_BUCKET_NAME=ghostpaste-bucket
95-
NEXT_PUBLIC_APP_URL=http://localhost:3000
121+
# Deploy to production
122+
npm run deploy
96123
```
97124

98125
## 📖 Documentation
99126

100127
- [Technical Specification](docs/SPEC.md) - Detailed architecture and implementation details
101128
- [AI Development Guide](CLAUDE.md) - Guidelines for AI-assisted development
129+
- [Implementation TODO](docs/TODO.md) - Development roadmap and progress tracking
102130

103131
## 🤝 Contributing
104132

docs/SPEC.md

Lines changed: 62 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,24 @@ GhostPaste is a zero-knowledge encrypted code sharing platform where users can c
1717

1818
## 🏗️ Architecture
1919

20+
### Deployment Model
21+
22+
GhostPaste runs entirely on Cloudflare's edge network:
23+
- **Next.js** deployed via Cloudflare Workers using `@cloudflare/next-on-pages`
24+
- **R2 Storage** accessed through native Workers bindings (no AWS SDK needed)
25+
- **Zero cold starts** with Workers' always-warm edge runtime
26+
- **Global distribution** across Cloudflare's network
27+
2028
### Tech Stack
2129

2230
| Component | Technology | Purpose |
2331
| -------------- | --------------------------------------- | --------------------------------- |
24-
| **Frontend** | Next.js 14+ (SPA mode) | React framework with app router |
32+
| **Frontend** | Next.js 15 | React framework with app router |
2533
| **UI Library** | [shadcn/ui](https://ui.shadcn.com) | Modern, accessible components |
2634
| **Editor** | CodeMirror 6 | Syntax highlighting & editing |
2735
| **Encryption** | Web Crypto API | AES-GCM client-side encryption |
28-
| **Backend** | Next.js API + Cloudflare Workers | API endpoints & edge computing |
29-
| **Storage** | Cloudflare R2 | Object storage for all data |
36+
| **Runtime** | Cloudflare Workers | Edge computing platform |
37+
| **Storage** | Cloudflare R2 | Object storage with native bindings |
3038

3139
### Storage Structure
3240

@@ -135,6 +143,8 @@ For editable gists:
135143

136144
## 🔌 API Endpoints
137145

146+
All API routes run on Cloudflare Workers with Edge Runtime.
147+
138148
### Create Gist
139149

140150
```http
@@ -222,6 +232,8 @@ Error codes:
222232
| Update rate | 60/hour/IP | Allow active editing |
223233
| Minimum PIN length | 4 digits | Basic security |
224234
| Maximum PIN length | 8 digits | Usability |
235+
| Request size | 100 MB | Cloudflare Workers limit |
236+
| CPU time | 50ms | Workers CPU limit |
225237

226238
---
227239

@@ -235,16 +247,18 @@ Users can set expiration times:
235247
- Default: No expiration
236248

237249
Implementation:
238-
- Cloudflare Workers CRON job
250+
- Separate Cloudflare Worker with scheduled trigger
239251
- Checks `expires_at` field hourly
240-
- Deletes expired gists + versions
252+
- Batch deletes expired gists + versions
253+
- Configured in wrangler.toml
241254

242255
### 2. One-Time View
243256

244257
Gists that delete after first decryption:
245-
- Special flag in metadata
258+
- `one_time_view: true` flag in metadata
246259
- Client notifies server after successful decrypt
247-
- Server immediately deletes
260+
- Server immediately deletes all gist data
261+
- Optional download before viewing
248262

249263
### 3. Version History
250264

@@ -322,35 +336,54 @@ img-src 'self' data: https:;
322336
### Development Setup
323337

324338
```bash
325-
# Environment variables
326-
CLOUDFLARE_ACCOUNT_ID=
327-
CLOUDFLARE_R2_ACCESS_KEY_ID=
328-
CLOUDFLARE_R2_SECRET_ACCESS_KEY=
329-
CLOUDFLARE_R2_BUCKET_NAME=ghostpaste-bucket
330-
NEXT_PUBLIC_APP_URL=https://ghostpaste.dev
331-
332-
# Commands
339+
# Install dependencies
333340
npm install
341+
342+
# Local development with Wrangler
334343
npm run dev
344+
345+
# Build for Cloudflare Workers
335346
npm run build
347+
348+
# Deploy to Cloudflare Workers
336349
npm run deploy
337350
```
338351

339-
### R2 Configuration
352+
### Wrangler Configuration
340353

341-
```bash
342-
# Create bucket
343-
wrangler r2 bucket create ghostpaste-bucket
344-
345-
# Set CORS
346-
wrangler r2 bucket cors put ghostpaste-bucket --rules '[
347-
{
348-
"allowedOrigins": ["https://ghostpaste.dev"],
349-
"allowedMethods": ["GET", "PUT", "POST", "DELETE"],
350-
"allowedHeaders": ["*"],
351-
"maxAgeSeconds": 3600
352-
}
353-
]'
354+
```toml
355+
# wrangler.toml
356+
name = "ghostpaste"
357+
compatibility_date = "2024-12-01"
358+
359+
[[r2_buckets]]
360+
binding = "GHOSTPASTE_BUCKET"
361+
bucket_name = "ghostpaste-bucket"
362+
363+
[vars]
364+
NEXT_PUBLIC_APP_URL = "https://ghostpaste.dev"
365+
366+
# Scheduled worker for expiry cleanup
367+
[[triggers]]
368+
crons = ["0 * * * *"] # Every hour
369+
```
370+
371+
### R2 Access in Workers
372+
373+
```typescript
374+
// Access R2 from Workers environment
375+
export interface Env {
376+
GHOSTPASTE_BUCKET: R2Bucket;
377+
}
378+
379+
// Example usage in API route
380+
export async function POST(request: Request, env: Env) {
381+
// Direct R2 access without credentials
382+
await env.GHOSTPASTE_BUCKET.put(
383+
`metadata/${id}.json`,
384+
JSON.stringify(metadata)
385+
);
386+
}
354387
```
355388

356389
### Client-Side Encryption Example

0 commit comments

Comments
 (0)