Knowledge vault built with Next.js 15 App Router, NextAuth v5, Prisma, PostgreSQL + pgvector, Groq (Llama 3.3), and Gemini embeddings.
Entirely free AI tier — Groq free tier + Gemini free tier = zero cost.
# 1. Install
npm install
# 2. Configure
cp .env.example .env
# Edit .env — add NEXTAUTH_SECRET, GROQ_API_KEY, GEMINI_API_KEY
# 3. Start Postgres + pgAdmin
docker compose up postgres pgadmin -d
# 4. Run migrations
npx prisma migrate dev --name init
# 5. Start dev server
npm run devApp → http://localhost:3000
pgAdmin → http://localhost:5050
docker compose up -d| Service | Get key | Cost |
|---|---|---|
| Groq (chat) | console.groq.com | Free tier: 14,400 req/day |
| Gemini (embeddings) | aistudio.google.com | Free: 1M tokens/month |
| Google OAuth | console.cloud.google.com | Free |
| Layer | Tech |
|---|---|
| Framework | Next.js 15 App Router |
| Auth | NextAuth v5 (JWT strategy, Google OAuth + credentials) |
| Database | PostgreSQL 16 + pgvector |
| ORM | Prisma |
| AI Chat | Groq SDK (llama-3.3-70b-versatile) |
| Embeddings | Google Gemini (text-embedding-004, 768 dims) |
| State | Redux Toolkit |
| UI | Tailwind CSS |
| Deploy | Docker Compose |
NextAuth v5 uses JWT session strategy — no database sessions table needed.
- Credentials: Register via
/api/auth/register→ sign in via NextAuthcredentialsprovider - Google OAuth: Single button, handled entirely by NextAuth → auto-creates user on first login
- Session: JWT stored in cookie (HTTP-only), 30-day expiry
- Server auth:
auth()in Server Components and Route Handlers - Client auth:
useSession()fromnext-auth/react
- On save: content is embedded with
text-embedding-004(768 dims) → stored incontents.embeddingas pgvector - On chat: question is embedded → cosine similarity search (
<=>operator) finds top-6 matches - Groq Llama 3.3-70b generates answer using matched content as context
- Embedding runs in
setImmediateso saves are never blocked
| Service | Port |
|---|---|
| Next.js | 3000 |
| PostgreSQL | 5432 |
| pgAdmin | 5050 |