This file provides guidance to Codex (Codex.ai/code) when working with code in this repository.
This is a TanStack Start application - a full-stack framework for building next-generation React applications with server functions, streaming, and type safety.
# Development
pnpm dev # Start dev server on port 3000
# Build
pnpm build # Build for production
# Testing
pnpm test # Run tests with Vitest
# Database (Drizzle ORM)
pnpm db:generate # Generate migration files from schema
pnpm db:migrate # Run migrations
pnpm db:push # Push schema changes directly to DB
pnpm db:studio # Open Drizzle Studio for database management
# Linting & Formatting
pnpm lint # Run Biome linter
pnpm format # Format code with Biome
pnpm check # Run Biome check (lint + format)File-based routing via TanStack Router. Routes are defined in src/routes/:
src/routes/__root.tsx- Root layout component (appears in all routes via<Outlet />)src/routes/index.tsx- Home page routesrc/routes/api/$.ts- API endpoint for Better Auth (handles all auth requests)
Routes use createFileRoute from @tanstack/react-router. API routes are file-based under src/routes/api/.
Server functions are defined using the server key in route configuration. They execute on the server:
export const Route = createFileRoute('/api/example')({
server: {
handlers: {
GET: () => { /* server code */ }
}
}
})- Schema defined in
src/db/schema.ts - Drizzle client in
src/db/index.ts(connects to PostgreSQL viaDATABASE_URL) - Use
dbexport for queries throughout the app
Better Auth integration:
- Server config:
src/lib/auth.ts- Auth instance with email/password and TanStack Start cookies plugin - Client config:
src/lib/auth-client.ts- React client for authentication hooks
To add authentication to a route, use the auth client from @/lib/auth-client.
- Tailwind CSS (configured via
@tailwindcss/vite) - Shadcn UI components (via
components.jsonconfiguration) - Utility functions in
src/lib/utils.ts(cn helper for class merging)
The project uses @/* alias for ./src/*. This is configured in tsconfig.json and vite.config.ts.
Create a new file in src/routes/ with createFileRoute. TanStack will auto-generate the route tree.
Create a file under src/routes/api/. Use the server.handlers pattern for server functions.
Import and use the db instance from @/db:
import { db } from '@/db'
// Example query
const todos = await db.select().from(todos)