Skip to content

System architecture

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.
Mail 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).

  1. [E] Caddy receives the request from the operator’s proxy, sets the security headers and X-Real-IP, forwards to app:8080.
  2. [V] The server refuses cross-site posts (JSON only, Origin must be NOVA_PUBLIC_URL; a post without Origin is refused too, [E] #328), reads the session cookie, runs the handler.
  3. [E] An action runs in one SQLite transaction: first all fleets that are due (in time order), then the action. All or nothing.
  4. 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).

  • [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.
  • [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 from prebuilds/).
  • [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 packageManager of package.json and website/package.json (owner, 2026-11-17, #264, straight from 10 to 12). From pnpm 11 on its settings are read from pnpm-workspace.yaml, no longer from the field pnpm of package.json or from .npmrc: allowBuilds (esbuild runs its install script, better-sqlite3 is listed as not built, since it brings its binaries; an install script that is not listed there fails the install, and so did an existing node_modules of pnpm 10 without the line of better-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 default minimumReleaseAge of 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.