Handwritten Document OCR Platform
FastAPI · Google Vertex AI · Cloud Run · GCS · Firestore

The Challenge
The Approach
europe-west region. The application creates a job record in Cloud Firestore with an initial status of pending, then begins processing. The document is binarized, margins are removed, and the content is sliced into smaller tiles to optimize token consumption. Each tile is sent to Gemini 2.5 Flash on Vertex AI in the Europe West region. If Vertex AI returns a rate limit error, the router falls back to Gemini 3.1 Pro via OpenRouter. As processing progresses, the Firestore job status updates from processing to complete or failed. The final transcribed text is written as a .txt file to the GCS output bucket, organized by date and job identifier. Cloud Monitoring collects custom metrics for API latency, token usage, and error rates.System Architecture
Cloud Infrastructure
GCP Infrastructure
Architecture for the Handwritten Document OCR Platform. Click a node to view its configuration details.
Interactive Demo
Walk through the system design and data flow for this project step by step.
How the Pipeline Works
Step 1Document Input
The system receives a scanned image of a handwritten historical document. These manuscripts often suffer from ink fading, paper degradation, water damage, and non-standard cursive styles. Traditional OCR engines cannot handle these conditions because they rely on clean, printed character shapes.
Supported formats include high resolution TIFF and JPEG scans. The API accepts single pages or batched document sets through the FastAPI endpoint.
Overview
.txt files in a separate GCS output bucket. Cloud Firestore maintains real-time status tracking for each processing job with states like pending, processing, complete, and failed.Business Impact
Technical Highlights
- Multi model fallback routing between OpenRouter and Vertex AI
- GDPR compliant data processing in the Europe West region
- Token optimization through image tiling and prompt structuring
- FastAPI backend with asynchronous request handling
- GCS input and output buckets for document and transcription storage
- Firestore real-time job status tracking with state management
- Serverless deployment on Cloud Run with 2 vCPU and 2GB memory limits
- GCP Cloud Monitoring dashboard for latency and error tracking
Want results like this for your infrastructure?
I specialize in taking complex AI pipelines and cloud setups from concept to high-availability production. Let's discuss how to optimize your workloads, secure your environment, and reduce cloud costs.