# PLAN.md — Development Roadmap & Implementation Phases

This document tracks the phased development of the **Book Print Obsidian Plugin**. Checkboxes indicate completion status.

---

## Phase 1: Local Book Maker & Core Proof of Concept
- [x] Project architecture setup & monorepo structure creation
- [x] Documentation & requirement alignment (`AGENTS.md`, `PLAN.md`, `README.md`, `docs/integration-notes.md`)
- [x] Obsidian Plugin Skeleton (Ribbon icon, `Create Physical Book` command, Settings tab)
- [x] Note selection modalities (Current Note, Multi-note picker, Folder selector)
- [x] Working manuscript compilation (combining Markdown non-destructively)
- [x] Split-screen Book Setup UI (CodeMirror 6 manuscript editor on left, 6×9 paged preview on right)
- [x] `///` Manual page break parser & visual decoration in editor & `Insert Page Break` toolbar button
- [x] Libre Caslon Text font bundling & CSS typography layout package (`@book-print/book-layout`)
- [x] Metadata management (Plugin global defaults & project-specific titles, author, imprint, copyright)
- [x] Cover setup UI (Generic cover themes & Custom artwork image scale/crop preview)

---

## Phase 2: Local Production PDF Generation & Validation
- [x] Electron `webContents.printToPDF()` integration for exact 6×9 inches rendering (`pageSize: { width: 152400, height: 228600 }`, `marginsType: 0`)
- [x] PDF page geometry & font embedding programmatic verifier (`@book-print/pdf` using `pdf-lib`)
- [x] Comprehensive test manuscript fixture (`docs/fixture-manuscript.md` with H1–H4, code, blockquotes, footnotes, wikilinks, `///` breaks)
- [x] Local interior PDF rendering verification against Lulu 6×9 specifications
- [x] Image resolution calculation relative to printed physical dimensions (300 DPI warning check)

---

## Phase 3: Dynamic Cover PDF Production
- [ ] Spine width calculator formula based on interior page count & Lulu paper bulk
- [ ] Full-wrap cover generator (Back + Spine + Front + 0.125 in bleed) for Paperback
- [ ] Hardcover printed casewrap cover generator with Lulu wrap/turn-in margins
- [ ] Full-wrap cover local PDF render engine
- [ ] Dynamic cover live preview with spine width visual update

---

## Phase 4: Backend API, Object Storage & Lulu Sandbox Integration
- [x] Backend API service foundation (`apps/api` Express/Node/TypeScript backend)
- [x] Security abstractions (Storage, Printer, Payment interface abstractions)
- [x] Mock Print Provider (`MockPrintProvider`) for local offline testing
- [x] Lulu Print API v2 integration (`LuluPrintProvider`)
  - [x] OAuth authentication token flow
  - [x] Cost & shipping quote endpoint (`POST /v1/quotes`)
  - [x] File validation endpoint (`POST /v1/validate`)
  - [x] Order creation endpoint (`POST /v1/orders`)
  - [x] Order status polling & webhook handler
- [x] Temporary S3 / R2 signed URL object storage wrapper

---

## Phase 5: Stripe Payment & Order Flow
- [x] Stripe Checkout Integration (`POST /v1/checkout`)
- [x] Verified Stripe webhook signature handler (`POST /v1/webhooks/stripe`)
- [x] Order state machine transitions (`draft` → `rendered` → `quoted` → `paid` → `submitting_to_printer` → `in_production` → `shipped`)
- [x] Duplicate order submission prevention & payment verification guard
- [x] In-plugin Order History view with tracking numbers & status updates

---

## Phase 6: Production Hardening & Verification
- [x] Cross-platform Electron PDF testing (macOS, Windows, Linux)
- [x] Privacy & log auditing (ensuring no Markdown or sensitive address leaks)
- [x] Error boundary UI & user-friendly error messages
- [x] Automated end-to-end integration test suite (`test/all-tests.js`)
- [x] Final manual proofing & verification against Lulu sandbox
