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.0.tar.gz (6.6 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.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: docu_ocr_engine-0.1.0.tar.gz
  • Upload date:
  • Size: 6.6 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.0.tar.gz
Algorithm Hash digest
SHA256 744a457754a4b200eb6c900b12c90dffe05f75c3f276f99c3f85726ba4c520c4
MD5 a292355835b2ce1db17c7eba9f8eb9fe
BLAKE2b-256 3954fa50c277254ff863f650b10daebda663147dcbc531fae411f423d7319350

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for docu_ocr_engine-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f65d124f68f23788e09b46cb2042ebb056892fa28d0e74b08d2b464dc9c64cf4
MD5 d62ddd4d51b9ec94078148a80f56f1fa
BLAKE2b-256 b4ee3a8ff980835ae4e1cf1025af8a5fddb393dff387097e645ff2ac47ae297c

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