The app uses PostgreSQL via Vercel Postgres (powered by Neon). Drizzle ORM manages the schema and migrations.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Wikedhart18/nextjs-ai-chatbot/llms.txt
Use this file to discover all available pages before exploring further.
Setup
Provision a Postgres database
Follow the Vercel Postgres quickstart to create a new database. Vercel will provide a connection string once the database is ready.
Migrations also run automatically as part of the production build (
pnpm build executes tsx lib/db/migrate.ts before next build).Database scripts
| Script | Command | Description |
|---|---|---|
| Migrate | pnpm db:migrate | Apply pending migrations to the database. |
| Generate | pnpm db:generate | Generate a new migration file from schema changes. |
| Push | pnpm db:push | Push schema changes directly without a migration file (useful during prototyping). |
| Studio | pnpm db:studio | Open Drizzle Studio, a browser-based GUI for inspecting and editing data. |
| Pull | pnpm db:pull | Introspect the database and update the local schema. |
| Check | pnpm db:check | Validate migration files for consistency. |
Schema overview
All tables are defined inlib/db/schema.ts. The six tables and their relationships are:
lib/db/schema.ts
Table descriptions
| Table | Description |
|---|---|
User | One row per registered account. Stores the email and a bcrypt-hashed password. |
Chat | One conversation thread per row, linked to its owner. Can be public or private. |
Message | Every message exchanged in a chat, including both user and assistant turns. Content is stored as JSON to support rich message structures. |
Vote | Records whether a user upvoted or downvoted a specific assistant message. Identified by the composite key (chatId, messageId). |
Document | Artifacts generated in the artifact panel: text documents, code files, images, or spreadsheets. |
Suggestion | Inline edit suggestions attached to a document, tracking the original text, the proposed replacement, and whether the suggestion has been resolved. |