doublespacebetav0.1.0
April 6, 2026

Building DoubleSpace: 7 Cloudflare services, zero servers

DoubleSpace is a cloud storage platform that keeps files in sync across every device — and it runs entirely on Cloudflare. No EC2 instances, no Kubernetes, no database servers. Here's how the architecture works.

The constraint

We set ourselves one rule: use only Cloudflare services. No AWS. No GCP. No third-party databases. Everything — from auth to file storage to real-time sync — has to run on Cloudflare's developer platform.

The result is an application that deploys globally with zero infrastructure management. Every request runs on the edge, within milliseconds of the user.

Architecture overview

┌──────────────────────────────────────────────────────┐
│                   doublespace.io                     │
├──────────────────────────────────────────────────────┤
│                                                      │
│           ┌──────────┐    ┌──────────────┐           │
│           │  Pages   │    │  Workers     │           │
│           │  Web UI  │───▶│  Hono API    │           │
│           └──────────┘    └──────┬───────┘           │
│                                  │                   │
│                    ┌─────────────┼──────────┐        │
│                    │             │          │        │
│              ┌─────▼─────┐ ┌────▼────┐ ┌───▼────┐   │
│              │    D1     │ │   R2    │ │   KV   │   │
│              │  SQLite   │ │ Objects │ │ Cache  │   │
│              │ 14 tables │ │  Files  │ │Sessions│   │
│              │   FTS5    │ │ Thumbs  │ │  Rate  │   │
│              └───────────┘ └─────────┘ └────────┘   │
│                                                      │
│         ┌────────────────┐  ┌─────────────────┐      │
│         │ Durable Objects│  │     Queues      │      │
│         │                │  │                 │      │
│         │  SyncRoom      │  │  Thumbnails     │      │
│         │  (WebSocket    │  │  Indexer (FTS5) │      │
│         │   per-space)   │  │  Cleanup        │      │
│         │                │  │                 │      │
│         │  UploadSession │  │                 │      │
│         │  (multipart)   │  │                 │      │
│         └────────────────┘  └─────────────────┘      │
│                                                      │
│         ┌──────────────┐   ┌──────────────────┐      │
│         │  Workers AI  │   │  CLI (Rust)      │      │
│         │  (future:    │   │  dblspc binary   │      │
│         │   semantic   │   │  sync, mount,    │      │
│         │   search)    │   │  share, search   │      │
│         └──────────────┘   └──────────────────┘      │
│                                                      │
└──────────────────────────────────────────────────────┘

Service breakdown

Workers — the API layer

The API is a single Cloudflare Worker running Hono, a lightweight web framework. It handles auth (PBKDF2-SHA256 + Google OAuth via Arctic), file metadata CRUD, presigned uploads, share links, search, and the sync change feed. Every request runs on the edge — no cold starts, no region selection.

R2 — file storage

Files are stored in R2 with a key structure of {workspaceId}/files/{fileId}/v1/original. Single uploads go through the Worker (up to 10 MB). Larger files use R2's native multipart upload API — the Worker coordinates the upload, but data flows directly to R2. Thumbnails are stored alongside originals.

The key advantage: $0 egress. Users download their own files without bandwidth charges. This is the entire economic thesis of DoubleSpace.

D1 — metadata database

D1 is Cloudflare's edge SQLite database. We have 14 tables covering users, sessions, workspaces, files, folders, share links, sync cursors, and search indexes. Drizzle ORM generates type-safe queries. A separate FTS5 virtual table powers full-text search.

KV — session cache and rate limiting

KV stores two things: session tokens (keyed by token hash, with TTL matching session expiry) and rate limit counters (sliding window per user per endpoint). The auth middleware checks KV first — if the session is cached, we skip the D1 roundtrip entirely.

Durable Objects — real-time sync

This is the most interesting piece. Each workspace gets its own SyncRoom Durable Object. When a client connects via WebSocket, it subscribes to the room. When any device uploads, deletes, or renames a file, the API route sends a notification to the SyncRoom, which broadcasts to all connected clients. They refresh their file list instantly.

A second Durable Object, UploadSession, tracks multipart upload state. It uses the alarm API to auto-abort uploads that stall for more than 24 hours — preventing orphaned partial uploads from consuming R2 storage.

Queues — background processing

Three queues handle work that shouldn't block the upload response:

  • Thumbnails — generates thumbnails for image files and stores them in R2
  • Indexer — extracts text from text/JSON files, populates the FTS5 search index
  • Cleanup — expires share links, purges 30-day-old trash, aborts stale multipart uploads

Pages — the web UI

The web interface runs on Cloudflare Pages via Vinext (Cloudflare's Vite-based Next.js replacement). It's a terminal-inspired dark UI with a file browser, drag-and-drop uploads, share link creation, trash management, and full-text search. WebSocket connections to the SyncRoom keep the UI in sync across tabs and devices.

The Rust CLI

The CLI (dblspc) is a Rust binary using Clap for argument parsing. It supports device auth flow (polls the API while the user approves in browser), bidirectional sync with file watching, FUSE/WinFSP drive mounting, and share link creation. Credentials are stored in the OS keychain via the keyring crate.

What we learned

Building a full product on Cloudflare's platform is genuinely viable. The developer experience is excellent — wrangler dev gives you a local environment with D1, R2, KV, and Durable Objects that behaves identically to production. The main constraints are D1's SQLite limitations (no JOINs across databases, row size limits) and Durable Objects' single-threaded execution model.

The total infrastructure cost for a small deployment is effectively $0 — R2's free tier covers 10 GB of storage, D1 gives 5 million reads/day free, and Workers handles 100,000 requests/day on the free plan.

DoubleSpace is a Flarefound project — a demonstration of what you can build when you go all-in on Cloudflare.

← All postsAI agents for your filesystem →