Repository Guidelines
Project Structure & Module Organization
app/holds the Next.js App Router pages, layouts, and route handlers.components/contains reusable UI components (PascalCase files likeAchievementBadge.tsx).context/,hooks/,lib/, andutils/store shared state, hooks, service clients, and helpers.schemas/andtypes/define Zod schemas and TypeScript types.messages/andi18n/manage localization content and helpers.__tests__/contains unit, integration, and e2e suites (see subfolders like__tests__/e2e).public/stores static assets;scripts/contains one-off maintenance tools.
Build, Test, and Development Commands
pnpm dev: start the Next.js dev server onhttp://localhost:3000.pnpm build/pnpm start: build and run the production server.pnpm lint: run ESLint across the repo.pnpm format: format with Prettier using repo settings.pnpm test: run Vitest in CI mode.pnpm exec playwright test: run Playwright e2e tests (usesplaywright.config.ts).pnpm emulator: start Firebase emulators with persisted data; seeemulator:*scripts for cleanup.
Coding Style & Naming Conventions
- TypeScript + ESM; keep files in
.ts/.tsx. - Prettier rules: 2-space indentation, single quotes, semicolons, 80-char lines.
- Components use
PascalCase.tsx; hooks useuseThing.ts; helpers usecamelCase. - CSS Modules use
*.module.cssalongside components where needed. - When extracting logic into functions, move them into an existing helper module (or a new helper file) and add unit tests.
- Prefer simple
ifstatements with early returns for error handling and message extraction. Avoid nested ternaries, especially patterns likeerror instanceof Error ? ... : ....
Testing Guidelines
- Unit/integration tests live in
__tests__/unitand__tests__/integrationand use Vitest. - E2E tests live in
__tests__/e2eand run with Playwright. - Name tests
*.test.ts/*.test.tsxand keep fixtures/mocks in__tests__/fixtures/__tests__/mocks.
Commit & Pull Request Guidelines
- Follow Conventional Commits as seen in history:
feat:,fix:,refactor:,test:(optional scope). - PRs should include a clear description, testing notes (commands + results), and linked issues.
- For UI changes, add screenshots or short clips; for config changes, call out env vars touched.
Configuration & Security Notes
- Store secrets in
.env.localand keep them out of commits. - Firebase configuration lives in
firebase.json,firestore.rules, andstorage.rules; prefer emulators for local work.