← Back to the home page

Behind the scenes

How I built this site

This portfolio is a small serverless web app on Cloudflare. I wrote it in plain HTML, CSS and JavaScript with no framework, so I can explain every part of it. It runs on Cloudflare's free plan, at my own domain, ajayhearn.uk, which is registered through Cloudflare too.

Architecture of this website Visitors and the admin panel talk to Cloudflare over HTTPS. Cloudflare Pages serves the files and Pages Functions run the API. The functions read and write Workers KV, read encrypted secrets, and send contact form messages to a Discord channel through a webhook. I deploy from my Mac with Wrangler and push the code to GitHub. Cloudflare (free plan) Cloudflare Pages HTML, CSS and JavaScript files Pages Functions (/api) public: page content, images admin: log in, save, upload images contact form Workers KV site content uploaded images rate-limit counters Encrypted secrets admin password session signing key Discord webhook Visitor's browser loads the page, then the content from /api Me, at /admin password login My Mac Wrangler CLI Discord channel contact form messages GitHub code and history HTTPS HTTPS webhook deploy git push
How the parts connect. Arrows show which way requests go.

What happens when someone visits

  1. The browser asks Cloudflare for the page. Cloudflare Pages sends the HTML, CSS and JavaScript from its global network, so it loads quickly wherever the visitor is.
  2. The page's JavaScript then asks for /api/content. A Pages Function (a small piece of server code running on Cloudflare) reads my content from Workers KV, Cloudflare's key-value database, and returns it as JSON.
  3. The JavaScript builds each section from that content. All text is inserted as plain text, never as HTML, so nothing saved in the admin panel can inject code into the page.
  4. Images are served from /api/images/…. Each image has a random ID that never changes, so browsers can cache them for a year.

How I edit the content

How the contact form works

The form sends the message to a Pages Function. The function checks it and posts it to a private channel in my Discord server using a Discord webhook. The webhook address is kept as an encrypted secret, so visitors never see it. Before anything is stored or sent, Cloudflare Turnstile checks that the visitor is a person, and the function confirms that result with Cloudflare. This means requests sent straight to the API without passing the check are refused. A hidden "honeypot" box also catches simple bots, and each connection can send 5 messages an hour. Messages can't ping anyone in the server.

Security

Accessibility

How I deploy changes

Tools and services