Skip to content

Architecture

Pummelchen edited this page Sep 13, 2026 · 20 revisions

Architecture

Design stage. Nothing here is implemented.

Shape

One Swift engine process handles all three Minecraft servers and the website. A master Caddy owning ports 80 and 443 for the whole host fronts it. The Minecraft servers run under systemd units the engine generates.

           :80 :443                 127.0.0.1:8787
   browser ──▶ Caddy ──────────────▶ mod engine ──┬──▶ state DB (SQLite, WAL)
                                                  ├──▶ mod store (sha256)
                                                  ├──▶ Google Sheets
                                                  └──▶ test sessions

   player  ──▶ :25565 / :25566 / :25567  (Minecraft servers, systemd)

Nothing sits between a player and their server. All three servers run continuously.

Minecraft version Minecraft port Role
26.1 25565 from the version table
26.2 25566 from the version table
26.3 25567 from the version table

Ports are allocated from a configured range when a version is added, not assigned by hand. Roles live in a column — see Adding a Version.

Components

Component Responsibility
Mod engine One Swift 6.3.3 process: reconciliation for every version, the website API, conflict-test scheduling, Minecraft supervision. See Engine.
Minecraft servers One systemd-managed JVM per version, unit generated from a template.
Mod store Content-addressed jar storage. Server and test mod directories are hardlinks into it.
State database Local SQLite in WAL mode: versions, modsets, verdicts, conflict graph, deployment history. See State Database.
Caddy Master edge on 80 and 443 for the whole host, HTTP/3, routing by hostname. Serves the static site and proxies /api/* to the engine. See Edge and TLS.

Why one engine rather than three

v1 ran three Swift services on three loopback ports, one per Minecraft version. That meant three systemd units, three Caddy route blocks, three copies of every fix, and nowhere to put logic spanning versions — the conflict graph is worth far more when it accumulates across all of them.

Collapsing to one process means a new Minecraft version adds no service and no Caddy configuration. It adds a row.

The Minecraft servers stay under systemd rather than becoming engine children, because they are long-lived JVMs that must survive an engine restart. The engine generates their units instead of requiring them to be written by hand.

Server status

The website shows which servers are up. Status is read by querying each Minecraft server over the Server List Ping protocol on loopback, not by the engine reporting on itself.

One query returns liveness, player count, maximum players and the MOTD, and it exercises the same path a real client uses. A server hung in a way that still satisfies an internal health check will still fail a real ping — which is precisely the case worth detecting.

Filesystem layout

/var/minecraft/
├── shared/
│   ├── store/<sha256>.jar        content-addressed mod jars
│   ├── state.db                  SQLite (WAL) — versions, modsets, verdicts, conflicts
│   ├── state.db-wal              part of the database; never copy state.db alone
│   └── backups/                  VACUUM INTO snapshots
├── 26.1/
│   ├── sets/<digest>/            materialized mod sets (hardlinks)
│   ├── current -> sets/<digest>  the deployed set
│   ├── world/
│   └── logs/
├── 26.2/  …
├── 26.3/  …
├── test/
│   └── <run-id>/                 throwaway session, deleted after
└── web/
    └── site/public/              served by Caddy

/etc/pummelchen/
├── engine.toml                   no version strings in here
├── google-service-account.json   owner read-only
└── tls/                          certificate, obtained externally

Materialized sets are hardlinks into the store, so keeping the last several validated sets for instant rollback costs almost nothing.

Storage

Three versions of ~300 mods averaging 8 MB is about 7 GB naive. Deduplicated through the content store — many mods are byte-identical across versions — it is closer to 4–5 GB. A test scratch directory costs essentially zero bytes and materializes instantly.

Store blobs with no referencing modset are prunable, but pruning must keep anything referenced by a retained rollback target.

Test session isolation

Test servers are ordinary Minecraft servers with three constraints:

  • They may only write beneath /var/minecraft/test/, validated by path before launch.
  • They bind loopback-only scratch ports and run offline-mode.
  • They run under systemd-run --scope with resource limits and a raised oom_score_adj.

The last point is not about rationing capacity. It exists so a mod that leaks or spins can never take a live server down with it.

Deliberate non-goals

  • No containers. cgroup limits via systemd-run give the enforcement that matters without image management.
  • No client-side testing. v1 ran headless client soaks with a real Minecraft account. They caught real problems but would make every bisection round enormously expensive.
  • No proxy in front of the Minecraft ports. Servers stay up, so nothing needs one, and a proxy in the player path is a failure domain with no compensating benefit.
  • No per-version service. The thing that made v1 tedious to extend.

Clone this wiki locally