- App Router code lives in
src/app(pages, API routes). Example:src/app/v1/chat/completions/route.ts. - UI components in
src/components(PascalCase.tsx). Shared utilities insrc/lib. Types insrc/types. - Static assets in
public/. Supabase SQL, migrations, and edge functions insupabase/. - Examples and helper scripts in
examples/andscripts/.
npm run dev— Start local dev server onhttp://localhost:8080(Turbopack).npm run build— Production build via Next.js.npm start— Run the production server.npm run lint— Lint with ESLint (next/core-web-vitals, TS). Example:NODE_ENV=production npm run build && npm start.
- Language: TypeScript (strict). Framework: Next.js App Router.
- Indentation: 2 spaces; keep imports sorted and use
@/*path alias fromtsconfig.json. - Components: PascalCase (
src/components/FeatureGrid.tsx). Folders and route segments: kebab/lowercase (src/app/api/usage/route.ts). - Prefer server-first data access in route handlers; keep side effects in
src/libhelpers. - Linting: Fix warnings before merging (
npm run lint). Tailwind v4 via PostCSS.
- No JS unit test runner is configured yet; rely on linting plus manual and API testing.
- For API endpoints, use
curlor the OpenAI client pointed at our base URL. Example:curl -X POST http://localhost:8080/v1/chat/completions -H "Authorization: Bearer edgar_..." -H "Content-Type: application/json" -d '{"model":"gpt-5","messages":[{"role":"user","content":"hi"}]}' - Optional:
examples/openai_python_example.pydemonstrates end‑to‑end usage.
- Commits: Present tense, concise, scoped. Example:
dashboard: add API key managementorapi: enforce billing cycle limits. - PRs: Include a clear description, motivation, and testing notes. Link related issues. Add screenshots/GIFs for UI changes.
- Keep PRs focused and small; update docs when changing behavior or endpoints.
- Required env vars (local/production):
NEXTAUTH_SECRET,GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRET,NEXT_PUBLIC_SUPABASE_URL/SUPABASE_URL,SUPABASE_SERVICE_ROLE, provider keys (OPENAI_API_KEY,ANTHROPIC_API_KEY,GEMINI_API_KEY). - Optional feature flags:
CONSERVATIVE_RATE_LIMIT(defaultfalse). Whentrue, the v1 chat completions API suppresses recent duplicate requests to emulate TPM-style conservative behavior. - Stripe integration lives in
supabase/functions/stripe-webhook*with schema/migrations undersupabase/; seeSTRIPE_INTEGRATION_README.md. - Never commit secrets. Use
.env.localfor development and provider secrets in deployment settings.