PRD — ocrmd¶
What ocrmd is for and whom it serves: the problem, users, goals and non-goals, current features, requirements, proposed success metrics and open questions.
Product requirements for bamr87/ocrmd, derived from the README, agent docs, config and code in this repo. Anything not stated in those sources is marked TBD; success metrics are proposals.
1. Overview / problem¶
ocrmd turns physical books and loose pages into cross-checked Markdown, plain text and JSON from a webcam, a folder of photos or a PDF, and keeps an inventory of everything scanned. Every page is read twice (local OCR engines and a vision model, Claude by default) and the readings are diffed, flagging disagreements rather than silently picking one.
1.1 Missions¶
ocrmd's direction is to become the ultimate open home for all things document digitization — data, tools, resources and transparency, gathered in one place that anyone can inspect and reuse.
- Provide data, tools, resources and transparency for all stakeholders, archivists, librarians, scholars and digitization practitioners, and the general public. Anyone turning paper into text is a first-class audience. The aim is a shared, inspectable commons: the same readings, the same diffs, and the same inventory for everyone.
- Turn physical books and loose pages into cross-checked Markdown, plain text and JSON, and flag disagreements rather than silently picking a winner. Every page is read twice — local OCR engines and a vision model, Claude by default — from a webcam, a folder of photos or a PDF, so provenance stays visible on the page.
- Keep a searchable inventory of everything scanned, work fully offline when the model pass is deferred, and send only page images off the machine, and only to the configured provider. Accuracy, disagreement markers and local-first operation are the default path, not a later mode.
These missions set the course; they do not claim the work is finished. They serve the PRD goals: accurate transcriptions with visible disagreement, a searchable inventory, an offline OCR-only path, and a tight rule for what may leave the machine.
Requirement
- MR1: Constitution §1 states one direction statement and exactly three numbered missions, and the README and AGENTS.md taglines match that direction and link to constitution §1.
Feature OCRMD-011 traces to requirement MR1.
2. Target users¶
- People digitizing books and documents (e.g. study material) on a Mac
- Developers embedding the pipeline via
ocrmd.api.Library - Downstream systems receiving pages via the destination HTTP contract (e.g. law-ai)
3. Goals and non-goals¶
Goals
- Accurate page transcriptions with visible disagreement markers
- A searchable SQLite inventory across all scanned pages
- Work offline (OCR-only) with the LLM pass deferrable
- Only page images leave the machine, and only to the configured provider
Non-goals
- Cloud hosting / multi-user service: TBD (not described)
- Silent auto-correction of disagreements
4. Core features (current)¶
- CLI: scan, ingest (incl.
--watch), verify (incl. Batches API), review, status, reprocess, delete, build, read, library, search, export, send, etl, ocr-bench, doctor - Local OCR: Apple Vision + RapidOCR voting (Tesseract fallback)
- Vision-model providers: Anthropic (default) and xAI
- Corpus per document (
documents/<slug>/pages/NNNN.md) with rich front matter - Exports: md, txt, json, jsonl; local web UI
- Structured-data ETL pipelines and destinations
Feature catalog¶
Every user-facing capability has a stable id in the feature catalog features/features.yml. Each entry names the PRD requirements it serves (prd:); the trace below is the reverse view.
| ID | Feature | Status | Where | Requirements |
|---|---|---|---|---|
| OCRMD-001 | CLI: scan, ingest | shipped | ocrmd/cli.py · README.md |
FR2, FR3 |
| OCRMD-002 | Local OCR: Apple Vision + RapidOCR voting (Tesseract… | shipped | ocrmd/ocr.py · README.md |
NFR1 |
| OCRMD-003 | Vision-model providers: Anthropic (default) and xAI | shipped | ocrmd/llm.py · README.md |
NFR3 |
| OCRMD-004 | Corpus per document | shipped | ocrmd/store.py · README.md |
FR1 |
| OCRMD-005 | Exports: md, txt, json, jsonl | shipped | ocrmd/export · README.md |
TBD |
| OCRMD-006 | Structured-data ETL pipelines and destinations | shipped | ocrmd/etl.py · README.md |
TBD |
| OCRMD-007 | Component identification in figures | partial | ocrmd/pipelines/components.yaml · docs/corpus.md |
TBD |
| OCRMD-008 | On-machine vision pass (local VLM cross-check) | planned | ocrmd/llm.py · PRD.md |
FR4 |
| OCRMD-009 | Structure-aware digital-PDF path | planned | ocrmd/pdfsrc.py · PRD.md |
FR5 |
| OCRMD-010 | Table-structure reconstruction for camera scans | planned | ocrmd/ocr.py · PRD.md |
FR6 |
| OCRMD-011 | Constitution missions | planned | docs/constitution.md · PRD.md |
MR1 |
Requirement → feature trace
| Requirement | Features |
|---|---|
| FR2 | OCRMD-001 |
| FR3 | OCRMD-001 |
| NFR1 | OCRMD-002 |
| NFR3 | OCRMD-003 |
| FR1 | OCRMD-004 |
| TBD | OCRMD-005, OCRMD-006, OCRMD-007 |
| FR4 | OCRMD-008 |
| FR5 | OCRMD-009 |
| FR6 | OCRMD-010 |
| MR1 | OCRMD-011 |
5. Requirements¶
Functional
- FR1: Each page stored as Markdown with front matter and both readings reconciled
- FR2:
ocrmd doctorreports engines, cameras, credentials and DB health - FR3: Config via
ocrmd.toml/ user config /OCRMD_*env / CLI flags (in increasing precedence)
Non-functional
- NFR1: Python ≥ 3.12; macOS primary (Linux/Windows via RapidOCR)
- NFR2: Test suite (~306 checks)
- NFR3: Cost awareness:
doctor --costs, batch mode at reduced price
Functional (planned — cycle 1 day 20 deep dive)
- FR4: An optional on-machine vision-language model can be the second reading, so page images need not leave the machine; the default remains Claude, and disagreements stay visible in the Markdown (OCRMD-008)
- FR5: Born-digital PDFs can take a structure-aware path (layout, tables, reading order via Docling or Marker) that is still reconciled against the PDF text layer, the local engines and the vision pass (OCRMD-009)
- FR6: Ruled tables on camera scans are reconstructed as tables, not flattened prose, before reconcile (OCRMD-010)
6. Success metrics (proposed — not defined in sources)¶
- OCR vs LLM disagreement rate per page
- Pages requiring re-shoot/review
- Cost per page
- Targets: TBD
7. Roadmap / open questions¶
- Supported non-macOS camera capture: TBD
- xAI provider not exercised live (per README)
- Nougat was considered as a math/LaTeX specialist and is not proposed: it is narrow (arXiv-style English papers), slower, and appears unmaintained relative to Docling / olmOCR-class local VLMs
- Open PRs #22 and #26 both add a feature id OCRMD-007 (figure components vs constitution missions). This PR starts new ids at OCRMD-008 so either can keep 007. Rebase if those PRs land first and take 008+
8. Links¶
- README.md · AGENTS.md · CHANGELOG.md · docs/ARCHITECTURE.md
- Backlog of record: GitHub Issues