Advanced AI-powered legal information retrieval and DevOps automation platform with RAG (Retrieval-Augmented Generation) and MCP (Model Context Protocol)
- π― Overview
- π Quick Start
- π Project Structure
- π οΈ Development
- π³ Deployment
- π§ͺ Testing
- π§ Configuration
- π Monitoring
LexiOps is a cutting-edge dual-platform system that revolutionizes both legal information access and DevOps automation through advanced AI technologies. The platform combines RAG (Retrieval-Augmented Generation) with MCP (Model Context Protocol) to deliver precise legal insights and intelligent Kubernetes cluster management.
- Intelligent RAG System: Advanced retrieval-augmented generation for legal document analysis
- Real-time Legal Chat: WebSocket-powered instant legal assistance with streaming responses
- Multi-Source Integration: Legal databases, web search, and knowledge APIs
- Vietnamese Legal Focus: Specialized for Vietnamese legal corpus with 180k+ documents
- Vector Search: Semantic search with Qdrant database and OpenAI embeddings
- Agentic Workflow System: GPT-4 powered automation for Kubernetes operations
- MCP Integration: Model Context Protocol with 51+ dynamic Kubernetes tools
- 3-Tier Architecture: FastAPI + MCP Client + Tools Server
- Intelligent Decision Making: LangGraph-based workflow orchestration
- Cluster Management: AI-powered infrastructure automation
- Dual AI Engines: Legal RAG + DevOps Automation in unified platform
- Real-time Processing: Sub-second response times with intelligent caching
- Microservices Design: Scalable, containerized architecture with specialized workers
- Production Ready: Enterprise-grade security, monitoring, and deployment
- Open Source: MIT licensed with comprehensive documentation
- Docker 20.10+ and Docker Compose 2.0+
- OpenAI API Key for AI functionality
# 1. Clone repository
git clone https://github.com/tinhnguyen0110/LexiOps.git
cd LexiOps
# 2. Setup environment
cp .env.example .env
# Edit .env with your OPENAI_API_KEY
# 3. Start system
make quick-start
# OR: docker-compose up -d
# 4. Verify health
make health-check| Service | URL | Description |
|---|---|---|
| Frontend | http://localhost:3000 | Main chat interface |
| API Docs | http://localhost:8000/docs | Backend documentation |
| Monitor | http://localhost:5555 | Celery task monitor |
LexiOps/
βββ π src/ # Main legal retrieval system
β βββ π app/ # π FastAPI Backend
β β βββ brain.py # π§ AI reasoning engine
β β βββ main.py # π API server entry
β β βββ celery_config.py # π Task queue config
β β βββ π api/ # API endpoints
β β βββ π config/ # Configuration
β β βββ π utils/ # Utilities
β β
β βββ π legal-chatbot-fe/ # βοΈ React Frontend
β β βββ src/App.jsx # Main component
β β βββ π components/ # UI components
β β βββ π hooks/ # Custom hooks
β β
β βββ π streamlit-fe/ # π― Alternative frontend
β
βββ π lexiops-copilot/ # π€ DevOps AI Copilot System
β βββ π agent/ # Core AI agent
β β βββ main.py # FastAPI copilot server
β β βββ graph.py # LangGraph workflow
β β βββ mcp_server.py # MCP server configuration
β β βββ π nodes/ # AI processing nodes
β βββ π k8s/ # Kubernetes deployments
β β βββ mcp-k8s-deployment.yaml # MCP tools server
β βββ π scripts/ # Deployment scripts
β β βββ run.sh # Start copilot system
β β βββ deploy-3tier.sh # 3-tier deployment
β βββ π test/ # Integration tests
β βββ π docs/ # Architecture docs
β βββ π notebooks/ # Development notebooks
β
βββ π scripts/ # π§ Deployment scripts
β βββ build-docker.sh # Docker builder
β βββ system-check.sh # Health validator
β βββ deploy-pipeline.sh # Deployment automation
β
βββ π tests/ # π§ͺ Test suite
β βββ run_docker_tests.sh # Test runner
β βββ DOCKER_TESTING_GUIDE.md # Testing docs
β βββ test_*.py # Test files
β
βββ π helm/ # βΈοΈ Kubernetes deployment
β βββ helmfile.yaml # Helm orchestration
β βββ π charts/ # Custom charts
β βββ π values/ # Environment configs
β
βββ π data/ # π Legal corpus
β βββ π data_corpus/ # 180k+ legal documents
β βββ π mongo_data/ # Database storage
β βββ π qdrant_storage/ # Vector database
β
βββ π deployment/ # π Deployment configs
βββ π terraform/ # π©οΈ Infrastructure as Code
βββ π reports/ # π System reports
βββ docker-compose.yml # π³ Container orchestration
βββ Makefile # π οΈ Commands
βββ README.md # π Documentation
| Component | Purpose | Key Features |
|---|---|---|
| brain.py | AI reasoning engine | Query analysis, tool selection, response generation |
| legal_chat.py | WebSocket API | Real-time chat, conversation management |
| App.jsx | Frontend app | Chat interface, message handling |
| useChat.js | Chat logic | WebSocket management, state handling |
| Copilot System | DevOps automation | K8s management, AI-powered operations |
# Docker development (recommended)
make dev-up
# Local development
cd src/app
pip install -r requirements.txt
uvicorn main:app --reload --port 8000cd src/legal-chatbot-fe
npm install
npm run dev # Development server
npm run build # Production build# Start copilot system
cd lexiops-copilot
./scripts/run.sh
# Test copilot functionality
python test/test_fastapi_mcp.py# Required in .env file
OPENAI_API_KEY=your_openai_api_key_here
MONGODB_URL=mongodb://admin:password123@localhost:27017/legaldb?authSource=admin
REDIS_URL=redis://localhost:6379/0
QDRANT_URL=http://localhost:6333# Local deployment
docker-compose up --build -d
# Production deployment
docker-compose -f docker-compose.yml --env-file .env.production up -d
# Scale workers
docker-compose up --scale celery-worker-rag=3 -d# Deploy with Helm
helmfile -e development apply # Development
helmfile -e production apply # Production
# Deploy copilot MCP server
kubectl apply -f lexiops-copilot/k8s/mcp-k8s-deployment.yaml
# Monitor deployment
kubectl get pods -n legal-retrieval-prodmake quick-start # Quick setup and start
make health-check # System health verification
make test # Run test suite
make clean-all # Complete cleanup
make help # Show all commands- Smoke Tests: Quick validation (2-3 minutes)
- API Tests: Endpoint validation
- Integration Tests: Service interaction
- Performance Tests: Load and stress testing
# Quick smoke tests
make test-smoke
# Full test suite
make test
# Docker-isolated testing
./tests/run_docker_tests.sh --command test --test-type smoke
# Copilot system tests
cd lexiops-copilot
python test/test_fastapi_mcp.pyFor detailed testing: tests/DOCKER_TESTING_GUIDE.md
# API Configuration
FASTAPI_HOST=0.0.0.0
FASTAPI_PORT=8000
DEBUG=true
# AI Configuration
OPENAI_MODEL=gpt-4o-mini
EMBEDDING_MODEL=text-embedding-3-small
VECTOR_SIZE=1536
# Worker Configuration
CELERY_CONCURRENCY=2
CELERY_BROKER_URL=redis://localhost:6379/3The system supports horizontal scaling:
- RAG Workers: CPU-intensive AI processing
- Embed Workers: Vector embedding generation
- Retrieval Workers: Web search and content retrieval
- Frontend: React chat interface (port 3000)
- Backend: FastAPI with WebSocket (port 8000)
- Workers: Celery for RAG processing
- Databases: MongoDB + Redis + Qdrant
- Tier 1: FastAPI main server (lexiops-copilot/agent/main.py)
- Tier 2: MCP client adapter (langchain_mcp_adapters)
- Tier 3: MCP tools server (Kubernetes deployment)
- Celery Monitor: http://localhost:5555 - Task monitoring
- API Health: http://localhost:8000/health - System status
- Qdrant Dashboard: http://localhost:6333/dashboard - Vector DB
- Response Time: < 2s simple queries, < 5s complex queries
- Throughput: 100+ concurrent users, 50+ RPS
- Resource Usage: 2-4GB RAM, 2-4 CPU cores
# Check service status
docker-compose ps
# View logs
docker-compose logs -f backend-api
# System health check
./scripts/system-check.shLexiOps includes enterprise-grade features:
β
Legal AI System - RAG-powered legal information retrieval
β
DevOps Copilot - AI-powered Kubernetes cluster management
β
Scalable Architecture - Microservices with auto-scaling
β
Real-time Chat - WebSocket-powered interface
β
Comprehensive Testing - Full test coverage
β
DevOps Ready - Docker, Kubernetes, CI/CD
β
Performance Optimized - Sub-second response times
- π Reports:
reports/OPTIMIZATION_REPORT.md - π Deployment:
deployment/configs - π Documentation:
docs/guides - π€ Copilot Docs:
lexiops-copilot/docs
LexiOps - Transforming Legal Information Access with AI ποΈπ€
Built with β€οΈ using FastAPI, React, OpenAI, Docker, and modern DevOps practices