Pragmatism, With an Exit
I care about open source and self-hosting, and I have a homelab. The public half of my engine still runs on Cloudflare. This chapter is why, and how I make sure that’s a choice I can reverse.
Why a platform, today
The homelab can be down and nothing is lost. Forms keep working while my server reboots, my internet drops or I’m travelling. Self-hosting the capture path would make a home connection the single point of failure for every lead.
The volume fits the free tier. A small business gets tens of leads a month. The only bill in the whole engine is email delivery.
There’s almost nothing to operate. No server to patch on the public path, certificates renewed for me, attacks absorbed at the edge. For one person, time spent operating infrastructure is time not spent with clients.
It’s fast to change. git push or wrangler deploy. A new site joins the
engine with a route and a registry entry.
The rules that keep leaving cheap
Pragmatism turns into lock-in when platform specifics spread through the code. Six rules prevent it:
- Web standards, no platform SDK. The Worker is a plain
fetch(request, env, ctx)handler:Request,Response,URL,crypto.subtle. The platform-specific surface isenv.LEADSandctx.waitUntil. - Same-origin paths. Sites post to
/api/forms/submiton their own domain. Whatever answers that path can change without touching a site. - A copy of the data off-platform from day one. The homelab mirrors every lead into SQLite. KV is the inbox, not the only copy.
- Adapters for providers. Email goes through one switch; Mailpit or any SMTP relay works in development.
- Rules in files, not dashboards. Retention, the site registry, the spam blocklist, consent wording: versioned, reviewable, portable.
- Decisions written down. Short architecture decision records with the alternatives considered. When a decision is revisited, the exit plan already has a starting point.
When I’d move
None of these is true today; each would change the answer:
- A client requirement: data processed in a specific place, or by no US provider.
- Price or terms: free tiers change.
- Volume: at some point a small server is cheaper and simpler.
- Querying: when the edge code itself needs SQL across leads. That’s a move to D1 inside the platform, or to a database outside it.
- Principle: some businesses simply want everything on hardware they control, and that’s a valid reason.
The exit table
| Piece | Today | Self-hosted swap | What keeps it cheap | Effort |
|---|---|---|---|---|
| Static sites | Cloudflare Pages | A static file server behind Traefik | Plain static output | Low |
| HTTPS certificates | Cloudflare edge | Traefik + Let’s Encrypt (automatic) | Standard DNS | Low |
| Security headers | _headers file | Traefik headers middleware | Same header list, new syntax | Low |
| Forms endpoint | Worker on /api/forms/* | PocketBase route + hooks, same path | Same-origin path, web-standard handler | Medium |
| Lead inbox and retention | KV with TTLs | PocketBase collection + a daily cron hook | Retention rules in one file | Low–medium |
| Mirror and analysis | Homelab SQLite | PocketBase is SQLite | Same data model | Low |
| Secrets | wrangler secret | .env or Docker secrets | Read from env only | Low |
| Mailjet API | Same provider, or any SMTP relay | Sender adapter | Config only | |
| Alerts | ntfy (already self-hosted) | Same | — | None |
| Exposure | Cloudflare Tunnel | Open 80/443 on a VPS, or a WireGuard tunnel to one | Hub only pulls | Medium |
| Analytics | Cloudflare Web Analytics | Umami or Plausible CE | One script tag | Low |
| Spam | Honeypot + blocklist in code | Same code | Nothing platform-specific | None |
| Scheduled rebuilds | Cron Worker + deploy hooks | A cron job that builds and copies dist/ | — | Low |
| Global CDN, DDoS | Cloudflare | No self-hosted equivalent | — | High: rent it or accept it |
The honest summary: almost everything can move in days. The one thing you can’t self-host is a global edge network. If I left, I’d either accept serving from one location (fine for most small businesses) or keep only DNS and caching on a CDN while everything else lives on my own server.
Chapter 7 is that move, built out: the same engine on PocketBase behind Traefik.