Files
2026-04-18 19:34:19 +08:00

28 lines
2.7 KiB
Markdown

# Repository Guidelines
## Project Structure & Module Organization
This repository is a Next.js 15 app using the App Router and TypeScript. Route entry points live in `src/app`, with localized pages under `src/app/[locale]` and API handlers under `src/app/api`. Reusable UI belongs in `src/components`, shared hooks in `src/hooks`, and server/client utilities in `src/lib`. Internationalization files live in `src/messages` and `src/i18n`. Database schema, migrations, and seed data are in `prisma/`. End-to-end tests should live in `e2e/`; unit-style tests currently sit beside source files in `src/`.
## Build, Test, and Development Commands
Use `pnpm`, not `npm`.
- `pnpm dev`: start the local Next.js dev server.
- `pnpm build`: create a production build and catch type/runtime integration issues.
- `pnpm start`: serve the production build locally.
- `pnpm lint`: run Next.js ESLint rules.
- `pnpm test`: run Vitest for `src/**/*.test.ts`.
- `pnpm test:e2e`: run Playwright against a local app instance on port `3100` by default.
- `pnpm prisma db seed`: seed the database from `prisma/seed.ts`.
## Coding Style & Naming Conventions
Prettier is authoritative: 2-space indentation, semicolons, double quotes, trailing commas (`es5`), and `printWidth: 100`. ESLint extends `next/core-web-vitals`; `console.warn` and `console.error` are allowed, other `console` calls trigger warnings. Use strict TypeScript and prefer the `@/*` import alias over deep relative paths. Name React components in `PascalCase`, hooks as `useX`, and tests as `*.test.ts`. Keep route files in Next.js conventions such as `page.tsx`, `layout.tsx`, and `route.ts`.
## Testing Guidelines
Write fast logic tests with Vitest next to the code they exercise, for example `src/lib/validations.test.ts`. Use Playwright for cross-page or API-driven flows under `e2e/`. Add tests for new behavior and for bug fixes, especially around API routes, validation, Prisma-backed queries, and localized routing. Run `pnpm test` and `pnpm lint` before opening a PR; add `pnpm test:e2e` for UI or routing changes.
## Commit & Pull Request Guidelines
Recent history uses Conventional Commit prefixes such as `feat:`, `fix:`, `refactor:`, and `chore:`; keep that format and use concise summaries. PRs should describe the user-visible change, note schema or env updates, link the issue when available, and include screenshots for UI work. If a migration is added, mention the migration directory name and any seed or deployment steps reviewers must run.
## Security & Configuration Tips
Copy from `.env.example` and keep real secrets only in `.env.local` or deployment settings. Never commit production credentials, webhook keys, or database URLs. Validate Prisma schema changes with migrations, not manual database edits.