Skip to content

Letters is a full-stack application built to handle self-destructing messages. It uses a modern edge-native stack: React 19 on the frontend, Hono running on Cloudflare Workers for the backend, and Drizzle ORM with Cloudflare D1 for the database. Every design decision was made to prioritize speed, privacy, and impermanence.

Most of what we send each other online is disposable. Hundreds of messages a day, none of them meaning much. The things that actually matter get buried in the noise.

I wanted to build the opposite. A place where you write one message to one person, share it as a single link, and know it will disappear. The impermanence is the point.

Letters started as something much smaller — a personal tool for a personal moment. But I realized early that a tool designed for one person isn’t really a tool. It’s a gift. And gifts are fragile. If the one person doesn’t want it, the whole thing falls apart.

Letters lets you write one message to one person and share it as a link. The recipient opens it, reads it, and can reply. Then it disappears.

You can customize every part of the letter — the background, the font, the message box, the buttons. Add motion effects: hearts, confetti, snow, fireworks.

Every letter lives on a progressive timer:

  • 7 days from creation
  • 3.5 days after it’s been opened
  • 1.75 days after it’s been replied to
Created Opened Replied Expired 7.0 days 3.5 days 1.75 days

Why halve the time? It’s a design choice for speed and space. Every interaction cuts the letter’s life in half, forcing it to die faster. This keeps the database clean and saves storage space on Cloudflare D1.

Even if a letter is completely ignored (never opened or replied to), it doesn’t matter. The original 7-day timer always runs out, meaning the space is guaranteed to be reclaimed automatically. Nothing lives forever here.

Letters has to render identically in two completely different environments:

1. The live app — React 19, Motion, Tailwind CSS, TypeScript

2. The downloaded HTML — plain HTML, CSS, and vanilla JavaScript

patterns/confetti-burst.ts
export default {
id: 'confetti-burst',
component: () => ( /* React */ ),
standalone: {
  script: `/* vanilla JS */`,
},
}

Keeping these two renderers in sync was the single biggest engineering problem.

The codebase is split into clear layers:

src/ pages/ letter/ core/ db/

Flow: pages → letter → core → db

Nothing skips layers. Nothing imports backward.

Here is the exact lifecycle of a request. When a user creates a letter, the data travels down from the React client, into the Hono API, and finally queries the Cloudflare D1 database.

Once the database confirms the write, the JSON payload travels back up, arches through the API layer, and renders the final response to the user.

User React App Vite + Tailwind Hono API Cloudflare Worker Cloudflare D1 Drizzle ORM Form Data POST /letters SQL Query DB Result JSON Response (Rendered Data)

Because letters have to self-destruct, the database needs a strict cleanup routine so it doesn’t fill up with dead data.

The system relies on two triggers:

  1. A Cron job that runs every day at 3 AM.
  2. A User Threshold that triggers when there are over 100 users or letters.

Whenever either of these triggers fires, it runs the exact same logic: Normal Cleanup always runs first, followed by a storage check. If the database is over 90% full, it runs an aggressive Pressure Cleanup.

Cloudflare Worker trigger 1 Cron 3 AM daily trigger 2 POST /letters user threshold runCleanup() always runs first Normal Cleanup deletes expired letters sessions + orphan users Storage ≥ 90%? yes Pressure Cleanup deletes oldest letters and inactive users

Flow: Trigger → runCleanup() → Normal → Check 90% → Pressure

This ensures the database stays healthy and prevents Cloudflare from hitting its storage limits.

Decision Why Trade-off
Cloudflare Workers Global edge, no servers No full Node APIs
Drizzle over Prisma Smaller bundle, better TS Fewer tutorials
Better Auth Self-hosted, free More setup

Reading code is a different skill from writing code. I can read what AI generates now — spot what’s wrong, what’s missing, what needs to change.

The distance between “it works on my machine” and “it works for the person who needs it” is the whole project.

  • chore(deps): update astro and dependencies

    e891276 · 2m ago

  • Starred the repo

    22d ago

  • fix: update D1 database ID and wrangler config

    01986eb · 28d ago

  • Merge branch 'new'

    b765abf · 28d ago

  • refactor: unify time to seconds and fix cleanup flow

    cf5260f · 28d ago