app/: Next.js App Router entrypoints and routes.app/(chat)/: chat UI pages plus API routes (api/chat,api/history,api/files/upload, etc.).app/(auth)/: Auth.js login/register flows and auth route handlers.components/: feature components;components/ui/contains shared UI primitives.lib/: core logic (lib/ai,lib/db,lib/dashboard,lib/editor, utilities).artifacts/: artifact server/client implementations (text,code,image,sheet).tests/: Playwright E2E (tests/e2e), fixtures/helpers, and prompt utilities.public/images/: static assets.
pnpm install: install dependencies.pnpm dev: start local dev server (next dev --turbo).pnpm build: run DB migration then build production app.pnpm start: run production server locally.pnpm lint: run Ultracite checks.pnpm format: apply Ultracite fixes.pnpm db:migrate: apply Drizzle migrations.pnpm db:generate/pnpm db:studio: generate migrations / inspect DB.pnpm test: run Playwright test suite.- Example single spec:
pnpm exec playwright test tests/e2e/chat.test.ts.
- Language: TypeScript + React function components.
- Formatting/linting: Ultracite (
pnpm lint,pnpm format) is the source of truth. - Use 2-space indentation and keep files in ASCII unless required.
- Naming patterns:
- Component files: kebab-case (for example
chat-header.tsx). - Component exports: PascalCase (
ChatHeader). - Hooks:
useXnaming inhooks/(use-chat-visibility.ts). - Prefer
@/imports over deep relative paths.
- Framework: Playwright (
@playwright/test). - Place end-to-end tests in
tests/e2e/*.test.ts. - Keep test names behavior-focused (for example:
"redirects to /chat/:id after sending message"). - Update/add tests for changes to chat flow, model selection, auth, uploads, or API behavior.
- Follow existing history style: conventional prefixes like
feat:andfix:. - Use imperative, concise subjects (optionally with scope, e.g.,
feat(chat): add workflow runner). - PRs should include:
- What changed and why.
- Linked issue/task.
- Test evidence (commands run and results).
- Screenshots/GIFs for UI changes.
- Migration/env updates when schema or config changes.
- Never commit secrets; keep local values in
.env.local. - Start from
.env.exampleand document any new variables in PRs. - Avoid hard-coded external endpoints or API keys in source code.