# documents/ Document management UI with maintenance manual extraction. Handles file uploads, document viewing, and PDF-based maintenance schedule extraction via Gemini. ## Subdirectories | Directory | What | When to read | | --------- | ---- | ------------ | | `api/` | Document API endpoints | API integration | | `components/` | Document forms, dialogs, preview, metadata display | UI changes | | `hooks/` | Document CRUD, manual extraction, upload progress | Business logic | | `mobile/` | Mobile-specific document layout | Mobile UI | | `pages/` | DocumentsPage, DocumentDetailPage | Page layout | | `types/` | TypeScript type definitions | Type changes | | `utils/` | Utility functions (vehicle label formatting) | Helper logic | ## Key Files | File | What | When to read | | ---- | ---- | ------------ | | `hooks/useManualExtraction.ts` | Manual extraction orchestration: submit PDF to /ocr/extract/manual, poll job status via /ocr/jobs/:jobId, return extraction results | Manual extraction flow, job polling | | `components/DocumentForm.tsx` | Document metadata form with "Scan for Maintenance Schedule" checkbox (Pro tier) | Document upload, extraction trigger | | `components/AddDocumentDialog.tsx` | Add document dialog integrating DocumentForm, upload progress, and manual extraction trigger | Document creation flow | | `hooks/useDocuments.ts` | CRUD operations for documents | Document data management | | `hooks/useUploadWithProgress.ts` | File upload with progress tracking | Upload UI | | `components/DocumentPreview.tsx` | Document viewer/preview | Document display | | `components/EditDocumentDialog.tsx` | Edit document metadata | Document editing | | `types/documents.types.ts` | DocumentType, DocumentRecord, CreateDocumentRequest | Type definitions | ## Manual Extraction Flow ``` DocumentForm ("Scan for Maintenance Schedule" checkbox, Pro tier) | v AddDocumentDialog -> useManualExtraction.submit(file, vehicleId) | v POST /api/ocr/extract/manual (async job) | v Poll GET /api/ocr/jobs/:jobId (progress: 10% -> 50% -> 95% -> 100%) | v Job completed -> MaintenanceScheduleReviewScreen (in maintenance/ feature) | v User selects/edits items -> Batch create maintenance schedules ```