The aiwow.dev tech stack: FastAPI, Postgres, Caddy and a CI gate for agent commits

in AI-Assisted Development

A blog that coding agents commit to needs something between their commit and the live site that can say no, and a way back when the server dies.

  1. What is aiwow.dev built on?
  2. What happens when you open a page?
  3. How does a post get from a chat to the site?
  4. What stops a bad commit from going live?
  5. How do I know it is working?
  6. What if the server dies?
  7. What is still missing?
  8. Summary

Most of this site's code was written by Claude chats, several at a time. A chat can be wrong with full confidence: a failing test it didn't run, a secret pasted into a file, a dependency with a known hole. If every commit to main went straight to the server, any of those would be live within minutes, and I would find out from a reader.

So the app itself is small, and most of the code is the checks around it. This post follows one file, this post, from the commit that adds it to the page you are reading.

What is aiwow.dev built on?

One Python app on one rented server, with Postgres beside it and Caddy in front.

Tool Used for
Python 3.13, FastAPI 0.148, uvicorn The app: one worker, Jinja templates, hand-written CSS
markdown-it-py, Pygments Posts are Markdown files with front matter, rendered in memory
Postgres 17 (pgvector), SQLAlchemy 2.1 async, Alembic Build telemetry and the health check
Caddy 2.11.7 + caddy-ratelimit HTTPS, security headers, per-IP limits
Docker Compose, GHCR Five containers on one server, images tagged by commit
GitHub Actions ci, deploy, security, perf, zap and links workflows
ruff, pyright, pytest Lint, types and 670 test functions as of 3 November, coverage floor 96%
gitleaks, pip-audit, Trivy, Semgrep, OWASP ZAP Secrets, dependencies, images, code and the running site
Grafana Alloy v1.21.0, Grafana Cloud, Sentry Metrics, logs, traces and exceptions
k6 A latency budget on the two busiest pages
pg_dump, age, rclone, S3 Encrypted backups off the server, restored every week

You don't need any of this to follow along. The same shape works for any small site that more than one person, or agent, can commit to.

What happens when you open a page?

Your browser talks to Caddy, Caddy talks to the app, and the app answers from memory. Only Caddy faces the internet.

readerHTTPS 4431 CaddyTLS, headers, limits2 Postgres 17telemetry, health FastAPI appposts baked in3 Grafana Cloudmetrics, logs, traces Alloyscrapes every 60 s
Figure 1. Four containers on one server.
  1. Your browser opens an HTTPS connection to Caddy on port 443.
  2. Caddy adds the security headers, checks the rate limit and passes the request to the app on port 8000.
  3. The app renders the post from memory and sends the HTML back the same way.

Posts ship inside the app's image, so rendering this page reads no database row. Postgres only holds the site's build telemetry and answers /healthz. If the database is down, posts still load.

Caddy is the only container with a public port. It sets a strict content security policy (default-src 'self'), HSTS and nosniff on every response. It allows 120 page requests a minute per IP, and 1,200 for static files, so one page's CSS and fonts don't use up its page budget. Stock Caddy has no rate limiter, so CI builds its own Caddy image with the caddy-ratelimit module and scans it like the app.

The app and Caddy containers are read-only, drop every Linux capability they don't need, and have memory caps: 256 MB for Caddy, 512 MB for the app, 1 GB for Postgres.

One warning: the app runs a single uvicorn worker that also serves /static. That is why static files have their own, higher rate limit. Unlimited static traffic could starve the one worker that renders pages.

How does a post get from a chat to the site?

Every post starts as a file with draft: true, and the site returns 404 for a draft.

I write posts with Claude through a blog skill. It writes the Markdown, the figures and the sources list, and it is not allowed to set draft: false. I read the draft on my own machine and flip the flag myself. The build records on /runs come from the other direction: three import scripts copy runs, records and docs from the agent harness into content/.

Either way, nothing reaches the site without a commit to main. Several chats commit to the same checkout, so they push through one script that takes a lock first, described in One push at a time. How a feature gets planned and split across agents before that commit is in /mow: multi-agent orchestration for AI coding agents.

What stops a bad commit from going live?

