System architecture
Components
Section titled “Components”| Part | Folder | Role |
|---|---|---|
| Rules | src/core |
Catalog, costs, times, production, settling a planet to a point in time, flights, battle. Pure functions, used by server and browser. The universe settings are a parameter. |
| Features | src/features |
One folder per catalog entry and per mission; the core reaches them only through the generated index index.gen.ts (#112, still empty; see Design patterns). |
| Store | src/server/db |
SQLite through better-sqlite3: schema, migrations, one repository per aggregate in repos/ that maps the game objects to tables (#117; see Design patterns); store.ts is a thin facade over them. |
| Game | src/server/game |
Actions of the players, fleet arrivals, points, the state a player sees, admin actions. Clock, chance and ids are injected. |
| Accounts | src/server/auth.ts |
Invitations, registration, login, sessions. |
| HTTP | src/server/http |
JSON API under /api, the client files, /healthz, security headers, rate limit. |
src/server/mail.ts |
Invitation mails through nodemailer. | |
| Operator command | src/server/commands.ts |
`nova admin |
| Client | src/client |
logic/ (tested functions), views/ (HTML templates), main.ts (events, server calls, clock). Bundled by Vite into dist/public. |
[E] A game rule that the server checks and the browser shows lives once,
in src/core, and both sides call it (owner, 2026-11-11): the shipyard
lock (yard.ts), the lab lock (lab.ts), noob protection (protection.ts)
and the fleet slots (fleetSlots in flight.ts). Messages stay with the
caller; the rule does not.
[E] The patterns for new rules, entries and views, and the migration to them, are in Design patterns (owner, 2026-11-12).
Request flow
Section titled “Request flow”- [E] Caddy receives the request from the operator’s proxy, sets the
security headers and
X-Real-IP, forwards toapp:8080. - [V] The server refuses cross-site posts (JSON only,
Originmust beNOVA_PUBLIC_URL; a post withoutOriginis refused too, [E] #328), reads the session cookie, runs the handler. - [E] An action runs in one SQLite transaction: first all fleets that are due (in time order), then the action. All or nothing.
- The answer carries the new state of the player.
[E] How the data reach the browser, and the move to Server-Sent Events: Data exchange and realtime (owner, 2026-11-25).
The clock
Section titled “The clock”- [E] Like version 1, a timer lands due fleets every second, also while nobody is online. Each fleet event is its own transaction; a broken fleet is logged and removed instead of stopping the clock.
- Planets are not updated by the clock: production and finished queues are
computed when a planet is read (
settle), as in version 1. - [V] Expired sessions and rate-limit entries are removed once an hour.
Dependencies (runtime)
Section titled “Dependencies (runtime)”- [E]
better-sqlite3: SQLite. Synchronous, so a transaction is one function call. It brings prebuilt binaries for linux amd64 and arm64; the image has no compiler, and pnpm does not run its install script (the binary is loaded fromprebuilds/). - [E]
nodemailer: SMTP for the invitations. - Development only: TypeScript, Vitest, Stryker, ESLint (with sonarjs), Prettier, Playwright with axe, Vite.
- [E] Package manager: pnpm 12, pinned in
packageManagerofpackage.jsonandwebsite/package.json(owner, 2026-11-17, #264, straight from 10 to 12). From pnpm 11 on its settings are read frompnpm-workspace.yaml, no longer from the fieldpnpmofpackage.jsonor from.npmrc:allowBuilds(esbuildruns its install script,better-sqlite3is listed as not built, since it brings its binaries; an install script that is not listed there fails the install, and so did an existingnode_modulesof pnpm 10 without the line ofbetter-sqlite3),engineStrict, and the overrides of a security hotfix (Branching and release). The Dockerfile copies the file before it installs.website/has no settings. [V] pnpm’s defaultminimumReleaseAgeof one day stays as it is: tested with pnpm 12.21.0, it does not refuse a version that a lockfile or an override pins exactly, so a security update still installs at once.