ocr/
Backend proxy for the Python OCR microservice. Handles authentication, tier gating, file validation, and request forwarding for VIN extraction, fuel receipt scanning, and maintenance manual extraction.
Files
| File |
What |
When to read |
README.md |
Feature documentation with architecture diagrams |
Understanding OCR proxy, data flows |
index.ts |
Feature barrel export |
Importing OCR services |
Subdirectories
| Directory |
What |
When to read |
api/ |
HTTP endpoints, routes, request validation |
API changes, adding endpoints |
domain/ |
Business logic, TypeScript types |
Core OCR proxy logic, type definitions |
external/ |
HTTP client to Python OCR service |
OCR service integration, error handling |
tests/ |
Unit tests for receipt and manual extraction |
Test changes, adding test coverage |
api/
| File |
What |
When to read |
ocr.controller.ts |
Request handlers for all OCR endpoints (extract, extractVin, extractReceipt, extractManual, submitJob, getJobStatus) |
Adding/modifying endpoint behavior |
ocr.routes.ts |
Fastify route registration with auth and tier guard preHandlers |
Route configuration, middleware changes |
ocr.validation.ts |
Request/response type definitions for route schemas |
Changing request/response shapes |
domain/
| File |
What |
When to read |
ocr.service.ts |
Business logic layer: file validation, size limits (10MB sync, 200MB async), content type checks, service delegation |
Core logic changes, validation rules |
ocr.types.ts |
TypeScript types: OcrResponse, VinExtractionResponse, ReceiptExtractionResponse, ManualExtractionResult, JobResponse, ManualJobResponse |
Type changes, adding new response shapes |
external/
| File |
What |
When to read |
ocr-client.ts |
HTTP client to mvp-ocr Python service (extract, extractVin, extractReceipt, decodeVin, submitJob, submitManualJob, getJobStatus, isHealthy) |
OCR service communication, error handling |
tests/
| File |
What |
When to read |
unit/ocr-receipt.test.ts |
Receipt extraction tests with mock client |
Receipt flow changes |
unit/ocr-manual.test.ts |
Manual PDF extraction tests |
Manual extraction flow changes |