Repo Context
- Vercel AI SDK for AI framework and frontend-backend interactions
- Next.js with app directory
- ORM is Drizzle with the schema at
lib/db/schema.ts - DB queries and mutations are at
lib/db/queries.ts - To test your changes through compilation. Don't run a build. But do
bun test:types - This repo uses Tailwind 4.
- Shadcn UI is used for the UI components and the components are in
components/uifolder. The config is incomponents.json.
App structure
- People interact with the AI through the
app/(chat)/api/chat/route.tsby sending a message. It responds by creating a new message.
Database Migrations
- To perform database migrations follow Drizzle conventions. First make the desired changes to the schema in
lib/db/schema.ts. Then runbun db:generateto generate the migration file. Then runbun db:migrateto apply the migration to the database.
Environment Variables
- All env vars are managed in
lib/env.tsusing@t3-oss/env-nextjs - Add new vars to the
serverobject with zod schema - Use
env.VAR_NAMEinstead ofprocess.env.VAR_NAME - Feature flags live in
lib/config.ts(integrations, authentication) - When a feature is enabled in config, its required env vars must be validated in
scripts/check-env.ts - Pattern: check
siteConfig.feature && !env.REQUIRED_VARthen push to errors array
Browser Testing
- To test authenticated features in the browser, navigate to
/api/dev-loginfirst - This creates a dev session and redirects to
/with valid auth cookies - Only works in development (
NODE_ENV=development)
