Current Version: v1.0.3 | Status: β Production Ready | Last Updated: June 23, 2025
- π― Zero Error Rate: All tests passing with robust error handling
- β‘ High Performance: Sub-millisecond response times with optimized concurrency
- π Complete Documentation: All guides consolidated and up-to-date (June 2025)
- π§ Full Feature Set: Entity extraction, vector search, multilingual support, PDF export, and analytics
- π Auto-Install: Smart dependency detection and installation
- π‘οΈ Production Hardened: Comprehensive logging, monitoring, and health checks
Variable | Description | Example Value | Required |
---|---|---|---|
OPENROUTER_API_KEY | OpenRouter API key for LLM access | sk-or-v1-*** |
β |
CHUNK_SIM | Similarity threshold for chunking | 0.80 |
|
LOG_LEVEL | Application logging level | DEBUG |
Setup: Copy .env.example
to .env
and update with your values.
Copy-Item .env.example .env
# Edit .env with your API keys
SocioRAG is a production-ready system for analyzing social dynamics in texts through advanced NLP, entity extraction, vector search, and answer generation capabilities. The system follows a modular architecture with distinct phases for data ingestion, storage, retrieval, and answer generation.
- Python: 3.12+ (tested with 3.12.9)
- Node.js: 18+ with npm/pnpm/yarn support
- Operating System: Windows (PowerShell), Linux, macOS
- Memory: 4GB+ RAM (8GB recommended for optimal performance)
- Storage: 2GB+ free space for dependencies and models
- Internet: Required for model downloads and API access
- π Auto-Detection: Automatically detects missing dependencies and installs them
- π¦ Multi-Package Manager: Supports npm, pnpm, and yarn (auto-detected)
- πͺ Windows Optimized: Proper handling of paths with spaces (e.g., "Program Files")
- π‘οΈ Error Recovery: Clear error messages with automatic fallbacks
- β‘ Zero Configuration: Works out-of-the-box after environment setup
π Complete deployment guide: DEPLOYMENT.md
π― TL;DR: Run
.\start.ps1
β Click http://localhost:3000 when ready β Run.\stop.ps1
when done
# Clone and navigate to repository
git clone https://github.com/Muhanad-husn/sociorag.git
cd sociorag
# Setup environment files
Copy-Item .env.example .env
Copy-Item config.yaml.example config.yaml
# Edit .env with your OPENROUTER_API_KEY
# Start everything automatically
.\start.ps1
π Success indicators:
- Backend:
β Backend started successfully
- Frontend:
β Frontend started successfully
- Health:
β All services started successfully!
π Access Points:
- Main Application: http://localhost:3000 β Primary UI
- API Documentation: http://localhost:8000/docs
- Backend Health: http://localhost:8000/api/admin/health
- Admin Status: http://localhost:8000/api/admin/status
For comprehensive environment setup with database initialization:
# Run full setup script
.\setup.ps1
# Then start normally
.\start.ps1
Always properly stop the application when finished:
.\stop.ps1
π‘ Why this matters: Prevents port conflicts, ensures clean shutdown, and stops all background processes properly.
Feature | Description | Status |
---|---|---|
π§ Entity Extraction | LLM-powered multilingual entity recognition with spaCy | β Ready |
π Vector Search | Fast similarity search with reranking and configurable params | β Ready |
π PDF Export | Custom-styled automated report generation | β Ready |
π Query Analytics | JSONL logging with performance metrics | β Ready |
π Multilingual | English & Arabic support with translation API | β Ready |
π¨ Modern UI | Responsive design with dark/light themes | β Ready |
π Security | API key management and secure configurations | β Ready |
π Monitoring | Health checks, structured logging, performance dashboards | β Ready |
π Auto-Deploy | One-command startup with dependency management | β Ready |
# Run all tests
pytest tests/ -v
# Integration tests only
pytest -m integration -v
# Performance testing
.\scripts\testing\test_runner.ps1 -TestLevel standard
# Load testing
.\scripts\testing\load_test.ps1 -ConcurrentUsers 5
Test Coverage: 100% pass rate | Performance: Sub-millisecond response | Documentation: Complete
π Full testing guide: tests/README.md
SocioRAG follows a robust 4-phase pipeline:
- π₯ Ingest: Upload documents (PDF, text) with intelligent preprocessing
- π― Extract: Entities and relationships via LLM + spaCy with multilingual support
- ποΈ Store: Dual vector storage system:
- Chunk Embeddings: Document segments for semantic retrieval
- Entity Embeddings: Named entities for graph analysis and entity-level search
- Semantic Chunking: AI-driven text segmentation based on semantic boundaries
- π Query: Advanced hybrid retrieval combining:
- Vector similarity search
- BM25 keyword matching
- Cross-encoder reranking
- Source diversity enforcement
- π€ Export: Download answers and comprehensive reports as styled PDFs
Component | Technology | Purpose |
---|---|---|
π₯οΈ Backend | FastAPI + Python 3.12 | API server and core logic |
π¨ Frontend | Preact + Vite + TypeScript | Modern reactive UI |
π§ LLM | OpenRouter API + LangChain | Language model integration |
ποΈ Vector DB | SQLite-vec | Embeddings and similarity search |
π Graph DB | SQLite | Entity relationships |
π NLP | spaCy + Custom pipeline | Entity extraction and analysis |
π Export | Playwright | PDF generation with styling |
π Config | Pydantic + YAML | Type-safe configuration |
sociorag/
βββ π₯οΈ backend/app/ # FastAPI application
β βββ api/ # REST API endpoints
β βββ core/ # Configuration & logging
β βββ ingest/ # Document processing
β βββ retriever/ # Vector search & retrieval
β βββ answer/ # Response generation
βββ π¨ ui/ # Preact frontend
βββ π scripts/ # Automation & testing
β βββ production/ # Deployment scripts
β βββ testing/ # Test automation
β βββ utilities/ # Helper tools
βββ π docs/ # Documentation
βββ π§ͺ tests/ # Test suites
βββ π¦ Configuration files
- π Quick Start Guide β Get up and running in minutes
- π Complete Documentation β Centralized access to all guides
- π§ API Reference β Complete endpoint documentation
- π Production Deployment β Deployment & scaling
- π Project Status β System health & version info
- π οΈ Architecture Guide β System design deep-dive
- π Smart Search: Natural language, semantic, and multilingual queries
- π Query History: View, copy, and delete previous queries with timestamps
- π€ Document Management: Upload, process, and download documents
- βοΈ Advanced Settings: API keys, model selection, theme toggle
- π Performance Metrics: Real-time analytics and response monitoring
- π Multilingual: Full English and Arabic support with auto-translation
- π¨ Modern Design: Responsive UI with dark/light themes
- Health Checks: Real-time system status monitoring
- Performance Dashboard: Response times, throughput, and system metrics
- Load Testing: Built-in testing scripts for performance validation
- Structured Logging: Comprehensive logging with multiple output formats
# Start monitoring dashboard
.\scripts\testing\monitoring_dashboard.ps1
# Run performance tests
.\scripts\testing\performance_test_monitor.ps1
# Check system status
.\scripts\utilities\production_status.ps1
Prerequisites: Python 3.12+, Node.js 18+, Git
# Clone repository
git clone https://github.com/Muhanad-husn/sociorag.git
cd sociorag
# Automated setup - handles everything
.\setup.ps1
# Start application
.\start.ps1
# Install Miniconda if not already installed
# Download: https://docs.conda.io/en/latest/miniconda.html
# Create environment from environment.yml (if available)
conda env create -f environment.yml
conda activate sociorag
# Or create manually
conda create -n sociorag python=3.12
conda activate sociorag
pip install -r requirements.txt
# Download spaCy model
python -m spacy download en_core_web_sm
# Install Playwright browsers
playwright install
# Create virtual environment
python -m venv .venv
# Activate environment
# Windows
.\.venv\Scripts\Activate.ps1
# Linux/macOS
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Download spaCy model
python -m spacy download en_core_web_sm
# Install Playwright browsers
playwright install
# 1. Copy configuration templates
Copy-Item config.yaml.example config.yaml
Copy-Item .env.example .env
# 2. Edit configuration files
# config.yaml - System settings
# .env - API keys and environment variables
Required Configuration:
OPENROUTER_API_KEY
: Get from OpenRouterCHUNK_SIM
: Text similarity threshold (default: 0.8)LOG_LEVEL
: Logging verbosity (DEBUG/INFO/WARNING/ERROR)
# Start with auto-dependency installation
.\start.ps1
# Or start services manually
# Terminal 1: Backend
python -m backend.app.main
# Terminal 2: Frontend
cd ui
npm install # if not already installed
npm run dev
- OS: Windows 10+, macOS 10.15+, Linux (Ubuntu 18.04+)
- Python: 3.12+ (recommended 3.12.9)
- Node.js: 18+ with npm/pnpm/yarn
- Memory: 4GB RAM
- Storage: 2GB free space
- Network: Internet connection for model downloads
- Memory: 8GB+ RAM for optimal performance
- Storage: 10GB+ for large document processing
- CPU: Multi-core processor for concurrent operations
- GPU: Optional, future feature for accelerated embeddings
Detailed diagrams & component docs β docs/architecture_documentation.md
- Data Ingestion Pipeline (
backend/app/ingest/
)- Enhanced entity extraction with LLM-powered analysis
- Document chunking and metadata extraction
- Vector Storage & Retrieval (
backend/app/retriever/
)- Chunk Embeddings: Stores document segments as vectors for semantic search (e.g., SQLite-vec)
- Entity Embeddings: Stores named entities as separate vectors for entity-level similarity and graph operations
- Advanced Retrieval System: Employs hybrid retrieval combining vector similarity, BM25 keyword matching, and cross-encoder reranking for comprehensive coverage
- Intelligent Context Management: Dynamically balances relevance, diversity, and token limits with priority-based selection and semantic deduplication
- Enables both chunk-based and entity-based retrieval with source diversity enforcement
- Answer Generation (
backend/app/answer/
)- Complete response generation with LLM integration
- Citation management and source linking
- Core Infrastructure (
backend/app/core/
)- Centralized configuration management
- Logging and error handling
- API Layer (
backend/app/api/
)- FastAPI endpoints for Q&A functionality
- RESTful interface design
- Framework: FastAPI with async/await support
- LLM Integration: LangChain with OpenRouter API
- Vector Database: SQLite-vec for similarity search (chunks and entities)
- Graph Database: SQLite for entity relationships
- Entity Extraction: spaCy + Custom LLM pipeline
- PDF Generation: Playwright with browser automation
We welcome contributions! Here's how to get started:
# Fork and clone the repository
git clone https://github.com/your-username/sociorag.git
cd sociorag
# Set up development environment
.\setup.ps1
# Run tests
pytest tests/ -v
# Start in development mode
.\start.ps1 -ShowStartupLogs
- Unit Tests:
pytest tests/ -v
- Integration Tests:
pytest -m integration -v
- Performance Tests:
.\scripts\testing\test_runner.ps1
- Load Tests:
.\scripts\testing\load_test.ps1
- Update README.md for user-facing changes
- Add docstrings for new functions/classes
- Update API documentation for endpoint changes
- Include type hints for Python code
- Create a feature branch:
git checkout -b feature/your-feature
- Make your changes with tests
- Run the full test suite
- Update documentation as needed
- Submit a pull request with clear description
- π Issues: GitHub Issues
- π Documentation: Complete Docs
- π Project Status: Status Dashboard
- π§ Developer Guide: Development Guidelines
Apache-2.0 License β See LICENSE for full terms.
- LangChain for LLM integration framework
- FastAPI for the high-performance web framework
- SQLite-vec for efficient vector storage
- spaCy for advanced NLP processing
- Preact for the lightweight frontend framework
- OpenRouter for LLM API access
Port Already in Use:
# Kill existing processes
.\stop.ps1
# Wait a few seconds, then restart
.\start.ps1
Dependencies Not Installing:
# Clear cache and reinstall
Remove-Item -Recurse -Force node_modules, .venv
.\setup.ps1
API Key Issues:
# Verify your .env file has the correct API key
Get-Content .env | Select-String "OPENROUTER_API_KEY"
Performance Issues:
# Check system status
.\scripts\utilities\production_status.ps1
# Run diagnostics
.\scripts\testing\monitoring_dashboard.ps1
For more troubleshooting help, see Installation Guide.
π― Ready to start? Follow the Quick Start section above!
π Need more details? Check out our Complete Documentation.