Skip to main content

Universal document parsing engine with OCR, layout analysis, and table extraction

Project description

📄 DocMirror

Universal Industrial-Grade Document Parsing Engine
Extract highly-structured data from any document format with military-grade precision.

PyPI Python License CI


DocMirror is a cutting-edge Python library built for the toughest document parsing environments. Go beyond simple text extraction. DocMirror combines computer vision, topological layout algorithms, and middleware intelligence to deliver pure, structured data and verifiable trust scores from messy, real-world documents.

⚡ The Killer Features

Capability What makes it different?
🛡️ Anti-Forgery & Tamper Detection Integrates Pixel Error Level Analysis (ELA) and Metadata Blacklisting. It doesn't just read documents; it tells you if the document was Photoshopped.
🧠 Topological Divide-and-Conquer Layout Drops naive heuristics and uses spatial clustering (DBSCAN + X-Y Cuts) guided by DocLayout-YOLO to accurately reconstruct reading orders even on dense, multi-column financial reports.
🏦 Bank-Grade CCB Table Repair Native algorithmic immunity against complex table structure anomalies (e.g., China Construction Bank staggered grids) doing what LLMs and basic vision models notoriously fail at.
👁️ Dynamic Multi-Scale OCR RapidOCR core supercharged with dynamic color-slicing and contrast boosting to rescue faded, low-DPI scans.
🧩 Zero-Friction Plugin Architecture Write custom Domain Plugins (BankStatement, Invoice) that magically bind unstructured output to your exact Pydantic entity schemas.

🚀 Quick Start

1. Install (One-Liner)

# Get the engine, PDF vision drivers, and high-performance layout analyzers
pip install "docmirror[all]"

2. Awaken the Engine

Just point perceive_document at an image, PDF, Word doc, or Excel sheet. The L0 Dispatcher automatically infers the format, spins up the correct Adapter, parses the data, applies your middlewares, and returns a unified 4-layer topology.

import asyncio
from docmirror import perceive_document

async def main():
    # One line to process ANY tricky document
    result = await perceive_document("suspicious_bank_statement.pdf")

    print(f"Status: {result.status} | Scene: {result.scene}")
    
    # Check if the document was forged
    if result.provenance.validation.is_forged:
        print(f"⚠️ FORGERY DETECTED: {result.provenance.validation.forgery_reasons}")
    
    # Zero in on extracted entities directly mapped from your plugins
    print(f"Entities: {result.content.entities}")

asyncio.run(main())

Pro-Tip: Prefer the CLI? python3 -m docmirror document.pdf --format json

🏗️ The 4-Layer Architecture

DocMirror abandons monolithic parser designs in favor of a strict, highly observable pipeline. From the raw bytes reading to the final Python properties, every step is rigorously logged and structurally sound.

graph TD
    classDef orchestrator fill:#2b2b2b,stroke:#00f0ff,stroke-width:2px,color:#fff
    classDef adapter fill:#3a3a3a,stroke:#ffa500,stroke-width:2px,color:#fff
    classDef core fill:#444,stroke:#ff0055,stroke-width:2px,color:#fff
    classDef data fill:#1f2937,stroke:#a855f7,stroke-width:2px,color:#fff
    classDef none fill:none,stroke:none

    FILE[[Any Document\nPDF / Image / Excel]]:::none --> DISPATCH
    
    DISPATCH[L0 Dispatcher \n + Redis Cache]:::orchestrator --> ADAPTERS
    
    subgraph "Adapt & Physically Extract"
        ADAPTERS(Format Adapters):::adapter --> CORE{Core Engine \n OCR / Layout / Tables}:::core
        CORE --> BASERESULT[(BaseResult)]:::data
    end
    
    BASERESULT --> ORCHESTRATOR
    
    subgraph "Enhance Pipeline (Middlewares)"
        ORCHESTRATOR[Orchestrator]:::orchestrator --> SCENE[Scene Detection]
        SCENE --> ENTITY[Entity Extraction]
        ENTITY --> VALIDATE[Validation & Trust]
    end
    
    VALIDATE --> BUILDER((Builder)):::orchestrator
    
    BUILDER --> PR[(PerceptionResult \n 4-Layer Output Topology)]:::data

The Output: PerceptionResult

DocMirror guarantees a standardized payload structure regardless of where the data came from.

  • Envelope/Status: success, confidence, timing
  • Content: Plain markdown text, localized geometric blocks (Tables, Paragraphs, Images), and entities.
  • Identity: Domain-resolved logic via Aho-Corasick dictionary matching.
  • Trust: validation_scores, is_forged, and subsystem execution times.

🤝 Community & Support

  • Documentation: Complete API & Guide
  • Bug tracker: GitHub Issues
  • Contribution: We welcome Pull Requests! Make sure to make test (129+ E2E validations) before submitting.

📄 License & Authors

Created by Adam Lin and proudly maintained by ValueMap Global.
Released under the Apache 2.0 License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docmirror-0.4.0.tar.gz (315.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docmirror-0.4.0-py3-none-any.whl (318.4 kB view details)

Uploaded Python 3

File details

Details for the file docmirror-0.4.0.tar.gz.

File metadata

  • Download URL: docmirror-0.4.0.tar.gz
  • Upload date:
  • Size: 315.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for docmirror-0.4.0.tar.gz
Algorithm Hash digest
SHA256 96048baf9d4e939cb4fb7ef9be78149f4a8c8048e039596285afd7517ba81ee6
MD5 2c1250bae4a81588e1ab0dbcaa3d909c
BLAKE2b-256 99dd782d1b68302e331b1dc9ec3ed9d0342fbb7a75ea04dc80c75f6aa6664c00

See more details on using hashes here.

File details

Details for the file docmirror-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: docmirror-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 318.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for docmirror-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 955f1146d304743850ca3317a05f7179fa0fd915b54605968ffe4e23f7cdae50
MD5 631b3f68400993bb1da2a215e01e4175
BLAKE2b-256 a8df7899e0f079f3a1041b766c6f65528db55e777304179f6e70a4cd44031682

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page