Skip to content

10. Layout and registration

  • [E] Core in layers, entries as feature folders:
src/core/ economy, settle, battle, flight, components/
src/features/<key>/ entry.ts, texts.de.ts, *.server.ts, *.test.ts
src/features/missions/<m>/ rules.ts, texts.de.ts, arrive.server.ts, *.test.ts
src/features/index.gen.ts generated index, not checked in
src/features/index.server.gen.ts generated server index (#116), not checked in
src/server/ http, db/repos, game (commands)
src/client/ state, components (generic), views
  • [E] The core folder is src/core: #112 renames src/shared to src/core in one pull request that changes every import (owner, 2026-11-13).
  • [E] The index of all features is generated by a script and not checked in (.gitignore). The script runs before start, test, typecheck, build and in the Dockerfile, chained explicitly in the scripts of package.json (node scripts/gen-features.ts && …), not as pre* scripts or tool hooks (owner, 2026-11-13, #112). Reason: the server runs without a bundler (node src/server/main.ts), so there is no glob import, and a checked-in generated file still collides between parallel pull requests.
  • [E] Built with #112: the folders src/features/ and src/features/missions/ exist (.gitkeep); no entry has moved yet. Since #114 every catalog entry has its folder with entry.ts, since #113 also with texts.de.ts. scripts/gen-features.ts writes src/features/index.gen.ts with ENTRIES (each <key>/entry.ts), since #113 TEXTS (each <key>/texts.de.ts), and MISSIONS (each missions/<m>/rules.ts) as lists of [key, module] pairs sorted by key. A list, not an object, because knip counts a module passed on as a whole as used. A folder without its file, or whose name is not a key, stops the script. The *.server.ts parts are not in this index, because the browser uses it too; their registry comes with the first server part (#116). The script writes only when the index changed, through a temporary file and a rename.
  • [E] Built with #112, where the index is written first: the scripts start, cli, build, typecheck, test, test:watch, test:coverage, test:mutation, lint:dead, lint:deps and check; the two E2E server starts (playwright.config.ts); the Dockerfile through pnpm build, and the image copies src/features; the CI jobs through these scripts (the nightly upgrade test runs pnpm test <file>).
  • [E] Built with #112: Vitest coverage and the Stryker mutate globs measure src/features and leave the generated index out; knip takes the index as an entry; jscpd skips it through .gitignore; Vite needs no setting, it follows the imports. The changelog check counts src/features as game code.
  • [V] If the generated index turns out to be a burden, the fallback is a hand-kept index, sorted, one line per entry.
  • [E] Decided for #116 (owner, 2026-11-14): gen-features also writes src/features/index.server.gen.ts with MISSION_SERVERS, not checked in (.gitignore) like index.gen.ts; each mission folder needs its arrive.server.ts; only src/server imports the server index. The type Mission is derived from the generated index as a type only, as long as no-circular allows it.
  • [E] Built with #116: a mission folder needs rules.ts, texts.de.ts and arrive.server.ts, else the script stops; index.gen.ts adds MISSION_TEXTS beside MISSIONS; generateServer writes index.server.gen.ts (MISSION_SERVERS, each missions/<m>/ arrive.server.ts), which the script writes with the other index; knip takes it as an entry, Vitest coverage and Stryker leave it out, the Dockerfile copies it with src/features. Mission in src/core/types.ts is (typeof MISSIONS)[number][0] through import type: the cycles it closes (types.ts → index → rules.ts → missions.ts) all run through a type-only import, which no-circular does not count, so the rule passes unchanged.
  • [V] Built with #285 (Lexicanum): an entry folder and a mission folder hold a lexicon.de.ts, what the entry or mission adds to its article (the guards ask for keywords in every one, owner, 2026-11-17). gen-features lists these files in a third index, src/features/lexicon.gen.ts (LEXICON and MISSION_LEXICON, not checked in), which only src/core/lexicon/ imports (rule lexicon-index-in-lexicon), so the parts load with the chunk of the Lexicanum and not with the start bundle (#242). Knip takes it as an entry, Vitest coverage and Stryker leave it out; Stryker leaves the lexicon.de.ts files out like the text files (see Lexicanum).