Monorepo Layout
The repository is structured as a parent repository containing three Git submodules:allcodex-core/: Headless backend (Express 5, SQLite, pnpm monorepo).allknower/: AI orchestrator (Elysia, Bun, Prisma/Postgres, LanceDB).allcodex-portal/: Next.js App Router frontend (React 19, Bun, Tailwind 4, shadcn/ui).docs/shared/: Markdown documentation (git submoduleThunderRonin/allcodex-docs).
Coding Conventions & Tech Stack
1. AllCodex Core
- Runtime: Node.js v22 (strict - Node 26 breaks SQLite bindings).
- Package Manager:
pnpm. - Conventions:
- TypeScript strict mode, target ES2022.
- Sibling modules must be imported with
.jsextensions (NodeNext resolution). - 4-space indentation, double quotes, semicolons, no trailing commas.
- ESLint flat configuration.
- Testing:
- Vitest for unit tests, Playwright for E2E.
- Run tests sequentially since they share database states:
pnpm test:sequential.
2. AllKnower
- Runtime: Bun.
- Conventions:
- Bun ESM modules (
"type": "module"). - TypeScript strict mode, bundler resolution.
- Imports must use
.tsextensions. - Elysia
tschemas at HTTP boundaries; Zod for internal validation.
- Bun ESM modules (
- Testing:
- Run unit and integration tests using Bun’s test runner:
bun test. - Use
mock.module()for third-party service mock isolation.
- Run unit and integration tests using Bun’s test runner:
3. AllCodex Portal
- Framework: Next.js 16 (App Router) + React 19 with React Compiler enabled.
- State Management: Zustand for dedicated global client stores (
useBrainDumpStore), TanStack Query for server state. - Styling: Tailwind CSS 4 with shadcn/ui.
- HTML Sanitization: All note body HTML must be sanitized using DOMPurify (
lib/sanitize.ts) viasanitizeLoreHtml()for GM details orsanitizePlayerView()for player-safe outputs before being rendered to the browser. - Testing:
- Vitest for unit testing.
- Playwright for integration testing.
Submodule Workflow
Each service is a Git submodule pointing to a separate GitHub repository. Always follow this workflow when committing changes:- Commit Submodule Changes First: Change directories into the submodule, stage files, and commit/push your changes.
- Update Parent Pointer: Change directory back to the monorepo root, stage the submodule directory pointer, and commit the update.