A production-ready Retrieval Augmented Generation (RAG) system built with LangChain, ChromaDB, and modern AI technologies. DocuMind AI enables intelligent question-answering over your documents with source citations.
- ๐ Multi-format Support: PDF, TXT, Markdown, DOCX
- ๐ Semantic Search: Advanced vector similarity search with ChromaDB
- ๐ค Flexible LLM Backend: OpenAI GPT or local Ollama models
- ๐ฌ Interactive Chat: Streamlit-based conversational interface
- ๐ REST API: FastAPI endpoints for easy integration
- ๐ Source Citations: Every answer includes document sources
- ๐ฏ Production Ready: Proper error handling, logging, and configuration
User Question
โ
[Document Processing] โ Text Chunking (1000 chars, 200 overlap)
โ
[Vector Store] โ Embeddings (ChromaDB)
โ
[Retrieval] โ Top-K Similar Chunks
โ
[LLM Generation] โ Answer with Context
โ
Response + Sources
| Component | Technology |
|---|---|
| Framework | LangChain 0.1.0 |
| Vector DB | ChromaDB 0.4.22 |
| LLM | OpenAI GPT-5/4o or Ollama |
| API | FastAPI 0.108.0 |
| UI | Streamlit 1.29.0 |
| Embeddings | OpenAI text-embedding-ada-002 |
| Processing | PyPDF, python-docx, markdown |
- Python 3.10 or higher
- OpenAI API key (or Ollama for local models)
- 4GB+ RAM recommended
# Clone the repository
git clone https://github.com/A2ELAOUDI/DocuMind-AI.git
cd DocuMind-AI
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env and add your OpenAI API keyEdit .env file:
# OpenAI Configuration
OPENAI_API_KEY=your_api_key_here
LLM_PROVIDER=openai # or 'ollama' for local
# Vector Database
CHROMA_PERSIST_DIRECTORY=./data/vectordb
# RAG Settings
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
TEMPERATURE=0.7
MAX_TOKENS=500streamlit run ui/streamlit_app.pyThen open http://localhost:8501 in your browser.
Steps:
- Click "Initialize System"
- Upload documents (PDF, TXT, MD, DOCX)
- Start asking questions!
# Start the API server
uvicorn api.main:app --reloadAPI will be available at http://localhost:8000
Swagger Documentation: http://localhost:8000/docs
Example API Calls:
# Upload documents
curl -X POST "http://localhost:8000/upload" \
-F "files=@document.pdf"
# Ask a question
curl -X POST "http://localhost:8000/query" \
-H "Content-Type: application/json" \
-d '{"question": "What is RAG?", "k": 4}'
# Get statistics
curl http://localhost:8000/statsfrom src.vector_store import VectorStore
from src.rag_engine import RAGEngine
from src.document_processor import DocumentProcessor
# Initialize components
vector_store = VectorStore()
rag_engine = RAGEngine(vector_store)
# Add documents
rag_engine.add_documents_to_knowledge_base(["doc1.pdf", "doc2.md"])
# Ask questions
response = rag_engine.query("What is machine learning?")
print(response["answer"])
print(response["sources"])DocuMind-AI/
โโโ src/
โ โโโ document_processor.py # Document loading & chunking
โ โโโ vector_store.py # ChromaDB vector database
โ โโโ rag_engine.py # RAG orchestration
โ โโโ utils.py # Utility functions
โโโ api/
โ โโโ main.py # FastAPI application
โโโ ui/
โ โโโ streamlit_app.py # Streamlit interface
โโโ data/
โ โโโ documents/ # Input documents
โ โโโ vectordb/ # Vector database storage
โโโ tests/
โ โโโ test_rag.py # Unit tests
โโโ requirements.txt # Python dependencies
โโโ .env.example # Environment variables template
โโโ README.md # This file
# Run tests
pytest tests/
# Run with coverage
pytest --cov=src tests/# Install Ollama
# https://ollama.ai
# Pull a model
ollama pull llama2
# Update .env
LLM_PROVIDER=ollama
OLLAMA_MODEL=llama2Smaller chunks = more precise retrieval, but less context Larger chunks = more context, but less precise
CHUNK_SIZE=500 # Smaller chunks
CHUNK_OVERLAP=100# In vector_store.py
embeddings = OpenAIEmbeddings(model="text-embedding-3-small")- Indexing Speed: ~1000 chunks/minute
- Query Latency: <2s (with OpenAI)
- Memory Usage: ~100MB + vector DB size
- Supported Docs: Unlimited (limited by disk space)
- โ
Never commit
.envfile - โ Use environment variables for API keys
- โ Sanitize file names before processing
- โ Validate file types before upload
- โ Use HTTPS in production
- โ Implement rate limiting for API
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- LangChain - RAG framework
- ChromaDB - Vector database
- OpenAI - LLM & Embeddings
- Streamlit - UI framework
- FastAPI - API framework
For questions or suggestions, please open an issue or contact [abdouelaoudi8@outlook.fr]
- Multi-language support
- Advanced filtering options
- Conversation memory
- Export chat history
- Docker deployment
- Kubernetes configs
- GraphQL API
- Web scraping integration
Built with โค๏ธ using LangChain, ChromaDB & Streamlit

