# TODO ## Phase 0: Infrastructure (DONE) - [x] Azure VMs created and configured (jt-ub, jt-win) - [x] Ubuntu VM provisioned (Docker, Go, Python, rclone, zsh, dotfiles) - [x] Directory structures on both VMs (William's layout) - [x] Sample document generator (7 generators, Azure Claude content pools, CJK fonts) - [x] Project restructure: Tracker/Setup.bat + Tracker/Code/{Sync,Tools,Tracker} - [x] Windows rclone sync setup (Setup.bat, Win-Setup.ps1, sync.ps1, config.ini) - rclone auto-download + self-contained install in _LLM/Code/Sync/rclone/ - Password-based SFTP auth (demo), config.ini for server details - .sync_ignore generated on setup (excludes_LLM/, dotfiles, temp/lock files) - 5-minute scheduled task (JingTian-Sync) - Pull-first-then-push: bidirectional files pulled with --update, excluded from push - Bidirectional file list in config.ini (e.g. Admin/Tracker.xlsx) - Daily log rotation in _LLM/Code/Sync/logs/ - [x] Ubuntu VM SSH password auth enabled (Azure cloud-init was blocking it) - [x] Both sync directions tested and working - [x] Old JingTian-Rclone repo archived on Gitea ## Phase 1: Services (Services-First Approach) Rationale: De-risk unknowns (Docling OCR quality, Ollama CPU inference speed) before building orchestrator. ### 1a. Docker Compose + Docling (DONE) - [x] Docker Compose base (Docling service) - [x] Test Docling API with sample PDFs (curl) - [x] Validate OCR quality on real PDFs + generated samples - [x] Test OCR on images (PNG) — works with `force_ocr=true` **Docling API Spec:** - Image: `ds4sd/docling-serve:latest` - Port: `5001` - Endpoint: `POST /v1/convert/file` - Form params: `files=@;type=application/pdf`, `to_formats=md`, `do_ocr=true` - Response: `{ "document": { "md_content": "..." }, "status": "success" }` - OCR engine: `easyocr` (default), supports CJK **OCR Options:** - `do_ocr=true` — enabled by default, processes bitmap content - `force_ocr=true` — use for images/scanned PDFs (replaces existing text with OCR) - `ocr_engine` — `easyocr` (default), `tesseract`, `rapidocr`, `tesserocr`, `ocrmac` - `ocr_lang` — language codes (engine-specific), e.g. `ch_sim` for Simplified Chinese **Tested Formats:** - PDF (Filing Receipt) — extracted text, tables, CJK content ✅ - PNG (Email screenshot) — extracted subject, dates, recipient ✅ - PNG with `ocr_lang=ch_tra` — Traditional Chinese extracted correctly (官藥坊) ✅ **Portable Chinese OCR:** - Auto-downloads `ch_sim` (Simplified) and `ch_tra` (Traditional) models on first run - Models persist in `docling_models` volume - First run takes ~1-2 min extra for model download; subsequent runs instant - Use `ocr_lang=ch_tra` for HK/Taiwan, `ocr_lang=ch_sim` for Mainland China ### 1b. Ollama (DONE) - [x] Add Ollama to Docker Compose (Qwen3-1.7B, CPU mode) - [x] Test structured extraction prompt (curl) - [x] Measure inference time per document (~15-30s on 4 vCPU) - [x] Validate extraction accuracy (deadline, doc type, etc.) **Ollama API Spec:** - Image: `ollama/ollama:0.9.3` - Port: `11434` - Model: `qwen3:1.7b` (~1.4 GB, auto-pulled on startup) - Endpoint: `POST /api/generate` - Body: `{"model":"qwen3:1.7b","prompt":"...","stream":false,"options":{"temperature":0}}` - Response: `{ "response": "" }` (strip `...` tags in post-processing) - Note: Qwen3 includes reasoning by default; `/no_think` leaves empty tags, so strip instead ### 1c. Python Tools Service - [ ] FastAPI + openpyxl service - [ ] Endpoints: read tracker, write/update rows, get column schema - [ ] Test with sample Tracker.xlsx ### 1d. Manual Integration Test - [ ] Chain test: PDF → Docling → Ollama → Tools → Excel updated - [ ] Document any issues / adjustments needed ## Phase 2: Go Orchestrator - [ ] Init Go module in Tracker/ - [ ] Config loading (YAML) - [ ] SQLite schema + migrations (documents, extractions, processing_log) - [ ] Docling HTTP client - [ ] Ollama HTTP client - [ ] Tools service HTTP client - [ ] File watcher (inotify on Ubuntu, 2-min stability check via SHA256 hash) - [ ] State tracker integration (new/changed/skip logic) - [ ] Pipeline orchestrator (read latest Tracker before writing, merge not overwrite) ## Phase 3: Integration + Testing - [ ] End-to-end test (drop file on Windows → syncs to Ubuntu → pipeline → Tracker updates → syncs back) - [ ] Smoke test with real PDFs + generated samples - [ ] README documentation ## Future - [ ] Key-based SFTP auth (replace password for production) - [ ] Windows Go service (replace PowerShell scheduled task) - [ ] File hash (SHA256) change detection on Windows side - [ ] WhatsApp deadline notifications - [ ] Processing retry logic - [ ] Multi-client support - [ ] Smarter bidirectional merge (cell-level, not file-level)