src/pages: Next.js Pages Router entry points and API routes insrc/pages/api.src/components: Reusable React UI components.src/services: Business logic and KV/Nchan integrations.src/nchan: Nchan configuration and pub/sub helpers.src/utils: Shared utilities.src/tests: Jest unit/integration tests and test utilities.public: Static assets and standalone HTML pages (for examplepublic/leaderboard.html).
yarn dev: Start Next.js dev server (Turbo).yarn build: Production build.yarn start: Run the built app.yarn lint: Type-check and lint the codebase.yarn lint:smells: Run oxlint and duplication checks.yarn prettify: Formatsrcandpublicfiles.yarn test: Jest suite (src/tests/jest.config.js).
- Language: TypeScript with Next.js pages router.
- Formatting: no semicolons, trailing commas in ES5.
- Always run
yarn prettifywhen work complete. always. - Linting: ESLint plus TypeScript checks via
yarn lint. - Naming: Prefer descriptive component and test names; API route tests use
api.*.test.ts(seesrc/tests). - Portability: Use
globalThisinstead ofwindow,global, orself.
- Frameworks: Jest for unit/integration tests and Playwright for E2E.
- Location: Add tests under
src/testsand colocate fixtures there. - Naming:
*.test.tsor*.test.tsx(for examplesrc/tests/TableService.test.ts). - Always run:
yarn testandyarn lintafter changes. - Cloud-based LLM agents must not run
yarn e2e/Playwright in this repo. E2E startup depends on server-side DB/KV credentials that are not available in hosted agent environments. - For cloud agents, validate changes with
yarn testandyarn lintonly, unless a human explicitly provides credentials and requests E2E.
- KV and Nchan are required for full functionality; local tests may use mocks.
- Static pages in
publicare deployed alongside Next.js pages; update both when touching the lobby/leaderboard flows.