Have you ever wanted to just talk to a PDF instead of reading through 50 pages?
I built a full PDF Chat API in one day — upload any PDF, ask questions in natural language, and get AI-powered answers. Here's how I did it.
What it does
- Upload any PDF document
- Ask questions about its content in natural language
- Get accurate answers powered by RAG (Retrieval Augmented Generation)
- Clean web UI included — no frontend framework needed
- REST API with authentication for easy integration
Tech Stack
- FastAPI — REST API backend
-
Google Gemini — embeddings (
gemini-embedding-001) + chat (gemini-2.5-flash) - Qdrant — vector database for semantic search
- LangChain — RAG pipeline orchestration
- Pure HTML/CSS — no React, no framework
How it works
The architecture is classic RAG in two phases:
Ingestion (upload):
- Extract text from PDF
- Split into chunks (1000 chars, 200 overlap)
- Generate embeddings with Gemini
- Store in Qdrant
Query (chat):
- Embed the user's question
- Search Qdrant for the 4 most relevant chunks
- Send chunks + question to Gemini
- Return the answer
The code
The core is surprisingly simple:
chain = (
{"context": vector_store.as_retriever(search_kwargs={"k": 4}),
"question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
That's the entire RAG chain — retrieve relevant context, inject into prompt, generate answer.
What I learned
- Gemini embeddings produce 3072-dimensional vectors (not 768 like older models)
-
grpcioon Windows can be a pain — pin to version 1.62.2 - Qdrant Cloud free tier is genuinely useful for side projects
- Building a clean UI in pure HTML/CSS takes less time than setting up React
Try it yourself
get the packaged version ready to deploy:
👉 https://elyassdigital.gumroad.com/l/zcgjmmz
What's next
- Multi-user support with separate collections per user
- Docker deployment guide
- Support for other document types (Word, Excel)
Built this as a side project — happy to answer questions in the comments!
Top comments (0)