Skip to content

Repository files navigation

LexiOps - Intelligent Legal AI Platform

Advanced AI-powered legal information retrieval and DevOps automation platform with RAG (Retrieval-Augmented Generation) and MCP (Model Context Protocol)

GitHub Stars GitHub Forks Live Demo Kubernetes License Profile Views


πŸ—οΈ System Architecture

πŸ“Š Complete System Overview

LexiOps Complete System Architecture

πŸ€– DevOps Copilot Architecture

LexiOps DevOps Copilot

🌟 Application Architecture

Application

πŸ“‹ Table of Contents


🎯 Overview

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.

🌟 Dual Platform Architecture

πŸ›οΈ Legal AI Platform

  • 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

πŸ€– DevOps AI Copilot

  • 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

πŸš€ Key Innovations

  • 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

🏷️ Technology Stack

AI & Machine Learning: OpenAI RAG AI Agent MCP Tools LangGraph

Backend & Infrastructure: FastAPI React MongoDB Redis Docker Kubernetes


πŸš€ Quick Start

Prerequisites

  • Docker 20.10+ and Docker Compose 2.0+
  • OpenAI API Key for AI functionality

Installation

# 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

Access Points

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

πŸ“ Project Structure

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

Core Components

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

πŸ› οΈ Development

Backend Development

# Docker development (recommended)
make dev-up

# Local development
cd src/app
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

Frontend Development

cd src/legal-chatbot-fe
npm install
npm run dev          # Development server
npm run build        # Production build

DevOps Copilot

# Start copilot system
cd lexiops-copilot
./scripts/run.sh

# Test copilot functionality
python test/test_fastapi_mcp.py

Environment Setup

# 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

🐳 Deployment

Docker Deployment

# 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

Kubernetes Deployment

# 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-prod

Available Commands

make 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

πŸ§ͺ Testing

Test Categories

  • Smoke Tests: Quick validation (2-3 minutes)
  • API Tests: Endpoint validation
  • Integration Tests: Service interaction
  • Performance Tests: Load and stress testing

Running Tests

# 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.py

For detailed testing: tests/DOCKER_TESTING_GUIDE.md


πŸ”§ Configuration

Core Settings

# 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/3

Service Scaling

The system supports horizontal scaling:

  • RAG Workers: CPU-intensive AI processing
  • Embed Workers: Vector embedding generation
  • Retrieval Workers: Web search and content retrieval

System Architecture

Legal Retrieval System

  • Frontend: React chat interface (port 3000)
  • Backend: FastAPI with WebSocket (port 8000)
  • Workers: Celery for RAG processing
  • Databases: MongoDB + Redis + Qdrant

DevOps Copilot (3-Tier Architecture)

  • 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)

πŸ“Š Monitoring

Dashboards

Performance Metrics

  • Response Time: < 2s simple queries, < 5s complex queries
  • Throughput: 100+ concurrent users, 50+ RPS
  • Resource Usage: 2-4GB RAM, 2-4 CPU cores

Troubleshooting

# Check service status
docker-compose ps

# View logs
docker-compose logs -f backend-api

# System health check
./scripts/system-check.sh

πŸ† Production Ready

LexiOps 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

Additional Resources


LexiOps - Transforming Legal Information Access with AI πŸ›οΈπŸ€–

Built with ❀️ using FastAPI, React, OpenAI, Docker, and modern DevOps practices

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Stars

7 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages