Sign inSign up

alokdekadev/docurag

By alokdekadev

Updated about 1 year ago

Document RAG platform: Upload docs, query with AI. React + FastAPI + Ollama in unified container.

Image
API management
Machine learning & AI
0

544

alokdekadev/docurag repository overview

DocuRAG - Complete Document RAG Platform with DSPy Enhancement

🆕 Latest Updates (v1.2.0)

🧠 DSPy Integration - Advanced prompt optimization and structured outputs

  • Query Rewriting - Automatically optimizes queries for better document retrieval
  • Structured Outputs - Guarantees proper formatting (LaTeX, Markdown, JSON, etc.)
  • Answer Verification - Validates responses against source context
  • Multi-Step Reasoning - Chain-of-thought processing for complex queries
  • Format Intelligence - Detects and enforces specific output format requirements

🤖 Multi-Provider LLM Support - Choose from 5 different AI providers:

  • Ollama (Local) - Complete privacy, no API key required
  • OpenAI - GPT-4o, GPT-4-turbo, GPT-3.5-turbo
  • Anthropic - Claude-3.5-Sonnet, Claude-3-Opus, Claude-3-Haiku
  • Google - Gemini-Pro, Gemini-Pro-Vision
  • Groq - Ultra-fast inference with LPU architecture

💬 Enhanced User Experience

  • Chat Persistence - Conversations saved across browser sessions
  • Dynamic Provider Display - Shows current LLM provider and model
  • Session Management - 1-hour tokens with extension warnings
  • Updated Model Support - Removed deprecated models

DocuRAG is a comprehensive document analysis platform that combines React frontend, FastAPI backend, DSPy-enhanced RAG pipeline, and multi-provider LLM integration for intelligent document querying. Upload documents, organize by categories, and query using natural language with complete privacy or cloud AI power.

Features: User authentication, document management, category organization, AI-powered search, DSPy optimization, multi-provider LLM support, and local processing with no external API dependencies required.

Core Concept

Problem: Need intelligent document analysis with flexible AI provider options and reliable formatting
Solution: Complete RAG pipeline with DSPy optimization, multi-provider LLM support, and modern web interface

  1. Upload Step: Support for PDF, TXT, DOCX documents
  2. Process Step: Local embeddings and vector storage with ChromaDB
  3. Enhance Step: DSPy query optimization and structured generation
  4. Query Step: Natural language queries using your choice of AI provider
  5. Result: Private, intelligent document analysis with guaranteed formatting

Quick Start

Prerequisites:
  • Docker and Docker Compose installed
  • At least 4GB RAM available
  • No external API keys required (Ollama works locally)
Setup Instructions:

1. Create .env.prod file:

POSTGRES_DB=docurag
POSTGRES_USER=docurag_user
POSTGRES_PASSWORD=your_secure_password
DATABASE_URL=postgresql://docurag_user:your_secure_password@postgres:5432/docurag
SECRET_KEY=your-super-secret-key-here
ENVIRONMENT=production
CORS_ORIGINS=http://localhost,http://127.0.0.1
OLLAMA_URL=http://ollama:11434
OLLAMA_MODEL=llama3.2:1b

2. Create docker-compose.yml file:

services:
  postgres:
    image: postgres:15-alpine
    container_name: docurag_postgres
    environment:
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - "5432:5432"
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
      interval: 30s
      timeout: 10s
      retries: 3
    restart: unless-stopped

  ollama:
    image: ollama/ollama:latest
    container_name: docurag_ollama
    volumes:
      - ollama_data:/root/.ollama
    ports:
      - "11434:11434"
    environment:
      - OLLAMA_HOST=0.0.0.0
    healthcheck:
      test: ["CMD", "ollama", "list"]
      interval: 30s
      timeout: 10s
      retries: 3
    restart: unless-stopped

  docurag:
    image: alokdekadev/docurag:latest
    container_name: docurag_app
    ports:
      - "80:80"
    environment:
      - DATABASE_URL=${DATABASE_URL}
      - SECRET_KEY=${SECRET_KEY}
      - OLLAMA_URL=${OLLAMA_URL}
      - OLLAMA_MODEL=${OLLAMA_MODEL}
      - ENVIRONMENT=${ENVIRONMENT}
      - CORS_ORIGINS=${CORS_ORIGINS}
    volumes:
      - docurag_uploads:/app/uploads
      - docurag_chroma:/app/chroma_db
    depends_on:
      postgres:
        condition: service_healthy
      ollama:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/health"]
      interval: 30s
      timeout: 10s
      retries: 3
    restart: unless-stopped

volumes:
  postgres_data:
  ollama_data:
  docurag_uploads:
  docurag_chroma:

networks:
  default:
    name: docurag_network

3. Start everything:

docker compose --env-file .env.prod up -d

4. Download the AI model:

docker compose exec ollama ollama pull llama3.2:1b

5. Access the application at http://localhost

What You Get:

  • DSPy-Enhanced RAG: Advanced prompt optimization and structured outputs
  • Multi-Provider AI: Choose from Ollama, OpenAI, Anthropic, Google, or Groq
  • Complete Web Interface: Modern React frontend with responsive design
  • User Management: Secure registration, login, and session management
  • Document Upload: Support for PDF, TXT, DOCX files with category organization
  • AI-Powered Search: Natural language queries with context-aware responses
  • Format Intelligence: Automatic detection and handling of output format requests
  • Chat Persistence: Conversation history preserved across sessions
  • Privacy First: All processing happens locally with Ollama (no external API calls)
  • Production Ready: Health checks, proper logging, and restart policies

Use Cases:

  • Research Analysis: Upload papers and query specific topics with format control
  • Document Management: Organize and search through document collections
  • Knowledge Base: Create searchable repositories with structured outputs
  • Content Discovery: Find relevant information with LaTeX, Markdown formatting
  • Educational Tools: Query textbooks with guaranteed formatting compliance

Architecture:

React Frontend → Nginx Proxy → FastAPI Backend → PostgreSQL Database
                                      ↓              ↓
                              ChromaDB Vector Store → Multi-Provider LLMs
                                      ↓              (Ollama/OpenAI/Anthropic/Google/Groq)
                              DSPy Enhancement Pipeline

Commands:

# Start services
docker compose --env-file .env.prod up -d

# Stop services
docker compose down

# View logs
docker compose logs -f docurag

# Check status
docker compose ps

Access Points:

Requirements:

  • RAM: 4GB minimum, 8GB+ recommended
  • Disk: ~5GB (images + model + data)
  • Ports: 80 (web), 5432 (postgres), 11434 (ollama)
  • Dependencies: No external API keys required (optional for cloud providers)

Components:

  • App Image: alokdekadev/docurag:latest (Unified container with DSPy)
  • Database: postgres:15-alpine
  • LLM Service: ollama/ollama:latest
  • Local Model: llama3.2:1b (~1.3GB)
  • Enhancement: DSPy for prompt optimization and structured outputs

Available Tags:

  • latest: Latest stable version with DSPy (v1.2.0)
  • v1.2.0: DSPy integration and multi-provider support
  • v1.1.0: Multi-provider LLM support
  • v1.0.1: Fixed API connectivity
  • v1.0.0: Initial release

Built With:

React • FastAPI • PostgreSQL • ChromaDB • DSPy • Ollama • OpenAI • Anthropic • Google • Groq • Nginx • Docker

Tag summary

Content type

Image

Digest

sha256:ddb3593f4

Size

888.9 MB

Last updated

about 1 year ago

docker pull alokdekadev/docurag