Status: [UNTESTED] Endpoints found: http://localhost:8000/api/documents/chat/` Source: https://github.com/AminEttefagi/django_RAG_project # Enterprise RAG System with Django & LangChain An advanced, production-grade Retrieval-Augmented Generation (RAG) pipeline integrated into a Django web application. This system allows centralized document management via Django Admin, automatic background vectorization, and multi-document semantic querying with zero memory leaks. ## 🌟 Key Features - **Enterprise Architecture**: Built for organizational knowledge management where admins control data and clients securely query via API. - **Multilingual Support**: Uses high-accuracy multilingual embeddings optimized for Persian and English contexts. - **Metadata Filtering**: Advanced isolated routing in the vector store ensuring zero cross-document contamination and high token efficiency. - **Persistent Vector Store**: Leverages ChromaDB saved directly on disk with optimized lifecycle sync. - **Full Chat History**: Complete logging and chronological tracking of all user questions and AI answers. ## 🏗️ Architectural Design Patterns Applied To ensure maximum scalability and compliance with **SOLID principles**, the following design patterns were implemented: 1. **Strategy Pattern (`extractors.py`)**: Defines a unified interface (`BaseExtractor`) for reading text from multiple file types (`.txt`, `.docx`, `.pdf`), decoupling file-specific logic from the rest of the app. 2. **Factory Pattern (`extractors.py`)**: Encapsulates object creation via `ExtractorFactory`, dynamically resolving the correct strategy at runtime based on file extensions. 3. **Observer Pattern / Django Signals (`signals.py`)**: Eliminates tightly-coupled code. The core Django database operates independently; when a document is saved or deleted, asynchronous signals trigger automated state synchronization inside ChromaDB. 4. **Service Layer Pattern (`rag.py`)**: Concentrates all AI, LangChain LCEL chains, and LLM communication inside a unified, reusable `RAGService` class. 5. **Lazy Initialization**: High-overhead machine learning models (