Skip to content

mocipher.com: How This Site Is Built

This site is my CV, my portfolio and my lab. It runs on no framework and zero runtime dependencies, with no analytics or trackers, and if Cloudflare Pages goes down, my homelab takes over.

I wanted one place a recruiter could read in thirty seconds and an engineer could read for an hour. So the front is plain: experience first, projects, a CV to download. The back is where I practise the work I do for a living: operations, incident response, and keeping a service up when the platform under it is not.

The source is public on my own Forgejo: git.mocipher.com/m01/MoCipher.

What it is made of

Twelve HTML pages, about 4,000 lines of vanilla JavaScript and 4,000 lines of CSS. No React, no bundler framework, nothing in dependencies. The only packages are build and test tools: esbuild, jsdom and wrangler.

  • Cloudflare Pages serves the pages.
  • 33 Pages Functions serve everything that changes: experience, projects, posts, settings, the contact form, the RSS feed and the sitemap.
  • KV holds that content, and R2 holds uploads such as my CV.
  • A small admin panel edits all of it: a password with optional TOTP, a session cookie, and an editor for posts.

The homepage renders from one request. A single endpoint returns everything the page needs, and the edge caches it. When I save something in the admin, the server purges exactly the cached URLs that changed.

Security without a vendor

No analytics, no fonts from a CDN, no tag manager. Scripts, styles and fonts all come from this origin, and the one inline style block is allowed by its hash in the Content Security Policy, not by unsafe-inline. Every time a blog post is served, as a page or in the RSS feed, it goes through a server-side sanitiser first. An uploaded SVG is served so its scripts cannot run, and my CV is kept out of search results while images stay indexable. The one exception is the contact form: it uses Cloudflare Turnstile, which loads its challenge from Cloudflare, and only when you scroll to the form.

A build step that earns its place

tools/build.mjs copies only the public files into dist/. It content-hashes and minifies every stylesheet and script (28% smaller), rewrites every reference to the hashed names, and gives the service worker a cache name derived from the build. Before it existed, cache-busting was hand-typed version numbers across twelve pages, and the test folder was being published with the site.

Plan B in my homelab

A read-only mirror of the site runs on k3s in my homelab, reached through a Cloudflare Tunnel and rebuilt every night inside the cluster. A watcher checks the primary once a minute. After three failures in a row it points the domain at the mirror. After five good checks in a row it points it back. Every move pages my phone through ntfy, which I host myself. An iPhone only wakes for Apple's push service, so that one step goes through ntfy.sh, a third party; it relays a wake-up, never the alert text.

I rehearse it. The first rehearsal took the site down because of one header I had never sent, which is its own story: The Failover Drill That Took My Site Down.

Tests are how I change it safely

298 tests across 30 files, run with Node's built-in test runner. Many load a real page into jsdom with the site's own scripts and a stubbed API, then check what a visitor would see. A smoke check makes sure every stylesheet parses, every page links only clean URLs, and no page calls a function that does not exist. A pre-commit hook runs all of it.

One recent catch: certificate dates printed a day early for anyone in the Americas. A date stored as 2025-12-17 is midnight UTC, which is still the 16th in Los Angeles. I found it by running the suite under a different time zone, and the fix was to read dates in UTC.

Running it

npm ci
npm run verify   # syntax check, smoke check, 298 tests
npm run deploy   # build dist/ and publish to Cloudflare Pages

What I'd do next

  • The mirror is read-only. During a failover the site reads fine, but the admin and the contact form wait for the primary.
  • If my whole homelab goes dark, the watcher goes with it. I accepted that blind spot rather than hand monitoring to a third party.