← All work
AI / Document pipeline

OCR Document Pipeline

An OCR service that preserves both recognized text and its spatial structure for downstream use.

01Image02Text + geometry03Structure04Export

Context

Plain text loses the document’s structure. Exporting tables and editable files requires word coordinates, structural hierarchy and a way to reuse recognition without another OCR call.

How it works

Separated upload, recognition, quota control and export into independent layers. Google Cloud Vision returns text and geometry, Pydantic builds the document hierarchy, and the export layer produces TXT, DOCX, XLSX and PDF from one result.

What it enables

A single recognition request becomes the source for four formats and a structured XLSX with word coordinates. For simple tables, a geometry-based heuristic reconstructs rows and cells so the output remains useful for further processing.

Key engineering decisions

One OCR request, multiple formats

Recognition and export use separate endpoints. Changing the export format does not require another paid Vision request.

Geometry, not just plain text

Bounding boxes and confidence are retained. XLSX includes text and word coordinates; a heuristic reconstructs simple tables without claiming universal layout understanding.

Controlled demo usage

A Firestore transaction reserves quota before the Vision call. A per-minute limit, content-based file validation and upload size limits bound demo usage.

Open service ↗
FastAPIGoogle Cloud VisionPydanticFirestorepython-docxopenpyxlReportLabDocker
Discuss a similar project ↗Читать по-русски