Skip to content

OCR V3

OCR V3 is RAGA's PDF-to-Markdown OCR service, built on Python + FastAPI. It accepts a PDF file (upload or URL) and proxies the actual OCR work to an external engine (cloud or local) — the service no longer runs an OCR engine itself. Once the OCR result comes back, the service takes over storing the source PDF in MinIO, indexing the extracted text in Elasticsearch, and automatically triggering Summarize. It's used by API Tarantula to process documents uploaded by users.

Unlike other synchronous services, OCR V3 uses an in-memory queue with a single worker thread — large/slow OCR requests are processed in the background under a task_id, without blocking subsequent requests.

Tech Stack

ComponentTechnology
RuntimePython 3.10/3.11
FrameworkFastAPI + uvicorn
OCR ProcessingProxied to an external OCR engine (cloud/local) over HTTP
Object StorageMinIO
Search / IndexElasticsearch
Summarize IntegrationHTTP client to an external Summarize service
Secret Managementinfisical_sdk (Python)

Full environment variable, endpoint, and pipeline diagram details are on the Technical page.

How It Works

  1. The client (API Tarantula) sends POST /api/v1/pdfs — the PDF file/URL is placed on an in-memory queue, and the service immediately replies with a task_id (status pending).
  2. A single worker thread pulls tasks off the queue serially, then proxies the file/URL to an external OCR engine (CLOUD_PROCESSING_ENDPOINT or LOCAL_PROCESSING_ENDPOINT, depending on the processing parameter), polling the upstream task's status until it finishes.
  3. Once the OCR result (content_list + md_content_list) is downloaded, the source PDF (if it came from an upload/merge) is uploaded to MinIO, and the extracted text is indexed into Elasticsearch in chunks (5 pages per chunk).
  4. Summarize is triggered automatically in the background against the OCR result — the summary and per-chunk summaries are saved back into Elasticsearch, without blocking completion of the OCR task.
  5. The client polls GET /api/v1/tasks/{task_id}/status to track progress, then retrieves the result via GET /api/v1/pdfs/{id}.

OCR Modes

Mode (type_ocr)Description
ekstrak_only (default)Text extraction only, no image analysis
representasiText + image descriptions, image count capped by representasi_count

This mode is only forwarded as a parameter to the external OCR engine — the actual OCR logic runs on that engine, not inside OCR V3.

Summary

OCR V3 now acts as an orchestration layer: it proxies PDF processing to an external OCR engine (cloud/local), then handles storage (MinIO), indexing (Elasticsearch), and automatic document summarization (Summarize). Built for heavy workloads via a single-worker, in-memory queue model — clients don't wait for the request to finish synchronously; they poll status via task_id until the result is ready.