Architecture (Contributing)
Companion to the user-facing Architecture page. This page focuses on the rules contributors must follow to keep the codebase healthy.
The dependency direction rule
view · store · router · forms · … → reactive → corecoremust not import from any other module insrc/.reactivemust not import from any module higher than itself.- Higher modules may import from
reactive,core, and explicitly approved sibling modules.
If a change appears to require an upward import, the design is wrong. Restructure the change so the data flows in the legal direction, or open an issue to discuss the layering exception.
Module addition checklist
Adding a new public module is a non-trivial change. The full checklist (also enforced by check:full-bundle):
- Create
src/<module>/index.tswith explicit named exports. - Add the entry to
package.jsonexports. - Add Vite build entries (
vite.config.tsandvite.umd.config.ts). - Re-export the most commonly used names from
src/index.ts. - Re-export every public runtime + type from
src/full.ts. - Add tests under
tests/<module>*.test.ts. - Add a module guide at
docs/guide/<module>.mdand add it to the sidebar indocs/.vitepress/config.ts. - Add the module to the AI guidance surfaces:
AGENT.md,llms.txt,.cursorrules,.clinerules,README.md. - Add release notes — either a new section in the in-progress release or
docs/release-notes/<version>.md. - Verify:
bun run lint,bun run build,bun test,bun run check:full-bundle,bun run check:ai-guidance.
Public API change checklist
For a change to an existing public API:
- Update the module barrel (
src/<module>/index.ts). - Update tests — both happy path and edge cases.
- Update
docs/guide/<module>.md. - Update
src/full.tsif a new symbol or type was added. - Update the relevant version section in
CHANGELOG.md. - Run
bun run lint,bun test,bun run check:full-bundle.
Coding conventions
- Strict TypeScript — no weakening type safety, no unjustified
any, no@ts-ignorewithout an explicit explanation. - Naming — file names
kebab-case, classesPascalCase, functions and variablescamelCase. - Exports — named exports only.
- Chaining — mutating DOM wrappers return
this. - JSDoc — public APIs have JSDoc with
@examplewhere helpful; non-public helpers are marked@internal. - English — code, comments, docs, and commit messages are in English.
Security discipline
See Security Model for the user-facing summary. Contributor rules:
- HTML-writing APIs must sanitize untrusted input.
- Do not introduce new uses of
evalornew Function()outside the documentedviewandconcurrencyexceptions. - Cookie / header inputs must be validated against header-safe characters before being emitted.
- Form serialisation helpers throw on invalid IDs (
[A-Za-z0-9_-]+) — do not silently normalise.
Bundle discipline
- Zero runtime dependencies. Period.
- Add
/* @__PURE__ */on call expressions whose results may not be retained, when it materially helps tree-shaking. - Avoid module-scope side effects.
- New dependencies > ~5 KB gzipped require explicit approval.