Rajveer Mahida

Driftmail

A Gmail-style email client that runs entirely on a single Cloudflare Worker — SPA, JSON API, inbound email ingestion, and an AI layer for summarizing and replying, with nothing outside Cloudflare's edge.

role
Solo builder
stack
React 19, Hono, Cloudflare Workers, D1, R2, Claude API
when
Personal project, ongoing
browser spaworker (hono)email routingd1r2claude api
system diagram · one worker, no origin server
1
Worker serving SPA, API, cron & ingestion
0
traditional servers — fully edge-deployed
2
AI features: summarize & smart reply

Problem

Most self-hosted email clients need a mail server, a database server, a job queue, and a frontend host — four things to deploy and pay for just to read email in a nice UI. I wanted a Gmail-quality inbox that costs nothing to run at low volume and needs no server to manage.

Approach

Cloudflare's edge platform collapses that into one deployable unit. Hono runs the JSON API and serves the built React SPA from the same Worker. Email Routing pipes inbound mail straight into the Worker instead of a separate mail server. D1 stores message metadata and threads; R2 stores raw MIME bodies and attachments. A Cron Trigger handles undo-send by holding outbound mail for a short delay window before actually sending.

Decisions

ingestion
Cloudflare Email Routing forwards raw MIME to the Worker, which parses it and writes metadata to D1 and the body/attachments to R2 — no IMAP/SMTP server to run.
undo send
Outbound mail is queued in D1 with a send-after timestamp; a Cron Trigger polls every minute and only dispatches once the undo window has passed.
ai layer
Thread summarize and smart-reply call the Anthropic Claude API directly from the Worker — no separate AI service, same request/response cycle as the rest of the API.
delivery
Web push notifications, keyboard shortcuts, and swipe gestures were layered onto the SPA to make the edge-hosted client feel native.

What I'd change

D1's per-database size limits mean attachment-heavy accounts will eventually need R2 lifecycle rules for cold storage — currently unbounded. Next iteration moves large-attachment cleanup into the same cron that handles undo-send.

React 19, Hono, Cloudflare Workers, D1, R2, Email Routing, Cron Triggers, Claude API, Web Push