Skip to content

Repository files navigation

NotebookLM Clone

A NotebookLM-style app: upload documents, chat with grounded RAG answers, and generate studio artifacts (summaries, mind maps, quizzes, flashcards, and reports).

Stack

  • Next.js 16 (App Router), React 19, TypeScript
  • Tailwind CSS 4 + shadcn/ui
  • Supabase (nlm schema, 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

Environment variables

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.

Local development

pnpm install
cp .env.example .env.local
pnpm dev

Open http://localhost:3000.

Supabase migrations

Apply SQL migrations to your Supabase project (SQL editor or CLI):

  1. supabase/migrations/20250617180000_create_nlm_schema.sqlnlm schema, RLS, pgvector, storage
  2. supabase/migrations/20250617200000_enable_artifacts_realtime.sql — Realtime on nlm.artifacts

Enable Google OAuth in Supabase Auth if using Continue with Google. Set Site URL and redirect URLs:

  • http://localhost:3000/auth/callback
  • https://<your-vercel-domain>/auth/callback

Features

Notebooks (dashboard)

  • 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

Auth

  • Email/password sign-up and login
  • Google OAuth via Continue with Google on /login and /signup

Documents

  • 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

Chat

  • 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

Studio

  • Generate summary, mind map, quiz, flashcards, and report artifacts
  • Vercel Workflow pipeline with step-split durable invocations
  • POST /api/studio/generate returns immediately; progress via Realtime + polling fallback
  • Delete artifacts from the Studio history list
  • Inspect runs locally: npx workflow inspect runs or npx workflow web

Scripts

Command Description
pnpm dev Start dev server
pnpm build Production build
pnpm typecheck TypeScript check
pnpm lint ESLint

Deployment (Vercel)

  1. Import this repo in Vercel
  2. Add all environment variables from the table above (including SUPABASE_SECRET_KEY for Studio)
  3. Set NEXT_PUBLIC_SITE_URL to your production URL
  4. Deploy — CI runs typecheck, lint, and build on push/PR to main
  5. Production shows a Connected to Vercel badge when VERCEL=1

Demo script

Use this walkthrough to verify the full app end-to-end:

  1. Sign up at /signup (email or Google)
  2. Create a notebook on /notebooks — e.g. "Research notes"
  3. Sources — upload a PDF or paste a URL; wait for ingest to finish (status: ready)
  4. Chat — ask a question about your sources; confirm citations appear
  5. Discovery — ask find sources about <topic> and confirm new links can be added
  6. Studio — generate a Summary and a Mind map; watch Realtime status badges update
  7. Expand mind map — open the overlay, zoom and pan the diagram
  8. Delete artifact — remove a completed artifact from Studio history
  9. Rename notebook — pencil icon on the dashboard
  10. Delete notebook — trash icon; confirm cascade removes sources, chat, and artifacts

Build process

See CHAT-THREAD_DUMP.md for the AI-assisted build transcript (user prompts and agent responses).

Product requirements

See PRODUCT-REQUIREMENTS-DOCUMENT.md.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages