Skip to main content

Structured OCR extraction engine

Project description

docu-ocr-engine (Self-hosted OCR Engine)

A backend-agnostic, self-hosted OCR engine packaged in Python and shipped as a Docker container. It exposes:

  • HTTP API (FastAPI) for Laravel/Node/any backend
  • CLI for batch/offline OCR
  • Pluggable OCR engines (Tesseract by default) with an interface for future engines

This repo is production-oriented but intentionally minimal so you can extend it.

Features

  • Document processing endpoint (/v1/process) accepting:
    • local file upload (multipart)
    • or remote URL fetch
  • Status tracking (/v1/jobs/{job_id}) with in-memory store (swap to Redis/Postgres easily)
  • Retry-friendly design: idempotency key support
  • OCR engine abstraction (BaseOcrEngine)
  • Output as structured JSON (text + basic metadata)
  • Dockerized for easy self-hosting

Quickstart (Docker)

docker build -t docu-ocr-engine:local -f docker/Dockerfile .
docker run --rm -p 8000:8000 docu-ocr-engine:local

Open:

Quickstart (Local dev)

python -m venv .venv
# Windows: .venv\Scripts\activate
# Linux/macOS: source .venv/bin/activate
pip install -r requirements.txt
uvicorn docu_ocr.api.http:app --host 0.0.0.0 --port 8000 --reload

CLI

python -m docu_ocr.cli.main process --file samples/sample.png --out /tmp/result.json

API usage examples

cURL (upload)

curl -X POST "http://localhost:8000/v1/process" \
  -H "X-Idempotency-Key: demo-123" \
  -F "file=@samples/sample.png" \
  -F "language=eng"

cURL (status)

curl "http://localhost:8000/v1/jobs/<job_id>"

Notes

  • Default OCR engine is Tesseract. The Docker image includes tesseract-ocr.
  • For PDFs, the service uses pdftoppm (poppler-utils) to render pages to images.

Extending

  • Add new engines in docu_ocr/ocr/ and wire via DOCU_OCR_ENGINE=<name>
  • Replace InMemoryJobStore with Redis/Postgres
  • Add webhooks from core/pipeline.py after completion

License

MIT

ocr-medz

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

docu_ocr_engine-0.1.3.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

docu_ocr_engine-0.1.3-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file docu_ocr_engine-0.1.3.tar.gz.

File metadata

  • Download URL: docu_ocr_engine-0.1.3.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for docu_ocr_engine-0.1.3.tar.gz
Algorithm Hash digest
SHA256 81d2257238416ac54df4a498913490e1863c9ad801043c061dfce43a876139f2
MD5 a908309046a3dfda1af9b9583ebd7f2f
BLAKE2b-256 3fdb0e7bd5ab6c602dc3b0609b62794fb8f9f562176efabebf1726fe28a70863

See more details on using hashes here.

File details

Details for the file docu_ocr_engine-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for docu_ocr_engine-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d3b26647953b8661dae1348cab61fb4fe77216ce70ad51315259903e6c0b09dd
MD5 064d179b5c8dfc953e634fe0b0f2346b
BLAKE2b-256 a1eeeddc4d45beb79cf43dec7e7a91dfd34b47f2878ded64b617deabfeb1360c

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