A local-first RAG document chatbot. Upload PDFs or add a website URL, index them into a vector database, and ask questions grounded in that content — with citations. Built with Next.js, TypeScript, LangChain.js, Pinecone, Groq, and Ollama.
See tasks/prd-rag-document-chatbot.md for the full product spec and tasks/tasks-rag-document-chatbot.md for the implementation task list.
This app depends on two local services in addition to npm run dev:
Install Ollama, then pull the models referenced in .env.local:
# install: https://ollama.com/download
ollama pull nomic-embed-text # embedding model (must match OLLAMA_EMBEDDING_MODEL)
ollama pull llama3.2:3b # chat model (must match OLLAMA_CHAT_MODEL). llama3.2:1b also
# runs but is too small to reliably follow the grounding prompt.
ollama serve # usually already running as a background serviceConfirm it's reachable:
curl http://localhost:11434/api/tagsdocker compose up -dThis runs the Pinecone Local emulator on http://localhost:5080 (see docker-compose.yml). It does not require a real Pinecone account or API key, and data does not persist across restarts — that's expected for local dev.
Copy .env.local.example to .env.local and fill in GROQ_API_KEY if you plan to use Groq. Everything else has a working local default. See src/lib/config/env.ts for validation.
cp .env.local.example .env.localWith Ollama and Pinecone Local running:
npm install
npm run devOpen http://localhost:3000.
src/
├── app/ # Next.js App Router pages + API route handlers
├── components/ # React components (layout, sources, chat, developer)
├── hooks/ # Client-side state hooks
├── lib/
│ ├── ai/ # Chat + embedding model provider factories
│ ├── config/ # Env loading, centralized RAG constants
│ ├── db/ # SQLite schema + queries (app metadata)
│ ├── rag/ # Loaders, splitter, vector store, ingest, retrieve, answer
│ ├── storage/ # Local file storage for uploaded PDFs
│ └── validation/ # Zod schemas for API requests
└── types/ # Shared TypeScript types
data/
├── ragdock.sqlite # App metadata (git-ignored)
└── uploads/ # Uploaded PDF files (git-ignored)