JAlcocerTech E-books

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:

  1. Web standards, no platform SDK. The Worker is a plain fetch(request, env, ctx) handler: Request, Response, URL, crypto.subtle. The platform-specific surface is env.LEADS and ctx.waitUntil.
  2. Same-origin paths. Sites post to /api/forms/submit on their own domain. Whatever answers that path can change without touching a site.
  3. 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.
  4. Adapters for providers. Email goes through one switch; Mailpit or any SMTP relay works in development.
  5. Rules in files, not dashboards. Retention, the site registry, the spam blocklist, consent wording: versioned, reviewable, portable.
  6. 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

PieceTodaySelf-hosted swapWhat keeps it cheapEffort
Static sitesCloudflare PagesA static file server behind TraefikPlain static outputLow
HTTPS certificatesCloudflare edgeTraefik + Let’s Encrypt (automatic)Standard DNSLow
Security headers_headers fileTraefik headers middlewareSame header list, new syntaxLow
Forms endpointWorker on /api/forms/*PocketBase route + hooks, same pathSame-origin path, web-standard handlerMedium
Lead inbox and retentionKV with TTLsPocketBase collection + a daily cron hookRetention rules in one fileLow–medium
Mirror and analysisHomelab SQLitePocketBase is SQLiteSame data modelLow
Secretswrangler secret.env or Docker secretsRead from env onlyLow
EmailMailjet APISame provider, or any SMTP relaySender adapterConfig only
Alertsntfy (already self-hosted)Same—None
ExposureCloudflare TunnelOpen 80/443 on a VPS, or a WireGuard tunnel to oneHub only pullsMedium
AnalyticsCloudflare Web AnalyticsUmami or Plausible CEOne script tagLow
SpamHoneypot + blocklist in codeSame codeNothing platform-specificNone
Scheduled rebuildsCron Worker + deploy hooksA cron job that builds and copies dist/—Low
Global CDN, DDoSCloudflareNo 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.

Next: the fully self-hosted version.