- Refactor codebase into src/ (preprocessing, translation, assembly) - Add pipeline/ scripts for individual stages - Externalize configuration to config/config.yaml - Fix Cover Image preservation - Update documentation and manuals
38 lines
2.0 KiB
Markdown
38 lines
2.0 KiB
Markdown
---
|
|
trigger: always_on
|
|
---
|
|
|
|
# EPUB Bilingual Translator - File Architecture & Workspace Rules
|
|
|
|
## 1. Directory Structure
|
|
The project follows a strict modular structure. Code is in `src/`, execution scripts in `pipeline/`, and intermediate data in `.work/`.
|
|
|
|
.
|
|
├── main.py # Entry point (orchestrator)
|
|
├── pipeline/ # Executable scripts for each stage
|
|
│ ├── 01_preprocess.py # Step 1: Clean & Extract
|
|
│ ├── 02_translate.py # Step 2: LLM Translation
|
|
│ └── 03_assemble.py # Step 3: Backfill & Build
|
|
├── src/ # Source modules
|
|
│ ├── common/ # shared utils, config, paths.py
|
|
│ ├── preprocessing/ # epub_cleaner, text_extractor, profiler
|
|
│ ├── translation/ # llm_client, translator_engine, manifest_manager
|
|
│ └── assembly/ # backfiller, builder, format_restorer
|
|
├── config/
|
|
│ ├── config.yaml # System configuration (LLM, Translation)
|
|
│ └── prompts.json # LLM Prompts
|
|
└── .work/ # Working Directory (Gitignored)
|
|
└── {book_name}/ # One folder per book
|
|
├── book_structure.json # Structural skeleton (created by Step 1)
|
|
├── manifest.json # Translation source of truth
|
|
├── assets/ # Extracted images/css
|
|
└── chunks/ # Debug chunks from translation (before/after)
|
|
|
|
## 2. Path Resolution Rule
|
|
ALWAYS use `src.common.paths.get_work_dirs(input_path)` to resolve paths.
|
|
DO NOT hardcode `work/`, `.work/`, or `tmp/` paths in scripts.
|
|
|
|
## 3. Data Flow
|
|
1. Preprocess: EPUB -> .work/{book}/book_structure.json + .work/{book}/manifest.json
|
|
2. Translate: .work/{book}/manifest.json (read/write) -> .work/{book}/chunks/ (logs)
|
|
3. Assemble: .work/{book}/manifest.json + .work/{book}/book_structure.json -> output/{book}_bilingual.epub |