- Monorepo managed by pnpm; main Next.js App Router app under
apps/x-reason-web/src/app. - UI building blocks in
apps/x-reason-web/src/app/components; reusable variants live incomponents/ui. - Higher-level templates in
apps/x-reason-web/src/app/templates; server logic distributed acrossactions,api, andlib. - Shared utilities sit in
apps/x-reason-web/src/app/utils; React context undercontext; static assets inapps/x-reason-web/public/. - Jest specs reside in
apps/x-reason-web/src/app/test; config inapps/x-reason-web/jest.config.js.
- Unified Provider Layer: All AI interactions go through Vercel AI SDK (
ai,@ai-sdk/openai,@ai-sdk/google) - Centralized Configuration: Provider setup in
apps/x-reason-web/src/app/api/ai/providers.ts - Server-Side Only: API keys managed via environment variables (
.env.local), never exposed to client - Supported Providers:
- OpenAI: o4-mini, o3-mini, gpt-4.1-mini, gpt-4.1-nano
- Google Gemini: gemini-2.0-flash, gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.5-pro
- API Routes: Unified
/api/ai/chatendpoint replaces legacy/api/openai/and/api/gemini/paths
pnpm dev: launch local Next.js dev server athttp://localhost:3000.pnpm build: compile production bundle vianext build.pnpm start: run optimized build in production mode.pnpm lint [-- --fix]: execute ESLint (Next.js config) and optionally auto-fix.pnpm test: run Jest suite; setCI=trueto surface snapshot and coverage regressions.
- TypeScript/React with 2-space indentation and named exports for shared modules.
- Favor functional components, Tailwind utility classes, shadcn/ui + Radix primitives.
- Component filenames use lowercase-hyphen (
button-group.tsx); helpers use camelCase. - Maintain Tailwind Merge class ordering; keep global styles in
globals.css.
- Use Jest with Testing Library (
ts-jest); place tests alongside mirrored names inapps/x-reason-web/src/app/testusing*.test.ts. - Cover new logic in
actionsorlib; expand edge-case assertions over broad snapshots. - Default timeout is 120s for AI-related tests—respect this when writing async specs.
- AI Provider Testing: Mock Vercel AI SDK functions (
streamText,generateText) instead of provider-specific SDKs - Mock Data: Use mock responses for deterministic testing; avoid live API calls in unit tests
- Write concise, imperative commit subjects (e.g.,
feat: add reasoning demo toggles). - PR descriptions should explain user-facing impact, list tests run, and link issues.
- Include screenshots or clips when UI shifts; note intentional skips for lint/test.
- Prefer
rgfor searches andfdfor file discovery; avoid slowergrep/find. - Rely on workspace scripts from repo root; refrain from mutating directories outside allowed roots without approval.