Skip to content

Backend map

Fuzja edited this page Nov 12, 2026 · 1 revision

Backend map

The Rust application lives in src-tauri/src/. Tauri exposes Rust functions as commands that the React frontend calls with invoke.

Application setup

lib.rs is the main setup point. It creates shared managers, registers Tauri plugins, initializes the tray and queue state, handles window close behavior, and registers every frontend-callable command with generate_handler!.

When adding a command, define it in the appropriate module and register it in the handler list in lib.rs. The frontend command name is derived from the Rust function name. Keeps the argument shape in sync with the frontend invoke call.

Module responsibilities

  • app/config.rs - config manager and persisted settings.
  • app/queue.rs - SQLite-backed queue state and priority ordering.
  • app/presets.rs - preset storage and import/export commands.
  • app/tray.rs - system tray menu and queue actions.
  • features/downloads/ - download command construction, execution coordination, cancellation, and file operations.
  • features/conversion/ - metadata-based input handling, FFmpeg argument building, estimates, and batch conversion.
  • features/compression/ - compression option handling, quality calculations, FFmpeg arguments, and batch compression.
  • system/ - metadata lookup, format catalog, configuration access, acceleration detection, and other OS-facing helpers.
  • startup/ - startup checks and requirement download/update work.
  • infrastructure/bridge/ - Pulsar Bridge process lifecycle, JSON-line communication, process limiting, and event forwarding.
  • infrastructure/ffmpeg/ - FFmpeg path resolution, codec mapping, and encoder validation.

Frontend communication

Use #[tauri::command] for commands and add each callable function to tauri::generate_handler! in lib.rs. Use AppHandle::emit to send asynchronous events to the frontend. The frontend's shared wrapper is src/services/tauri.ts.

Long-running operations should report progress as events and support cancellation where the feature requires it. Keep event names and payload fields consistent with the queue event model in src/features/queue/events.ts.

Pulsar Bridge and FFmpeg

BridgeState owns the long-running Pulsar Bridge child process and its stdin. Commands are written as newline-delimited JSON; a reader processes the returned JSON messages and emits task updates. Batch operations share the bridge process limiter.

Conversion and compression use FFmpeg through native Rust commands. Shared path and codec helpers live in infrastructure/ffmpeg/. Downloads can also delegate post-processing and merging to FFmpeg through Pulsar Bridge.

For the end-to-end lifecycle, see Task and event flow.

Clone this wiki locally