Skip to content

softdevcan/langorch

Repository files navigation

LangOrch

Multi-Tenant RAG Platform with Async Operations

πŸš€ Production-ready, multi-tenant RAG orchestration platform with background task processing

License Python Next.js Version

🎯 About LangOrch

LangOrch is a multi-tenant SaaS platform for Retrieval-Augmented Generation (RAG) with enterprise-grade features:

  • βœ… Production-Ready v0.3.0: Async operations, smart caching, timeout-free processing
  • 🏒 Multi-Tenant Architecture: Complete data isolation per tenant
  • πŸ€– Multi-Provider LLM: OpenAI, Anthropic, Ollama support via LiteLLM
  • πŸ“Š Vector Search: Qdrant integration for semantic document search
  • πŸ” Enterprise Security: HashiCorp Vault, JWT auth, tenant isolation
  • ⚑ Background Processing: No timeouts on long-running operations (10+ minutes)

✨ Current Features (v0.3.0)

Document RAG Operations

  • Summarize: Generate concise document summaries with smart caching
  • Ask: Question-answering with RAG (vector search + LLM)
  • Transform: Document transformation (translate, format, extract, etc.)

Core Capabilities

  • Async Background Tasks: All LLM operations run in background with polling
  • Smart Summary Caching: Reuse existing summaries, optional force regeneration
  • Multi-Provider Embedding: OpenAI, Google Gemini, Anthropic Claude, Ollama
  • Dynamic Embedding Dimensions: Support for different embedding models
  • Tenant Configuration: Per-tenant LLM and embedding provider settings
  • Document Management: Upload, process, chunk, and embed PDF/DOCX files

πŸ—οΈ Tech Stack

Backend

  • FastAPI - High-performance async web framework
  • LiteLLM - Unified LLM API (OpenAI, Anthropic, Ollama)
  • PostgreSQL 16+ - Primary database
  • Qdrant - Vector database for semantic search
  • Redis 7+ - Caching and session management
  • HashiCorp Vault - Secure secret management
  • SQLAlchemy + Alembic - ORM and migrations
  • Pydantic - Data validation
  • structlog - Structured logging

Frontend

  • Next.js 14 (App Router)
  • React with TypeScript
  • shadcn/ui + TailwindCSS
  • Axios - API client
  • Sonner - Toast notifications

Infrastructure

  • Docker & Docker Compose
  • Nginx (optional reverse proxy)

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Python 3.11+
  • Node.js 18+
  • Git

Installation

# 1. Clone the repository
git clone <repository-url>
cd langorch

# 2. Create environment file
cp .env.example .env
# Edit .env with your settings

# 3. Start infrastructure services
docker-compose up -d

# 4. Backend setup
cd backend
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

# Run database migrations
alembic upgrade head

# Start backend
uvicorn app.main:app --reload

# 5. Frontend setup (new terminal)
cd frontend
npm install
npm run dev

Access Points

πŸ“š Version Roadmap

Version Status Description Release Date
v0.3.0 βœ… Released Async RAG operations with smart caching 2026-01-08
v0.4.0 🚧 In Development LangGraph multi-agent workflows, streaming Q1 2026
v1.0.0 πŸ“‹ Planned Production-ready, full observability Q2 2026

v0.3.0 - Current Release

What's New:

  • Background task processing for all LLM operations (Summarize, Ask, Transform)
  • Smart summary caching with force regeneration option
  • Extended timeout support (10 minutes) for long operations
  • Multi-provider embedding support (OpenAI, Gemini, Claude, Ollama)
  • Dynamic embedding dimensions
  • Latest summary retrieval endpoint
  • Improved error handling and logging

Bug Fixes:

  • Fixed transform operation timeout issue
  • Fixed duplicate LLM operation records
  • Improved polling mechanism

View Full Changelog

v0.4.0 - Coming Soon

Planned Features:

  • LangGraph integration for multi-agent workflows
  • LangSmith observability and monitoring
  • Streaming responses via Server-Sent Events (SSE)
  • Advanced RAG: reranking, hybrid search, multi-query
  • Conversation history and memory
  • Agent-based architecture

View v0.4 Development Prompt

v1.0.0 - Production Ready

Target Features:

  • Complete observability stack (Prometheus, Grafana, LangSmith)
  • Kubernetes deployment manifests
  • Production-grade monitoring and alerting
  • Performance optimizations
  • Comprehensive documentation
  • Security audit and hardening

πŸ›οΈ Architecture Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    FRONTEND LAYER                        β”‚
β”‚                Next.js 14 + shadcn/ui                    β”‚
β”‚         (Document UI, RAG Operations, Settings)          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   BACKEND LAYER                          β”‚
β”‚              FastAPI + Background Tasks                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚ Tenant Isolation (JWT + Middleware)             β”‚    β”‚
β”‚  β”‚ β”œβ”€β”€ Auth Service (JWT, Password Hashing)        β”‚    β”‚
β”‚  β”‚ β”œβ”€β”€ Document Service (Upload, Processing)       β”‚    β”‚
β”‚  β”‚ β”œβ”€β”€ Embedding Service (Multi-provider)          β”‚    β”‚
β”‚  β”‚ β”œβ”€β”€ RAG Service (Summarize, Ask, Transform)     β”‚    β”‚
β”‚  β”‚ └── LLM Service (LiteLLM Integration)           β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                 β”‚                   β”‚
        ↓                 ↓                   ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  PostgreSQL  β”‚  β”‚    Redis     β”‚  β”‚    Qdrant    β”‚
β”‚  (Main DB)   β”‚  β”‚  (Sessions)  β”‚  β”‚  (Vectors)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚
        ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Vault     β”‚
β”‚  (Secrets)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Security Features

Multi-Tenant Isolation

  • JWT-based authentication
  • Tenant-scoped database queries
  • API-level tenant filtering
  • Session isolation via Redis

Secret Management

  • HashiCorp Vault for API keys
  • Tenant-specific secret storage
  • No secrets in code or .env files
  • Automatic secret rotation support

Data Security

  • Encrypted connections (TLS/SSL ready)
  • Secure password hashing (pwdlib with Argon2)
  • Audit logging for critical operations
  • GDPR-compliant data handling

πŸ“– API Documentation

RAG Operations

Summarize Document

POST /api/v1/llm/documents/summarize
{
  "document_id": "uuid",
  "model": "llama3.2",  # optional
  "max_length": 500,     # optional
  "force": false         # optional
}

Ask Question

POST /api/v1/llm/documents/ask
{
  "document_id": "uuid",
  "question": "What is this document about?",
  "model": "llama3.2",  # optional
  "max_chunks": 5        # optional
}

Transform Document

POST /api/v1/llm/documents/transform
{
  "document_id": "uuid",
  "instruction": "Translate to Turkish",
  "model": "llama3.2",        # optional
  "output_format": "text"     # text, markdown, json
}

All operations return immediately with an operation_id. Use polling to check status:

GET /api/v1/llm/operations/{operation_id}

Full API Documentation

πŸ§ͺ Testing

# Backend tests
cd backend
pytest tests/ -v --cov=app

# Frontend tests
cd frontend
npm run test
npm run type-check

# Linting
black backend/app
isort backend/app
flake8 backend/app

πŸ“Š Project Structure

langorch/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py                    # FastAPI application
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── v1/endpoints/          # API endpoints
β”‚   β”‚   β”œβ”€β”€ core/                      # Config, database, vault
β”‚   β”‚   β”œβ”€β”€ models/                    # SQLAlchemy models
β”‚   β”‚   β”œβ”€β”€ schemas/                   # Pydantic schemas
β”‚   β”‚   └── services/                  # Business logic
β”‚   β”œβ”€β”€ alembic/                       # Database migrations
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/                           # Next.js app router
β”‚   β”œβ”€β”€ components/                    # React components
β”‚   β”œβ”€β”€ lib/                           # API client, utilities
β”‚   └── package.json
β”œβ”€β”€ docs/                              # Documentation
β”œβ”€β”€ .github/                           # GitHub workflows
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ VERSION                            # Current version
β”œβ”€β”€ CHANGELOG.md                       # Version history
└── README.md

🀝 Contributing

We follow Conventional Commits:

feat: add new feature
fix: bug fix
docs: documentation changes
refactor: code refactoring
test: adding or updating tests
chore: maintenance tasks

Git Workflow

See Branching Strategy for details.

# Create feature branch
git checkout develop/v0.4
git checkout -b feature/my-feature

# Commit changes
git add .
git commit -m "feat: add amazing feature"

# Push and create PR
git push origin feature/my-feature

πŸ“ License

[License information to be added]

πŸ‘₯ Contact

[Contact information to be added]

πŸ™ Acknowledgments

Built with these amazing open-source projects:


Current Status: v0.3.0 - Production ready for basic RAG operations

Next Up: v0.4.0 - LangGraph integration and streaming responses

For detailed development information, see Development Phases

About

Language Workflow Orchestration Platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors