Mehak

AI Systems · 2025

DocuChat

An intelligent document assistant that lets you ask questions about PDFs and get answers grounded in the source material.

The DocuChat site: the headline 'Chat with your documents. Get answers that cite.' beside a preview of the chat interface answering a question about a document.
DocuChat — answers that cite the document they came from

Problem

Reading a long document to answer one question is the wrong shape of work.

Search can find a page. It can’t explain what the relevant passages mean or connect information scattered across a document.

The real problem isn’t finding text. It’s finding the right context — and trusting the answer that comes from it.

Approach

DocuChat uses retrieval-augmented generation to turn a document into a searchable knowledge base.

Instead of asking a language model to answer from memory, the system retrieves the most relevant passages from the uploaded document and provides them as context for generating the response.

Every answer stays tied to the source material, making it possible to check where the response came from.

The flow

Document → answer
  1. 01

    Upload

    A PDF enters the system and becomes the source of truth.

  2. 02

    Ingest

    The document is parsed and divided into smaller chunks that can be searched independently.

  3. 03

    Index

    Chunks are converted into embeddings and stored for semantic retrieval.

  4. 04

    Retrieve

    When a question arrives, the system searches for the passages most relevant to the query.

  5. 05

    Generate

    The retrieved context is passed to the language model to generate an answer grounded in the document.

  6. 06

    Verify

    The relevant source passages remain visible so the user can check the answer instead of taking it on faith.

Architecture

Two passes
IngestOnce per document
  1. PDF
  2. Parse
  3. Chunk
  4. Embed
  5. Index
QueryOnce per question
  1. User question
  2. Retrieval
  3. Relevant context
  4. LLM
  5. Grounded answer
  6. Source passages

The two passes are separate on purpose. Parsing, chunking and embedding happen once, when the document arrives. Everything after that is per question, and reads from the index rather than the original file.

The interesting part

The hard part isn’t making a model answer questions. It’s giving the model the right information to answer from.

A language model can produce a convincing answer even when the source doesn’t contain it. DocuChat therefore puts retrieval before generation.

Find the evidence first.
Generate the answer second.

RetrieveContextGenerate

Why retrieval?

Giving the entire document to a model isn’t always the right solution.

Large documents contain more information than a single question usually needs. Retrieval narrows that information down to the passages that matter.

That makes the interaction more focused, while also giving the system a path back to the original source.

Grounding

Search isn’t the answer.

Traditional document search answers

“Where does this appear?”

DocuChat is designed to answer

“What does the document actually say about this?”

The distinction is small on the surface, but it changes the entire interaction.

The experience

Four stages
01Ask

Ask questions in natural language instead of manually searching through pages.

02Understand

The system retrieves the parts of the document relevant to the question.

03Answer

The response is generated using the retrieved context.

04Check

Source passages provide a way to verify the answer against the original document.

Design decision

The interface should make the AI feel accountable.

A chatbot that simply produces an answer asks the user to trust it.

DocuChat exposes the connection between the answer and the document, turning the interaction from “the AI says…” into “the document says…”

Stack

5 components
  • Next.js
  • TypeScript
  • LangChain
  • OpenAI
  • RAG

Outcome

DocuChat turns static documents into interactive knowledge.

Instead of searching through pages manually, users can ask questions, retrieve relevant context and receive answers connected to the material they’re actually working with.

The principle it is built around

The answer should have somewhere to come from.