# OCR Feature

Backend proxy for OCR service communication. Handles authentication, validation, and file streaming to the OCR container.

## API Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/api/ocr/extract` | Synchronous OCR extraction (max 10MB) |
| POST | `/api/ocr/jobs` | Submit async OCR job (max 200MB) |
| GET | `/api/ocr/jobs/:jobId` | Poll async job status |

## Architecture

```
api/
  ocr.controller.ts   # Request handlers
  ocr.routes.ts       # Route registration
  ocr.validation.ts   # Request validation types
domain/
  ocr.service.ts      # Business logic
  ocr.types.ts        # TypeScript types
external/
  ocr-client.ts       # HTTP client to OCR service
```

## Supported File Types

- HEIC (converted server-side)
- JPEG
- PNG
- PDF (first page only)

## Response Format

```typescript
interface OcrResponse {
  success: boolean;
  documentType: 'vin' | 'receipt' | 'manual' | 'unknown';
  rawText: string;
  confidence: number; // 0.0 - 1.0
  extractedFields: Record<string, { value: string; confidence: number }>;
  processingTimeMs: number;
}
```

## Async Job Flow

1. POST `/api/ocr/jobs` with file
2. Receive `{ jobId, status: 'pending' }`
3. Poll GET `/api/ocr/jobs/:jobId`
4. When `status: 'completed'`, result contains OCR data

Jobs expire after 1 hour.
