Home/ Projects/ Chat with PDF

Chat with PDF

Chat with PDF is an AI-powered document Q&A application that lets users upload PDFs and hold grounded conversations with their content via a full RAG pipeline — semantic chunking, vector embeddings, similarity search, and streaming LLM responses with in-line source citations. Built with Next.js, FastAPI, PostgreSQL with pgvector, LangChain, and the Claude API.

Overview

Chat with PDF lets users upload any PDF and have a real conversation with its contents. Ask a question, get a reasoned answer with citations pointing to the exact pages they were drawn from. Behind the scenes, the document is extracted, chunked, embedded into a vector database, and queried using semantic similarity search — the RAG pattern that powers production-grade AI assistants at companies like Perplexity, Notion AI, and ChatGPT's "chat with your files" feature.

What it does

  • Upload any PDF — the system extracts text page by page, splits it into overlapping chunks, and generates embeddings for semantic search
  • Auto-generated summary — appears the moment ingestion completes, produced by Claude Haiku 4.5 in parallel with the embedding work
  • Ask questions in plain language — every answer streams in token-by-token from Claude Sonnet 4.5
  • Inline citations — appear as small page-number badges next to the claims they support; click any badge to see the exact source excerpt with its page number
  • Markdown transcript export — download the entire conversation, including the summary and all source excerpts, as a portable .md file

Tech Stack

  • Framework — Next.js 16 (App Router) + TypeScript
  • Styling — Tailwind CSS + shadcn/ui
  • Database — Postgres (Neon) with pgvector extension
  • Embeddings — OpenAI `text-embedding-3-small`
  • Generation — Anthropic Claude Sonnet 4.5 (chat) + Haiku 4.5 (summary)
  • PDF parsing — unpdf (Mozilla pdf.js)
  • Rate limiting — Upstash Redis sliding window
  • Deployment — Vercel

Where it goes next

Next, I would like to create a multi-document Q&A feature, allowing collaboration between documents. Persistent conversations will be stored in Postgres so that users can return to the chats and use them in the future.

Want to see the code?

The repository is on GitHub — issues and PRs welcome.

View Code on GitHub

Want to see the live demo?

The live demo is hosted on Vercel

View Live Demo