ai-pdf-chatbot-langchain
AI PDF chatbot agent built with LangChain & LangGraph
A TypeScript starter template for building a chatbot that answers questions about your uploaded PDFs, uses LangGraph, LangChain, and a Supabase vector database to ground AI answers in your documents.
This project is a customizable template for building an AI chatbot that lets users upload PDF documents and then ask questions about them in plain English, with the AI's answers grounded in the contents of those PDFs. The maintainer notes the repository is not actively maintained and is kept as a reference; it also serves as the accompanying example for the book Learning LangChain (O'Reilly).
The way it works follows a common pattern called retrieval-augmented generation. When a user uploads a PDF the backend runs an ingestion graph that parses the document, splits it up and turns each piece into a numeric fingerprint called a vector embedding; those embeddings are stored in a vector database (Supabase in this example) so that text passages can later be looked up by meaning rather than by exact keyword. When the user asks a question, a separate retrieval graph decides whether it needs to pull relevant passages out of the database or answer directly, calls a large language model such as OpenAI's to compose a reply, and streams the response back to the user interface in real time with references to the source passages. LangChain and LangGraph are the orchestration libraries that wire these steps together as a state machine, and LangSmith can optionally be plugged in for tracing and debugging.
Someone would clone this template to bootstrap their own document-Q&A app, learn how a LangGraph-based agent is structured, or follow along with the book. The stack is a TypeScript monorepo managed with Turborepo, with a Next.js and React frontend and a Node.js backend that runs the LangGraph server locally on port 2024. The full README is longer than what was provided here.
Where it fits
- Clone the template to bootstrap a PDF question-answering chatbot for your own documents in a weekend.
- Study the LangGraph retrieval-augmented generation pattern as a reference for building your own document-aware AI app.
- Follow along with the O'Reilly book Learning LangChain using this repo as the working code example.