Backend
The backend is a Rust Cargo workspace. The root Cargo.toml declares the
members and centralizes shared dependency versions under
[workspace.dependencies].
[workspace]
members = ["src-tauri", "crates/shared", "crates/show", "crates/ocr", "crates/classify"]
src-tauri — the app shell
src-tauri/ is the Tauri application crate (package nque). It owns:
tauri.conf.json— product name, window definitions, bundle config.build.rsandgenerate_context!()— never move these out ofsrc-tauri.capabilities/— Tauri 2 capability (permission) definitions.src/lib.rs— builds the app, registers plugins (opener, dialog), registers theinvoke_handler, and implements window management (open_display_window).src/commands.rs— theimport_pdf_showcommand that wires the OCR and show pipelines together.
Keep src-tauri thin. It should resolve dialogs, marshal arguments, move
CPU-heavy work onto spawn_blocking, and emit events. It should not contain
pipeline logic.
The domain crates
shared
Small, pure, dependency-light utilities used across crates.
ocr — ingest
Turns PDF bytes into a text document.
extract.rs— native text extraction and the scanned-PDF detection heuristic.pdf.rs— renders PDF pages to images with PDFium.ocr.rs— wraps theocrs/rtenengine with bundled models.pipeline.rs—extract_text(): probe, then extract or render + OCR.
The OCR models are downloaded by crates/ocr/scripts/download-models.sh and
embedded via include_bytes!. See OCR ingest.
classify
Turns a line of text into a LineKind (Heading, StageDirection, Dialog,
Noise) with a confidence score, and headings into a HeadingKind
(Act, Scene, Division). Rule-based, in rules.rs. See
Classify.
show — construct, filter, persist
pipeline.rs—build_show_from_text: classify → construct → filter.parse.rs—TextParseConfigand cue splitting.filter.rs—filter_showandFilterConfig.types.rs—Show,Section,Cue.file.rs— theShowFileenvelope.schema.rs— JSON Schema validation.commands.rs—save_show,save_show_as,load_show,confirm_discard_changes.
Conventions
- Register every Tauri command in the
invoke_handlerinsrc-tauri/src/lib.rs. - Prefer client-agnostic logic in
crates/shared(or a new domain crate) oversrc-tauri. - Centralize dependency versions in
[workspace.dependencies]. - The
ocrsandrtenpackages are compiled with release-level optimization even in the dev profile (seeCargo.toml), because they are unusably slow under debug settings. - Add new crates under
crates/and register them in the members list.