A NotebookLM-style app: upload documents, chat with grounded RAG answers, and generate studio artifacts (summaries, mind maps, quizzes, flashcards, and reports).
- Next.js 16 (App Router), React 19, TypeScript
- Tailwind CSS 4 + shadcn/ui
- Supabase (
nlmschema, Auth, Storage, pgvector, Realtime) - OpenRouter + Vercel AI SDK — chat streaming and embeddings
- LangGraph agent orchestration — ingest, discovery, studio generation
- Vercel Workflow — durable async studio artifact pipeline
Copy .env.example to .env.local and fill in values:
| Variable | Required | Purpose |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL |
Yes | Supabase project URL |
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY |
Yes | Supabase anon/publishable key |
NEXT_PUBLIC_SITE_URL |
Production | OAuth redirect base (e.g. https://your-app.vercel.app) |
SUPABASE_SECRET_KEY |
Studio / workflow | Service role key for workflow DB writes |
OPENROUTER_API_KEY |
Chat, ingest, studio | LLM and embedding API |
TAVILY_API_KEY |
Discovery | Web source discovery in chat and sources panel |
OPENROUTER_*_MODEL |
Optional | Override default models (see .env.example) |
Without Supabase env vars, the home page and auth routes show a Database not connected card instead of crashing.
pnpm install
cp .env.example .env.local
pnpm devOpen http://localhost:3000.
Apply SQL migrations to your Supabase project (SQL editor or CLI):
supabase/migrations/20250617180000_create_nlm_schema.sql—nlmschema, RLS, pgvector, storagesupabase/migrations/20250617200000_enable_artifacts_realtime.sql— Realtime onnlm.artifacts
Enable Google OAuth in Supabase Auth if using Continue with Google. Set Site URL and redirect URLs:
http://localhost:3000/auth/callbackhttps://<your-vercel-domain>/auth/callback
- Create, rename, and delete notebooks from
/notebooks - Each notebook has dedicated routes:
/sources,/chat,/studio - Empty states when no notebooks, documents, threads, or artifacts exist
- Email/password sign-up and login
- Google OAuth via Continue with Google on
/loginand/signup
- Upload
.txt,.md,.pdf, or.docx(max 20 MB) - Paste a public URL or Discover sources via Tavily
- Background ingest: parse → chunk → embed → auto-summary
- Grounded RAG chat with streaming responses
- Inline citations like
[source: documentName#chunkIndex] - Thread sidebar with persisted history
- Ask
find sources about …to run Tavily discovery from chat
- Generate summary, mind map, quiz, flashcards, and report artifacts
- Vercel Workflow pipeline with step-split durable invocations
- POST
/api/studio/generatereturns immediately; progress via Realtime + polling fallback - Delete artifacts from the Studio history list
- Inspect runs locally:
npx workflow inspect runsornpx workflow web
| Command | Description |
|---|---|
pnpm dev |
Start dev server |
pnpm build |
Production build |
pnpm typecheck |
TypeScript check |
pnpm lint |
ESLint |
- Import this repo in Vercel
- Add all environment variables from the table above (including
SUPABASE_SECRET_KEYfor Studio) - Set
NEXT_PUBLIC_SITE_URLto your production URL - Deploy — CI runs
typecheck,lint, andbuildon push/PR tomain - Production shows a Connected to Vercel badge when
VERCEL=1
Use this walkthrough to verify the full app end-to-end:
- Sign up at
/signup(email or Google) - Create a notebook on
/notebooks— e.g. "Research notes" - Sources — upload a PDF or paste a URL; wait for ingest to finish (status: ready)
- Chat — ask a question about your sources; confirm citations appear
- Discovery — ask
find sources about <topic>and confirm new links can be added - Studio — generate a Summary and a Mind map; watch Realtime status badges update
- Expand mind map — open the overlay, zoom and pan the diagram
- Delete artifact — remove a completed artifact from Studio history
- Rename notebook — pencil icon on the dashboard
- Delete notebook — trash icon; confirm cascade removes sources, chat, and artifacts
See CHAT-THREAD_DUMP.md for the AI-assisted build transcript (user prompts and agent responses).