DocuMind AI is a full-stack RAG (Retrieval-Augmented Generation) document assistant. Upload documents, ask questions in natural language, and get streaming, document-grounded answers powered by semantic search and LLMs β with multi-turn conversation memory and smart follow-up suggestions.
Upload β Extract β Chunk β Embed β Retrieve β Generate β Stream β Suggest
- Overview
- Features
- Tech Stack
- Architecture
- RAG Pipeline
- Backend Responsibilities
- Frontend Responsibilities
- Important Project Behavior
- Getting Started
- Using an LLM Provider
- API Reference
- License
DocuMind AI lets users upload documents in multiple formats, automatically extracts and chunks their text, generates vector embeddings, and stores them in a FAISS index for fast semantic retrieval. When a user asks a question, the app retrieves the most relevant chunks and passes them β along with the full session conversation history β to an LLM (Groq or a local Ollama model) to generate a grounded, streamed answer. After each answer, the app asynchronously generates 3 smart follow-up questions as clickable suggestions, enabling a natural, guided conversation flow.
- π Multi-format document upload: PDF, DOCX, TXT, Markdown, HTML
- β File validation (extension and size checks)
- π Text extraction with processed text storage
- βοΈ LangChain recursive text chunking
- π§ HuggingFace SentenceTransformer embeddings
- π FAISS semantic vector search with configurable top-k retrieval
- π¬ RAG-based, document-grounded answer generation
- β‘ Streaming answers via SSE-style
fetchstreaming (~0.4s time-to-first-token on Groq) - π Multi-provider LLM support: Groq and Ollama
- π£οΈ Multi-turn conversation memory β full session chat history injected into every LLM request
- β¨ Smart Follow-Up Suggestions β 3 clickable follow-up questions generated asynchronously after each answer
- π― Selected-document chat (scope Q&A to a specific document)
- π Query history
- π Analytics dashboard
- ποΈ Document deletion
- π Manual and startup FAISS index rebuild
- π Processed text preview
- π Notifications
- π³ Dockerfiles + Docker Compose
- π PostgreSQL metadata storage via SQLAlchemy
- βοΈ React frontend with Tailwind CSS, Zustand, and Axios
| Layer | Technologies |
|---|---|
| Frontend | React, Vite, Tailwind CSS, Zustand, Axios, Lucide Icons |
| Backend | Python, FastAPI, SQLAlchemy, Pydantic Settings |
| AI / RAG | LangChain, SentenceTransformers, FAISS, Groq, Ollama |
| Database | PostgreSQL (commonly a Supabase PostgreSQL pooler URL) |
| DevOps | Docker, Docker Compose, GitHub, Render/Vercel-ready setup |
flowchart LR
User["User"] --> Frontend["React Frontend"]
Frontend --> Backend["FastAPI Backend"]
Backend --> PostgreSQL["PostgreSQL Metadata DB"]
Backend --> LocalFiles["Local Uploads / Processed Text"]
Backend --> Extractor["Text Extraction"]
Backend --> Chunker["LangChain Chunking"]
Backend --> Embeddings["SentenceTransformer Embeddings"]
Embeddings --> FAISS["FAISS Vector Store"]
Backend --> LLM["Groq / Ollama LLM"]
FAISS --> Backend
LLM --> Backend
Backend --> Frontend
flowchart TD
A["Upload Document"] --> B["Validate File"]
B --> C["Save Original File"]
C --> D["Extract Text"]
D --> E["Save Processed Text"]
E --> F["Split Into Chunks"]
F --> G["Generate Embeddings"]
G --> H["Store Vectors In FAISS"]
I["Ask Question"] --> J["Embed Question"]
J --> K["Search FAISS (top-5 chunks)"]
K --> L["Retrieve Relevant Chunks"]
L --> M["Build Prompt (+ session history)"]
M --> N["Groq/Ollama Generates Answer"]
N --> O["Stream Answer To UI"]
O --> P["Save Query History"]
O --> Q["Generate 3 Follow-Up Suggestions"]
Q --> R["Display as Clickable Pills in UI"]
FastAPI handles document upload, validation, extraction, chunking, embedding, FAISS indexing, RAG answering with multi-turn session history, streaming responses, smart follow-up question generation via /query/follow-ups, query history, analytics, document deletion, processed text preview, and database communication.
React handles the dashboard, document list, upload UI, selected-document chat, streaming chat output with session history tracking, smart follow-up suggestion pills (clickable to auto-submit), query history, analytics, processed text preview, notifications, delete confirmation, and rebuild-index controls.
- PostgreSQL stores structured records such as documents, query history, and analytics metadata.
- Original uploaded files and processed text are stored locally.
- The FAISS index lives in memory.
- On backend startup, the app can rebuild the FAISS index from processed text.
- Streaming answers are served from
/query/ask-stream. - Session chat history is maintained in React state and sent with every request β it is not persisted to the database.
- Follow-up suggestions are generated by a separate background call to
/query/follow-upsafter the stream completes. - The active LLM provider is selected via the backend
.envfile.
Create a backend/.env file:
DATABASE_URL=your_postgresql_pooler_url
LLM_PROVIDER=groq
GROQ_API_KEY=your_groq_key
GROQ_MODEL_NAME=allam-2-7b
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3.1
APP_NAME=DocuMind AI
API_PREFIX=/api/v1
MAX_FILE_SIZE_MB=20
CHUNK_SIZE=1000
CHUNK_OVERLAP=200Using Docker with a local Ollama instance? Point to the host machine instead of
localhost:OLLAMA_BASE_URL=http://host.docker.internal:11434
Backend
cd backend
# Windows
.\.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reloadBackend runs at:
- API:
http://127.0.0.1:8000 - Interactive docs:
http://127.0.0.1:8000/docs
Frontend
cd frontend
npm install
npm run devFrontend runs at:
http://localhost:5173
From the project root:
docker compose up --buildThen open:
| Service | URL |
|---|---|
| Frontend | http://localhost:5174 |
| Backend docs | http://localhost:8000/docs |
In backend/.env:
LLM_PROVIDER=groq
GROQ_API_KEY=your_groq_keyRestart the backend.
Install Ollama, then pull a model and start the server:
ollama pull llama3.1
ollama serveIn backend/.env:
LLM_PROVIDER=ollama
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_MODEL=llama3.1Restart the backend.
All endpoints are prefixed with API_PREFIX (default: /api/v1).
| Method | Endpoint | Description |
|---|---|---|
GET |
/system/health |
Health check |
GET |
/system/rag-status |
Status of the RAG pipeline / FAISS index |
GET |
/documents |
List all uploaded documents |
POST |
/documents/upload |
Upload a new document |
DELETE |
/documents/{document_id} |
Delete a document |
POST |
/documents/rebuild-index |
Manually rebuild the FAISS index |
POST |
/query/ask |
Ask a question (non-streaming) |
POST |
/query/ask-stream |
Ask a question (streaming, with session history) |
POST |
/query/follow-ups |
Generate 3 follow-up question suggestions from an answer |
GET |
/query/history |
Retrieve query history |
GET |
/analytics/stats |
Retrieve usage analytics |
Full interactive documentation is available at /docs (Swagger UI) once the backend is running.
This project is available under the MIT License. Feel free to use, modify, and build on it.
Built with FastAPI, React, LangChain, FAISS, and a lot of curiosity about RAG pipelines.