Production-ready RAG (Retrieval-Augmented Generation) backend with emotion-aware responses, multi-domain support, and Hugging Face model integration.
- Overview
- Features
- Quick Start
- Architecture
- Configuration
- API Documentation
- Model Management
- Development
- Deployment
- Troubleshooting
Meetara Core is a modular, production-ready RAG assistant backend that provides:
- ✅ 100+ Domain Support - Healthcare, Education, Business, Technology, and more
- ✅ Emotion-Aware Responses - Facial and speech emotion detection
- ✅ Multi-Language Support - 15+ languages including Telugu, Tamil, Bengali
- ✅ Offline-First - All processing done locally with open-source models
- ✅ Hugging Face Integration - Automatic model download and caching
- ✅ Production Ready - FastAPI, comprehensive error handling, monitoring
- Multi-Domain RAG: Handle 100+ domains using vector search with ChromaDB
- LangChain Agent System: Tool-based orchestration with intelligent routing
- Emotion-Aware Responses: Facial and speech emotion detection for adaptive responses
- Multi-Language Support: Telugu, Tamil, Bengali + 12 other languages
- Smart Domain Detection: Context-aware keyword matching with cross-domain intelligence
- Image Extraction: Automatic extraction and retrieval of images from documents
- Conversation Context: Maintains domain context across multi-turn conversations
- Vector Storage: ChromaDB with Snappy compression (75-85% storage reduction)
- Model Caching: Single-instance model loading with Hugging Face cache integration
- Performance: Shared embeddings model, batch APIs, parallel loading
- Config-Driven: All domain logic via YAML files (no hardcoding)
- Modular Architecture: Extensible design for easy customization
📖 For detailed quick start guide, see docs/QUICK_START.md
- Python 3.12+ (recommended) or Python 3.10+
- 8GB+ RAM (for model loading)
- 5GB+ disk space
- Git (for cloning)
- Clone the repository
git clone <repository-url>
cd meetara-core- Create virtual environment
python -m venv .venv-meetara
.venv-meetara\Scripts\activate # Windows
# source .venv-meetara/bin/activate # Linux/Mac- Install dependencies
pip install -r requirements.txt- Install Tesseract OCR (for image text extraction)
Windows:
# Download and install from: https://github.com/UB-Mannheim/tesseract/wiki
# Or use chocolatey:
choco install tesseractLinux:
sudo apt-get install tesseract-ocrmacOS:
brew install tesseract📝 Note: Tesseract is required for extracting text from images in PDFs. The system will work without it, but OCR will be skipped.
- Configure environment
# Copy example env file
cp env.example .env
# Edit .env and set your configuration (see Configuration section)- Start the server
python main.py- Verify installation
curl http://localhost:8000/health
# Should return: {"status": "healthy", ...}🎉 API available at http://localhost:8000
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
📖 For complete architecture documentation, see docs/ARCHITECTURE.md
┌─────────────────────────────────────────────────────────┐
│ User Request │
└────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ FastAPI Endpoints (/api/chat) │
└────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ MeetaraAgent (LangChain Agent) │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Query │ │ Domain │ │ RAG │ │
│ │ Analyzer │→ │ Detection │→ │ Retrieval │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ GGUF LLM Processor (meetara-qwen3-1.7b) │
│ ┌──────────────────────────────────────────────────┐ │
│ │ • Hugging Face Model Download & Caching │ │
│ │ • Single-Instance Loading (reused for all reqs) │ │
│ │ • Domain-Specific Prompt Generation │ │
│ │ • Response Structure Validation │ │
│ └──────────────────────────────────────────────────┘ │
└────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Structured Response + Images │
└─────────────────────────────────────────────────────────┘
meetara-core/
├── app/
│ ├── api/ # FastAPI route handlers
│ │ ├── chat.py # Chat endpoint with RAG
│ │ ├── emotion.py # Emotion detection APIs
│ │ ├── upload.py # Document upload & management
│ │ └── image_generation.py # Image generation API
│ ├── agent/ # LangChain agent system
│ │ ├── planner.py # Main agent orchestration
│ │ ├── mcp_router.py # Multi-component planner
│ │ └── tools/ # Agent tools
│ │ ├── adapter_selector.py # Domain routing
│ │ ├── translation_tool.py # Multi-language
│ │ ├── speech_tool.py # STT/TTS
│ │ ├── emotion_tool.py # Speech emotion
│ │ └── face_emotion_tool.py # Facial emotion
│ ├── rag/ # RAG components
│ │ ├── domain_retrievers.py # Domain-specific retrievers
│ │ ├── semantic_domain_detector.py # Semantic domain detection
│ │ └── vector_loader.py # Vector store management
│ ├── core/ # Core utilities
│ │ ├── config.py # Configuration management
│ │ ├── config_loader.py # YAML config loader
│ │ ├── gguf_llm_processor.py # GGUF model processor
│ │ ├── llm_processor.py # LLM integration
│ │ ├── query_analyzer.py # Query analysis & domain detection
│ │ ├── domain_categorizer.py # Domain categorization
│ │ ├── logger.py # Logging system
│ │ └── security.py # Security & validation
│ ├── services/ # Service layer
│ │ └── image_generator.py # Image generation service
│ └── utils/ # Utility functions
├── config/ # Configuration files
│ ├── domain_config.yaml # Domain definitions & settings
│ ├── domain_keywords.yaml # Domain keywords for detection
│ └── tier_config.yaml # Domain tier configurations
├── scripts/ # Utility scripts
│ ├── batch_uploader.py # Batch document upload
│ ├── check_db_size.py # Database size checker
│ └── setup_environment.py # Environment setup
├── tests/ # Test files
├── docs/ # Documentation
│ └── archive/ # Archived documentation
├── vectorstore/ # ChromaDB vector stores (per domain)
├── images/ # Extracted document images
├── models/ # Emotion detection models
├── main.py # FastAPI application entry point
├── requirements.txt # Python dependencies
├── env.example # Environment variables template
└── README.md # This file
- User Query → FastAPI endpoint (
/api/chat/) - Query Analysis → Domain detection (keyword + semantic)
- RAG Retrieval → Vector search in domain-specific ChromaDB
- Context Building → Merge RAG context + conversation history
- LLM Generation → GGUF model generates structured response
- Response Formatting → Add images, format markdown, return JSON
These are the most important settings you should understand and configure:
# Enable/disable Meetara fine-tuned models (recommended: true)
USE_MEETARA_MODELS=true
# Hugging Face model (auto-downloads and caches)
MEETARA_HF_MODEL_ID=meetara-lab/meetara-qwen3-1.7b-gguf
MEETARA_HF_MODEL_FILE=meetara-qwen3-1.7b-Q4_K_M.ggufWhat it does:
- ✅
true→ Uses your fine-tuned Meetara model (better responses, domain-aware) - ❌
false→ Falls back to base models (less accurate) - 💡 Recommendation: Keep
truefor production
# Extract images during query time (affects performance)
ENABLE_IMAGE_EXTRACTION_DURING_QUERY=falseWhat it does:
- ✅
true→ Extracts relevant images during each query (slower, visual context) - ❌
false→ Only extracts during document upload (faster queries) - 💡 Recommendation:
falsefor production (better performance)truefor fine-tuning data generation (better training data)
# Filter RAG context by keyword relevance
FILTER_RAG_CONTEXT_BY_RELEVANCE=falseWhat it does:
- ✅
true→ Filters retrieved documents by keyword matching (stricter) - ❌
false→ Returns all semantically similar documents (more context) - 💡 Recommendation:
falsefor training data generation (full context)truefor production (focused responses)
Configured in: app/core/domain_categorizer.py → DOMAIN_SECTIONS
What it does:
- Defines response structure per domain category
- Healthcare → diagnosis, symptoms, treatment, precautions
- Education → explanation, examples, practice_questions
- Legal → legal_context, rights, obligations, next_steps
Note: This is NOT for model selection (one model for all domains). It only controls response formatting structure.
Create a .env file from env.example:
# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
DEBUG=false
# CORS Configuration
CORS_ORIGINS=["http://localhost:3000","http://localhost:2025"]
# Vector Store Configuration
VECTORSTORE_PATH=vectorstore
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
CHUNK_SIZE=500
CHUNK_OVERLAP=100
# Meetara GGUF Models Configuration
# Option 1: Use Hugging Face model (recommended - automatic download)
MEETARA_HF_MODEL_ID=meetara-lab/meetara-qwen3-1.7b-gguf
MEETARA_HF_MODEL_FILE=meetara-qwen3-1.7b-Q4_K_M.gguf
# Cache directory (leave empty to use default HF cache: ~/.cache/huggingface/hub)
# On Windows: C:\Users\<username>\.cache\huggingface\hub
# MEETARA_MODEL_CACHE_DIR=
# Option 2: Use local models (fallback if HF not set)
# MEETARA_MODELS_PATH=C:/path/to/models
# MEETARA_INSTRUCT_MODEL=meetara-qwen3-1.7b-Q4_K_M.gguf
USE_MEETARA_MODELS=true
LOCAL_LLM_MAX_LENGTH=640
LOCAL_LLM_TOP_P=0.9
LOCAL_LLM_TOP_K=50
# LLM Configuration
LLM_CONTEXT_LENGTH=4096
LLM_TEMPERATURE=0.7
# Speech Processing
STT_MODEL=base
TTS_VOICE=en-US-JennyNeural
AUDIO_SAMPLE_RATE=16000
# Emotion Detection
EMOTION_MODELS_PATH=models/emotion
FACE_DETECTION_CONFIDENCE=0.5
# Fine-tuning Configuration (for meetara-lab integration)
ENABLE_IMAGE_EXTRACTION_DURING_QUERY=false
FILTER_RAG_CONTEXT_BY_RELEVANCE=false
# Logging
LOG_LEVEL=INFO
LOG_FILE=logs/meetara.logDomains are configured in config/domain_config.yaml:
categories:
healthcare:
tier: safety_critical
validation_level: strict
domains:
general_health:
requires_validation: true
priority: 1
mental_health:
requires_validation: true
priority: 1Adding a new domain:
- Add domain to
config/domain_config.yaml - Add keywords to
config/domain_keywords.yaml - Upload documents via
/api/upload/doc - Domain automatically available for queries
POST /api/chat/
Content-Type: application/json
{
"query": "How can I improve my sleep quality?",
"session_id": "conv-abc123", # Reuse same ID for conversation
"context": {
"domain": "general_health", # Optional: specify domain
"lang": "en",
"emotion": "anxious"
}
}Response:
{
"response": "**Quick Answer:** To improve sleep quality...",
"domain": "general_health",
"confidence": 0.95,
"images": [
{
"image_url": "/api/images/general_health/sleep_guide.png",
"caption": "Sleep hygiene diagram"
}
],
"sources": ["Sleep Guide.pdf", "Health Manual.pdf"]
}GET /api/chat/domains/categorizedCommand Line (cURL):
# Upload with domain specified
curl -X POST "http://localhost:8000/api/upload/doc" \
-F "file=@document.pdf" \
-F "domain=general_health"
# Auto-detect domain
curl -X POST "http://localhost:8000/api/upload/doc" \
-F "file=@document.pdf"Python Script:
# Single file upload
python scripts/batch_uploader.py --file document.pdf --domain general_health
# Batch upload from directory
python scripts/batch_uploader.py --source-dir downloads/ --domain general_health
# Auto-detect domain
python scripts/batch_uploader.py --file document.pdf --auto-detectUI (Swagger):
- Open http://localhost:8000/docs
- Navigate to
/api/upload/doc - Click "Try it out"
- Upload file and execute
See docs/ARCHITECTURE.md for complete upload guide.
GET /healthVisit http://localhost:8000/docs for interactive Swagger documentation.
Meetara Core supports automatic model download from Hugging Face:
Configuration:
MEETARA_HF_MODEL_ID=meetara-lab/meetara-qwen3-1.7b-gguf
MEETARA_HF_MODEL_FILE=meetara-qwen3-1.7b-Q4_K_M.ggufHow it works:
- First Request: Downloads model from HF (~1.2 GB, one-time)
- Caching: Stores in
~/.cache/huggingface/hub(standard HF cache) - Loading: Loads model once into memory
- Reuse: Same model instance used for all requests
Performance:
- First request: ~2-3 minutes (download + load)
- Subsequent requests: ~30-35 seconds (generation only)
Request → Check Cache → Download (if needed) → Load (once) → Reuse
To use a custom cache directory:
# Example: Use a custom directory for model cache
MEETARA_MODEL_CACHE_DIR=/path/to/custom/cache
# Default: Uses standard HF cache location
# Windows: C:\Users\<username>\.cache\huggingface\hub
# Linux/Mac: ~/.cache/huggingface/hub- Add to
config/domain_config.yaml:
categories:
your_category:
tier: quality
domains:
your_domain:
requires_validation: false
priority: 2- Add keywords to
config/domain_keywords.yaml:
your_domain:
keywords: ["keyword1", "keyword2", "phrase"]- Upload documents:
curl -X POST http://localhost:8000/api/upload/doc \
-F "file=@your_document.pdf" \
-F "domain=your_domain"No code changes required! Everything is config-driven.
- Create tool in
app/agent/tools/your_tool.py:
from langchain_core.tools import BaseTool
class YourTool(BaseTool):
name = "your_tool"
description = "Tool description"
def _run(self, query: str) -> str:
# Tool logic
return result- Add to agent in
app/agent/planner.py:
tools.append(YourTool())# Run all tests
pytest tests/
# Run specific test
pytest tests/test_chat_api.py# Build image
docker build -t meetara-core .
# Run container
docker run -p 8000:8000 \
-v $(pwd)/vectorstore:/app/vectorstore \
-v $(pwd)/.env:/app/.env \
meetara-coredocker-compose up -d- Environment Variables: Set all sensitive configs via
.env - Model Caching: Ensure
~/.cache/huggingface/hubis persistent - Vector Store: Mount
vectorstore/directory as volume - Logging: Configure log rotation and monitoring
- Health Checks: Use
/healthendpoint for monitoring
Issue: Model download fails or model not found
Solutions:
- Check internet connection (for HF download)
- Verify
MEETARA_HF_MODEL_IDandMEETARA_HF_MODEL_FILEin.env - Check disk space (~2 GB needed)
- Verify cache directory permissions
- Check logs:
logs/meetara.log
Issue: Query routed to wrong domain
Solutions:
- Check
config/domain_keywords.yamlhas relevant keywords - Verify domain exists in
config/domain_config.yaml - Use
context.domainto explicitly specify domain - Check logs for domain detection scores
Issue: Responses take too long
Solutions:
- First request includes model download (one-time)
- Reduce
LOCAL_LLM_MAX_LENGTHin.env - Reduce
LLM_CONTEXT_LENGTHin.env - Check CPU/RAM usage
- Consider GPU acceleration if available
Issue: Port 8000 already in use
Solutions:
# Windows
netstat -ano | findstr :8000
taskkill /PID <PID> /F
# Linux/Mac
lsof -ti:8000 | xargs kill -9
# Or change port in .env
API_PORT=8001| Operation | Time | Notes |
|---|---|---|
| Model Download | ~99s | One-time only |
| Model Load | ~1.6s | One-time only |
| Domain Detection | ~0.2-0.4s | Per request |
| RAG Retrieval | ~0.2-0.5s | Per request |
| LLM Generation | ~30-45s | Per request |
| Total (cached) | ~30-35s | After first load |
- Model Caching: Model loads once, reused for all requests
- Vector Store: ChromaDB with Snappy compression (75-85% reduction)
- Shared Embeddings: Single embeddings model instance
- Batch Operations: Use
/api/vectorstore/allfor bulk stats
- Input Sanitization: XSS and injection protection
- PII Redaction: Automatic privacy protection in logs
- File Validation: Secure file upload handling
- CORS Configuration: Cross-origin request control
- Rate Limiting: Built-in request throttling
- Never commit
.envfile to git - Use environment variables for sensitive data
- Regularly update dependencies
- Monitor logs for suspicious activity
- Use HTTPS in production
config/domain_config.yaml- Domain definitions and settingsconfig/domain_keywords.yaml- Domain keywords for detectionconfig/tier_config.yaml- Domain tier configurationsenv.example- Environment variables template
scripts/batch_uploader.py- Batch document upload utilityscripts/check_db_size.py- Database size checkerscripts/setup_environment.py- Automated environment setup
- API Docs: http://localhost:8000/docs (Swagger UI)
- Archived Docs:
docs/archive/(historical documentation)
See docs/CONTRIBUTING.md for detailed contribution guidelines.
Quick steps:
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Make changes with tests
- Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
- Formatting: Black
- Imports: isort
- Type Hints: Required for all functions
- Docstrings: Required for all functions/classes
MIT License - see LICENSE file for details
- Quick Start Guide - Get started in 5 minutes
- Architecture Documentation - Complete system architecture with flow diagrams
- Contributing Guide - How to contribute to the project
- Data Management Guide - Managing downloads, images, and data directories
- Git Setup Guide - Setting up Git LFS for compressed data files
- API Docs: http://localhost:8000/docs (Swagger UI)
- Issues: GitHub Issues
- API Docs: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
✅ Production Ready
- All endpoints tested and working
- Model download and caching operational
- Multi-domain RAG functioning
- Emotion detection integrated
- Multi-language support active
- Documentation complete
Meetara Core - Empowering AI assistants with emotion-aware intelligence.
Version: 1.0.0
Last Updated: November 2025
Python: 3.12+