All docs

Database

The template uses Prisma 7 with PostgreSQL and the pgvector extension (for RAG embeddings). The Prisma client connects through a driver adapter (@prisma/adapter-pg).

Schema

The schema is split by domain in — Prisma merges every file:

FileModels
schema.prismagenerator + datasource (pgvector extension)
auth.prismaUser, Session, Account, Verification
billing.prismaSubscription
credits.prismaCreditBalance, CreditTransaction
chat.prismaConversation, Message
rag.prismaDocument, DocumentChunk (vector column)

Local database

The db service in ships pgvector/pgvector:pg16, so the extension is available out of the box.

bash
docker compose up -d db     # startdocker compose stop db      # stop (keeps data)docker compose down -v      # remove everything, including the volume

Commands

CommandWhat it does
npm run db:migrateCreate & apply a migration in development
npm run db:deployApply existing migrations (production / CI)
npm run db:seedSeed the demo account
npm run db:studioOpen Prisma Studio (visual browser)
npm run db:resetDrop, re-migrate and re-seed
npm run db:generateRegenerate the Prisma client

Seed

creates a demo account (demo@nova.dev) with a subscription, credits, a conversation and an indexed document — so a fresh clone shows a working product immediately. It is idempotent.

pgvector & RAG

DocumentChunk.embedding is a vector(1536) column. Prisma has no native vector type, so it is declared Unsupported(...) and read/written via raw SQL in the RAG service. An HNSW index (cosine distance) is created in the migration for fast similarity search. The dimension matches OpenAI text-embedding-3-small; change it in the schema and the embedding config if you switch models.