Skip to content

Add ocr-doc-api scaffold (Rust API + GCP Terraform/Terragrunt) - #17

Draft
pollenjp wants to merge 1 commit into
mainfrom
claude/rest-api-file-upload-0zxDr
Draft

Add ocr-doc-api scaffold (Rust API + GCP Terraform/Terragrunt)#17
pollenjp wants to merge 1 commit into
mainfrom
claude/rest-api-file-upload-0zxDr

Conversation

@pollenjp

@pollenjp pollenjp commented May 7, 2026

Copy link
Copy Markdown
Member

Summary

Scaffolds a document OCR REST API under ocr-doc-api-2026-05-07/.

  • API (api/) — Rust + axum on Cloud Run. Endpoints:
    • POST /v1/jobs (multipart: file, engine, formats)
    • GET /v1/jobs/{id} (status JSON)
    • GET /v1/jobs/{id}/{format} (json|csv|html|md|pdf, streamed from GCS)
    • GET /healthz
    • On upload, the API stores the source in the input GCS bucket, writes an
      initial status.json to the output bucket, and publishes a JobMessage
      to Pub/Sub.
  • Workers (workers/) — Cloud Run Job containers per OCR engine:
    • yomitoku/ shells out to the yomitoku CLI.
    • tesseract/ runs tesseract and renders json/csv/md/html(hOCR)/searchable-pdf.
    • The engine is selected per request, so adding a new backend = new image + Terragrunt env.
  • Infra (infra/) — Terraform modules + Terragrunt envs (GCP):
    • Modules: storage, pubsub, artifact_registry, iam, api_service, worker_job.
    • live/dev/ wires storage → pubsub → IAM → AR → API/workers with explicit dependency blocks.

Architecture

client → Cloud Run (Rust API) → GCS input + Pub/Sub
                                           ↓ Eventarc
                                Cloud Run Job (yomitoku|tesseract)
                                           ↓
                                   GCS output (json/csv/html/md/pdf)
client ← Cloud Run (streams from GCS) ← GET /v1/jobs/{id}/{format}

Test plan

  • cargo check / cargo build --release in api/
  • terragrunt run-all init && plan in infra/live/dev/ against a real project
  • Build and push api, worker-yomitoku, worker-tesseract images to Artifact Registry
  • End-to-end: POST /v1/jobs with a sample PDF, poll status, GET each format
  • Confirm Eventarc trigger destination — see infra/README.md "Notes / TODO" (Eventarc-to-Job needs a shim or the GA cloud_run_job destination)

https://claude.ai/code/session_01EioxbNVnmj9q3se6vUT1Z5


Generated by Claude Code

Scaffold a document OCR REST API: a Rust/axum service on Cloud Run accepts
image/PDF uploads, persists them to GCS, and publishes jobs to Pub/Sub for
yomitoku or tesseract Cloud Run Job workers to render json/csv/html/md/pdf
results back to GCS. Infra is split into reusable Terraform modules wired by
Terragrunt envs.

https://claude.ai/code/session_01EioxbNVnmj9q3se6vUT1Z5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants