Contexo: Multi-Docs RAG

# I built a RAG chatbot that lets you chat with your own PDFs :page_facing_up::speech_balloon:

Hey everyone! Wanted to share something I’ve been building: a **Contexo: document Q&A chatbot** using Retrieval-Augmented Generation (RAG). You upload a PDF, and instead of scrolling through 40 pages looking for one paragraph, you just ask it questions in plain English — and every answer comes back grounded in the actual document, with page references so you can go verify it yourself.

## How it works

1. **Upload** a PDF — it gets parsed page-by-page, split into overlapping chunks, and embedded into vectors.

2. **Ask** a question in a normal chat interface.

3. The app **retrieves** the most relevant chunks from *that specific document* and feeds them to an LLM as context, so it answers from your content instead of guessing from general training knowledge.

## Stack

- **Next.js 15** (App Router) + TypeScript

- **Clerk** for auth

- **Neon** (serverless Postgres) + **pgvector** for embeddings storage

- **Drizzle ORM**

- **Hugging Face Inference API** for embeddings

- **Groq** (Llama 3.1) for fast generation, via the **Vercel AI SDK**

- **shadcn/ui** + Tailwind for the UI

## A few things I’m proud of

- **Hybrid search** — combining vector similarity with Postgres full-text search (fused with Reciprocal Rank Fusion), since pure embeddings are surprisingly bad at exact matches like figures, names, or acronyms.

- **Page-level citations** — I had to write a custom PDF page extractor (pdf-parse flattens everything into one string by default) so every chunk keeps track of which page it came from, all the way to the answer.

- **Real multi-tenant isolation** — every row, down to individual document chunks, is scoped by user ID, not just checked at the route level. Learned the hard way how easy it is to accidentally leak data across users in a RAG pipeline if you’re not careful about *where* you filter.

- **Drag-and-drop upload**, a proper document dashboard with bulk select + delete, and a chat UI with suggested prompts for empty states.

## Still iterating on — and could use a hand with

- Retrieval quality tuning (chunk size/overlap, embedding model choice)

- Background job for cleaning up soft-deleted documents instead of a synchronous cascade delete

- Word document support (currently PDF-only)

If any of that sounds interesting, I’d genuinely welcome collaborators — whether that’s a PR, an issue with ideas, or just a second pair of eyes on the retrieval logic. Beginner-friendly issues are marked as such in the repo.

:link: **Live demo:** [https://contexto-taupe.vercel.app/\]

:laptop: **GitHub:** [ GitHub - rooneyrulz/rag-chatbot: Retrieval-Augmented Generation chatbot built with Next.js 15, Groq AI, HuggingFace embeddings, Clerk auth, and Neon PostgreSQL. Chat with your PDFs intelligently. · GitHub ]

Would love feedback, especially from anyone who’s built RAG apps before — always curious what I’m missing or doing the hard way. And if you find it useful, a :star: on the repo genuinely helps it get seen by more people (and by future-me, as motivation to keep polishing it). Sharing with anyone else who might want to build on this is welcome too. Thanks for reading!

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.