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+