Two gates and one switch, run by GitHub Actions on every push to main. Numbers in the figure match the list below. The dashed arrow is the one message that crosses from GitHub to the server.

GitHub Actions Server cion push · lint · tests ✕ build2 images → GHCR scanpip-audit · Trivy · Semgrep ✕ stopped built, held deploy.shpull by commit sha live green red scan red flag off flag on · private SSH 1 2 3 4 5
Figure 2. How a push to main reaches the server.
  1. ci runs gitleaks over the history, a check that nothing private is served, then ruff, pyright and pytest against a real Postgres. Coverage under 96% fails it. Red stops everything.
  2. build runs only after ci is green. It builds two images, the app and the custom Caddy, tags both with the commit sha and pushes them to GHCR.
  3. scan checks those exact images and that commit: pip-audit for Python dependencies, Trivy for the images, Semgrep for the code. Red stops the deploy. Every ignored finding sits in a committed file with a reason.
  4. The flag. A repository variable, DEPLOY_ENABLED, must be true. Off, the build and scans still run and nothing ships.
  5. deploy joins a private network for that one run, then connects over SSH through it; since 10 November, port 22 doesn't answer on the public internet. The key on the server is a forced command: it accepts only deploy <40-character sha>, then pulls that image and restarts the containers.

The forced command is the part I like most. A leaked deploy key can redeploy an image that already passed the scans. It cannot open a shell.

One warning: the deploy job never copies the Compose file or the Caddyfile to the server. It compares a hash of them and prints a warning when the server's copy lags the commit. Re-running the bootstrap script is still a manual step.

How do I know it is working?

Grafana Alloy runs on the server, scrapes the app's /metrics every 60 seconds and ships metrics, container logs and traces to Grafana Cloud's free tier. Labels use the route template, never the raw path, to stay inside the free budget. Exceptions go to Sentry, tagged with the commit sha.

Three workflows check the site from outside on a schedule, every Monday:

  • perf runs k6 against a local copy of the stack. A p95 over 300 ms on / or a post, or more than 1% failed requests, fails the job.
  • zap runs an OWASP ZAP baseline scan, and also runs after each deploy.
  • links checks every link with lychee.

The security scans also re-run on Mondays, so a new advisory against unchanged code still shows up.

What if the server dies?

A backup leaves the server every night at 06:15 Istanbul time (GMT+3), and a drill restores one every Sunday at 08:00.

backup.sh dumps Postgres and the app's env file, packs them, encrypts the archive with age and uploads it to S3. The server's S3 key can only add files. It cannot list, read or delete them. The bucket's Object Lock decides how long backups live, so a stolen server key cannot wipe the history. The server keeps its newest 3 encrypted copies locally.

The drill uses a different key that can only read. It downloads the newest backup from S3, decrypts it, restores it into a throwaway Postgres and checks that the migration table and the five telemetry tables exist. It restores from S3 on purpose: testing the local copy would prove nothing about losing the server. Pass or fail, it writes the result to a file the app exposes on /metrics, so a failed drill shows up in Grafana. Why a check needs to be seen failing before you trust it is in A guard you never saw fire isn't a guard.

What is still missing?

  • One server, one worker. There is no second machine. If the server is down, the site is down until I restore it.
  • Config drift is a warning, not a gate. A changed Caddyfile reaches the server only when I re-run the bootstrap script.
  • The drill allows an empty table. Nothing writes telemetry into production yet, so the drill does not yet require rows in the commit table. A setting turns that on once ingest runs there.

Summary

  • Posts are files baked into the image. The database is not on the reading path.
  • Only Caddy faces the internet, with strict headers and per-IP limits.
  • A commit goes live only after ci, a build and three scanners pass, and only while the deploy flag is on.
  • The deploy key can only ask for one commit sha. It cannot open a shell.
  • Backups leave the server with a write-only key, and a weekly drill restores one from off the server.
  1. Turn on the drill's row check once telemetry ingest runs in production.
  2. Make a lagging Compose file or Caddyfile fail the deploy instead of warning.
  3. If traffic ever needs it, add a second uvicorn worker before a second server.