BookForge
BookForge is the EPUB translation engine that keeps the LLM away from your document structure. It parses EPUBs into validated JSON payloads, checkpoints every segment, preserves markup/footnotes/links, and rebuilds valid EPUBs.
I built this to translate books for my partner. It's MIT-licensed in case it's useful to you.
Status
MVP functionality is implemented:
- EPUB inspect, parse, segment, and rebuild
- Plain, marker-safe, and run-preserving translation contracts
- Mock provider for deterministic tests
- OpenAI-compatible provider
- DeepSeek and OpenRouter presets
- Bounded parallel segment translation with
--concurrency - SQLite checkpoint store
- Resume and retry commands
- Status and tail commands for persisted jobs
- Segment-level cache reuse for compatible prior translations
- Static side-by-side review HTML with flag export/import
- QA reports in JSON and Markdown
- Optional LLM QA review pass
- Cost estimates for known provider/model pairs
Install
The binary is:
For development, use:
Commands
Inspect an EPUB:
Estimate tokens and approximate cost:
Translate with OpenRouter:
Translate with the v1 fast preset:
Check provider and storage health:
Translate with DeepSeek:
Use any OpenAI-compatible endpoint:
Resume a job:
Generate a side-by-side review page:
Ingest exported review flags and mark bad translations for retry:
Inspect persisted job state and recent events:
Retry failed or review-needed segments:
Validate a translated EPUB and report:
QA Modes
Translation always runs hard validators before committing a segment. The optional LLM QA pass is controlled with:
off is the default. Reports still include deterministic soft warnings such as changed URLs, changed numbers, suspicious length ratios, model commentary, and repeated text.
Checkpoints And Cache
Runtime state is stored in:
.bookforge/jobs.sqlite
That path is ignored by git. Segment translations are persisted as each segment completes. New jobs reuse compatible cached translations when the source hash, prompt version, provider, model, source language, and target language match.
Progress events can be written in every UI mode:
Review artifacts contain the full source and translated text of the book. They are written locally under .bookforge/runs/<job-id>/review/; treat them as private user data.
Known limitations: provider API keys are read from environment variables, and validation is intentionally pragmatic rather than a full EPUBCheck replacement.
Benchmarks
Run the mock release smoke benchmark with:
See docs/benchmarks.md for metrics to capture in real-provider runs.
Secrets And Local Tests
Do not commit API keys or ad hoc test books. The repository ignores:
test/
.bookforge/
.claude/
.codex
*.env
*.key
key.txt
For local OpenRouter testing, place the key outside tracked paths or export it directly:
Development Checks
Repository Layout
crates/bookforge-core IR, segmentation, shared config
crates/bookforge-epub EPUB inspect/read/rebuild
crates/bookforge-llm prompts, providers, scheduler, validators
crates/bookforge-llm/prompts Versioned prompt templates
crates/bookforge-store SQLite checkpoint store
crates/bookforge-cli CLI commands and reports
docs/ Architecture notes
tests/fixtures/ Committed minimal fixture only