ARCHITECTURE.ts-server.md — stack architecture template (E6)
The hexagonal server-side TypeScript architecture starter — layer tree, dependency direction, test suffixes and the enforcement map — delivered as the named .ai-factory variant and materialized as .ai-factory/ARCHITECTURE.md on ts-server stacks.
ARCHITECTURE.ts-server.md — stack architecture template (E6)
Status: shipped-beta ·
Ships to: npm-lane, all tier arms; delivered on every npm install, but its content is authoritative for the ts-server stack (react-* presets ship their own ARCHITECTURE variants instead) · Fires at: install time, twice — as the named .ai-factory/ARCHITECTURE.ts-server.md and as the materialized .ai-factory/ARCHITECTURE.md when the stack is (or falls back to) ts-server
What it is
The server-side TypeScript architecture starter: a hexagonal layer tree (domain/ → application/ → infrastructure/ → web/ → config/), the dependency-direction rules between those layers, the test-suffix convention (.unit.ts / .integration.ts / .audit.ts), a forbidden-patterns list, and a table mapping each convention to the channel that enforces it (dependency-cruiser, ESLint rules, audit-ai-docs.sh probes R1–R9). Header declares it consumer-customisable and NOT authoritative for the project goal.
How it works
- Delivery arm 1 — named variant:
setup.d/30-templates.shcopies the template to.ai-factory/ARCHITECTURE.ts-server.mdon every npm install, before the stack branches. - Delivery arm 2 — materialized SoT: AGENTS.md.template points the first agent session at
.ai-factory/ARCHITECTURE.md; the stage materializes that file fromarch_sot_src_for_stackand rewrites its "Drop into …" first line into "This install-generated starter IS your.ai-factory/ARCHITECTURE.md" viarewrite_arch_sot_header(only on a fresh write — a consumer-edited ARCHITECTURE.md is never mutated). - Stack selection: for
react-next/react-spa/react-nativethe materialized SoT comes from the preset's own ARCHITECTURE template; any unknown or empty stack falls back to this ts-server variant (an unknown npm stack is still TypeScript, per the helper's comment). - The
--refreshpath re-runs arm 2 through the same two lib.sh helpers so install and refresh cannot diverge. - Lane honesty: the python lane never sees this file — its stage names the python starter directly instead of consulting the stack map (45-python.sh A2-10), precisely because the ts-server doc would hand a Python repo a Zod/vitest/dependency-cruiser architecture.
Satellites & companions
ADAPTS the "Drop into .ai-factory/ARCHITECTURE.md" seed into the consumer's live architecture SSOT via rewrite_arch_sot_header (lib.sh). Companion of dependency-cruiser config delivery (40-configs.sh ships .dependency-cruiser.cjs) — the doc's layer rules name dependency-cruiser as their enforcer. Peer templates: ARCHITECTURE.react-next.md (preset), ARCHITECTURE.python.md (E36). Its enforcement table points at .ai-factory/RULES.md (E5's sibling render) for the full R1–R11 list. ADDS over a blank ARCHITECTURE.md: a starter whose every rule names a real enforcement channel.
Anchors
At framework pin aa87d0a47a6d8502f983cc9fe7284bd5dcb3d650:
packages/core/templates/shared/ARCHITECTURE.ts-server.md:1— «# Architecture — server-side TypeScript»packages/core/templates/shared/ARCHITECTURE.ts-server.md:3— «> Layer rules and dependency direction. Enforced bydependency-cruiser.»packages/core/templates/shared/ARCHITECTURE.ts-server.md:6— «> Drop into.ai-factory/ARCHITECTURE.mdand override only what your project needs. For React/Next.js projects, seeARCHITECTURE.react-next.md.»packages/core/templates/shared/ARCHITECTURE.ts-server.md:38— «-domain/→ nothing project-internal (only stdlib + Zod)»packages/core/templates/shared/ARCHITECTURE.ts-server.md:94— «See.ai-factory/RULES.mdfor full list R1–R11.»setup.d/30-templates.sh:19— «copy_safe "$PKG_ROOT/packages/core/templates/shared/ARCHITECTURE.ts-server.md" "$PROJECT_ROOT/.ai-factory/ARCHITECTURE.ts-server.md"»setup.d/30-templates.sh:81— «copy_safe "$_arch_sot_src" "$_arch_sot_dst"»setup.d/lib.sh:1347— «*) printf '%s\n' "$PKG_ROOT/packages/core/templates/shared/ARCHITECTURE.ts-server.md" ;;»
.prettierignore — managed block (E3)
The shipped prettier-ignore pattern set covering generated rules docs, framework-authored .ai-factory docs, generated configs and vendored framework source; merged non-destructively into an existing consumer .prettierignore.
CLAUDE.md.template — harness pointer doc (E7)
A pointer-only template telling Claude Code to read AGENTS.md and .ai-factory/ for real context — authored and header-verified in the template tree, but never copied into a consumer project by any install stage.