Chat with any PDF using AI — powered by MistralAI, LangChain, and ChromaDB.
DocMind is a Retrieval-Augmented Generation (RAG) application that lets you upload any PDF and have a natural conversation with it. Ask questions, extract insights, or summarize content — the AI answers using only what's in your document.
No hallucinations. No guessing. Just your document, intelligently searched.
┌─────────────────────────────────────────────────────────────────┐
│ DocMind Flow │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 📄 PDF Upload │
│ │ │
│ ▼ │
│ PyPDFLoader → loads all pages as documents │
│ │ │
│ ▼ │
│ RecursiveCharacterTextSplitter │
│ (chunk_size=1000, overlap=200) │
│ │ │
│ ▼ │
│ MistralAI Embeddings (mistral-embed) │
│ → converts each chunk into a vector │
│ │ │
│ ▼ │
│ ChromaDB → stores all vectors locally │
│ │
│ ───────────────────────────────────────── │
│ │
│ 💬 User Question │
│ │ │
│ ▼ │
│ MMR Retriever (k=4, fetch_k=10, lambda=0.5) │
│ → finds the 4 most relevant & diverse chunks │
│ │ │
│ ▼ │
│ ChatPromptTemplate │
│ → injects context + question into prompt │
│ │ │
│ ▼ │
│ MistralAI LLM (mistral-small-2506) │
│ → generates answer grounded in context │
│ │ │
│ ▼ │
│ ✅ Answer displayed in chat UI │
│ │
└─────────────────────────────────────────────────────────────────┘
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | HTML, CSS, Vanilla JS | Chat UI with PDF upload |
| Backend | Flask (Python) | REST API server |
| LLM | MistralAI mistral-small-2506 |
Answer generation |
| Embeddings | MistralAI mistral-embed |
Text → vector conversion |
| Vector Store | ChromaDB | Storing & searching embeddings |
| RAG Framework | LangChain | Orchestrating the entire pipeline |
| PDF Loader | PyPDFLoader | Parsing PDF pages |
| Text Splitter | RecursiveCharacterTextSplitter | Chunking documents |
| Retrieval | MMR (Maximal Marginal Relevance) | Diverse, relevant chunk retrieval |
DocMind/
├── app.py # Flask backend — API routes
├── index.html # Frontend UI
├── create_database.py # Standalone script to pre-index a PDF
├── main.py # CLI version of the RAG chat
├── requirements.txt # Python dependencies
├── .env # API keys (never committed)
├── .gitignore
└── chroma-db/ # Local vector store (auto-generated)
git clone https://github.com/YOUR_USERNAME/docmind.git
cd docmindpython -m venv venv
source venv/bin/activate # Mac/Linux
venv\Scripts\activate # Windowspip install -r requirements.txtCreate a .env file in the root folder:
MISTRAL_API_KEY=your_mistral_api_key_hereGet your free API key at console.mistral.ai
python app.pyOpen your browser at http://localhost:5010
- Open the app in your browser
- Click "Click or drag a PDF here" in the sidebar
- Wait for the document to be indexed (you'll see a confirmation message)
- Type your question in the chat input and press Enter
- DocMind retrieves the most relevant chunks and answers using only your document
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Serves the frontend UI |
POST |
/upload |
Upload and index a PDF file |
POST |
/chat |
Send a question, get an answer |
GET |
/status |
Check if a document is loaded |
| Variable | Required | Description |
|---|---|---|
MISTRAL_API_KEY |
✅ Yes | Your MistralAI API key |
PORT |
Auto (Railway) | Port override for deployment |
🚀 https://docmind-etyl.onrender.com/
Built by Henil Bhavsar
MIT License — free to use, modify, and distribute.