Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

OmniDoc AI - Enterprise OCR Document Intelligence Platform

Developed by Hassan Khan
πŸ“§ Email: hassanaiengineer@gmail.com
πŸ“ž Phone: +923131569393 πŸ”— LinkedIn: https://www.linkedin.com/in/hassan-khan-4961b722b/
πŸ”— Upwork: https://www.upwork.com/freelancers/~016ca6a619d9683838

Overview

OmniDoc AI is an enterprise-grade OCR-first document intelligence platform that transforms messy scanned documents into clean, structured, AI-ready knowledge using Gemini 2.0 Flash and RAG (Retrieval-Augmented Generation).

Key Features

πŸ” OCR-First Architecture

  • Column-aware extraction with layout preservation
  • Auto-detect digital vs scanned pages
  • Pre-processing: deskew, denoise, contrast normalization
  • Support for PDF, PNG, JPG, JPEG, TIFF, BMP
  • Page-level confidence scoring

✨ AI-Powered Text Cleaning

  • Simple Cleaner (Free): NLP-based preprocessing
    • Unicode normalization
    • OCR error correction
    • Whitespace & punctuation fixes
    • Broken word merging
  • Advanced Cleaner (Gemini 2.0 Flash)
    • Context-aware corrections
    • Grammar & structure improvement
    • No hallucination mode

πŸ’¬ Enterprise RAG

  • Document Q&A with citations
  • OCR-aware chunking
  • Semantic search with relevance scoring
  • Multi-document support
  • Source references

🏒 Enterprise Features

  • User-owned API keys (secure, no platform cost)
  • Document isolation per project
  • Multiple output formats (TXT, Markdown, JSON)
  • Batch processing support

Tech Stack

Backend

  • FastAPI (Python)
  • PyMuPDF, OpenCV, Tesseract (OCR)
  • Google Gemini 2.0 Flash (AI)
  • ChromaDB (Vector Store)

Frontend

  • Next.js 14
  • React 18
  • TypeScript
  • Tailwind CSS
  • Framer Motion

Getting Started

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Tesseract OCR
  • Poppler (for PDF processing)

Backend Setup

cd backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Run the server
python -m uvicorn app.main:app --reload --port 8000

Or use the provided script:

chmod +x run.sh
./run.sh

Frontend Setup

cd frontend

# Install dependencies
npm install

# Run development server
npm run dev

The frontend will be available at http://localhost:3000

System Dependencies

Ubuntu/Debian

sudo apt-get update
sudo apt-get install tesseract-ocr poppler-utils

macOS

brew install tesseract poppler

Windows

API Endpoints

Documents

  • POST /api/documents/upload - Upload a document
  • POST /api/documents/upload-multiple - Upload multiple documents
  • GET /api/documents/ - List all documents
  • GET /api/documents/{id} - Get document details
  • DELETE /api/documents/{id} - Delete a document
  • GET /api/documents/{id}/download - Download document text

OCR

  • POST /api/ocr/process/{id} - Process document with OCR
  • POST /api/ocr/process-batch - Batch OCR processing
  • POST /api/ocr/reprocess/{id} - Reprocess document
  • GET /api/ocr/status/{id} - Get OCR status

Cleaning

  • POST /api/cleaning/simple/{id} - Simple NLP cleaning
  • POST /api/cleaning/advanced/{id} - AI-powered cleaning (requires Gemini API key)
  • GET /api/cleaning/preview/{id} - Preview cleaning results

RAG

  • POST /api/rag/index/{id} - Index document for RAG
  • POST /api/rag/index-batch - Batch indexing
  • POST /api/rag/query - Query documents
  • DELETE /api/rag/index/{id} - Remove from index

Settings

  • GET /api/settings/ - Get settings
  • POST /api/settings/ - Update settings
  • POST /api/settings/validate-gemini-key - Validate API key

Configuration

Environment Variables

Create a .env file in the backend directory:

# Optional: Set default API key (not recommended for production)
GEMINI_API_KEY=your_key_here

For the frontend, create .env.local:

NEXT_PUBLIC_API_URL=http://localhost:8000

Project Structure

omnidoc-ai/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py           # FastAPI application
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”‚   └── schemas.py    # Pydantic models
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ ocr_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ cleaning_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ gemini_service.py
β”‚   β”‚   β”‚   β”œβ”€β”€ rag_service.py
β”‚   β”‚   β”‚   └── document_store.py
β”‚   β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”‚   β”œβ”€β”€ documents.py
β”‚   β”‚   β”‚   β”œβ”€β”€ ocr.py
β”‚   β”‚   β”‚   β”œβ”€β”€ cleaning.py
β”‚   β”‚   β”‚   β”œβ”€β”€ rag.py
β”‚   β”‚   β”‚   └── settings.py
β”‚   β”‚   └── utils/
β”‚   β”œβ”€β”€ uploads/              # Uploaded files
β”‚   β”œβ”€β”€ outputs/              # Processed outputs
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── run.sh
└── frontend/
    β”œβ”€β”€ src/
    β”‚   β”œβ”€β”€ app/
    β”‚   β”‚   β”œβ”€β”€ page.tsx      # Main dashboard
    β”‚   β”‚   β”œβ”€β”€ layout.tsx
    β”‚   β”‚   └── globals.css
    β”‚   β”œβ”€β”€ components/
    β”‚   β”‚   β”œβ”€β”€ Header.tsx
    β”‚   β”‚   β”œβ”€β”€ FileUploader.tsx
    β”‚   β”‚   β”œβ”€β”€ DocumentList.tsx
    β”‚   β”‚   β”œβ”€β”€ DocumentViewer.tsx
    β”‚   β”‚   β”œβ”€β”€ CleaningModal.tsx
    β”‚   β”‚   β”œβ”€β”€ RAGChat.tsx
    β”‚   β”‚   β”œβ”€β”€ SettingsModal.tsx
    β”‚   β”‚   β”œβ”€β”€ ProcessingStatus.tsx
    β”‚   β”‚   └── StatsCard.tsx
    β”‚   └── lib/
    β”‚       └── api.ts        # API client
    β”œβ”€β”€ package.json
    β”œβ”€β”€ tailwind.config.js
    └── next.config.js

Usage Guide

  1. Upload Documents: Drag and drop or click to upload PDFs/images
  2. OCR Processing: Documents are automatically processed after upload
  3. Clean Text:
    • Click "Clean" on any document
    • Choose Simple (free) or Advanced (AI-powered)
    • Download the cleaned text
  4. RAG Chat:
    • Configure your Gemini API key in Settings
    • Click "Index RAG" on documents
    • Go to RAG Chat tab
    • Ask questions about your documents

Security Notes

  • API keys are stored locally in your browser
  • Keys are sent directly to Google's servers
  • No keys are stored on our backend
  • Document data is stored locally during your session

License

MIT License - See LICENSE file for details

Support

For support or feature requests, please contact:


Note - If you want frontend folder send email to me :)

About

OmniDoc AI is an enterprise-grade OCR-first document intelligence platform that transforms messy scanned documents into clean, structured, AI-ready knowledge.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages