Skip to main content

Ratspeak app architecture and contributing

The Ratspeak desktop and mobile application pairs a layered Rust workspace (edition 2024, resolver = "3", MSRV 1.90+) with a separate Tauri 2 shell workspace (src-tauri/, edition 2021) and a zero-framework vanilla HTML/CSS/JS frontend (dashboard/).

1. Crate layering & responsibilities​

Workspace crate / dirRole & dependency boundary
crates/ratspeak-corePure domain types, delivery state machine, Emitter trait, and AppError. Zero Tauri, SQLite, or Reticulum dependencies.
crates/ratspeak-dbSQLite persistence (bundled rusqlite + r2d2 pool), sequential schema migrations (SCHEMA_VERSION in ratspeak-db/src/db.rs), and query helpers. Depends only on ratspeak-core.
crates/ratspeak-runtimeWires rsReticulum, rsLXMF, lrgp-rs, and optional rsLXST (lxst-voice). Owns AppState, .ratspeak-host.lock profile locking, auto-announce loop (default 1 hour via tokio::sync::watch), and async poll loops. Zero Tauri dependencies.
crates/ratspeak-tauri#[tauri::command] handlers across domain modules (messaging, contacts, interfaces, network, identity, channels, games, voice, etc.) and TauriEmitter implementing ratspeak_core::Emitter.
crates/rsnode-updateFirmware update helper crate (provisional tier).
src-tauri/Separate Cargo workspace (edition 2021, own src-tauri/Cargo.lock) hosting the Tauri 2 binary shell, native window/tray integration, and platform capabilities.
dashboard/Vanilla HTML/CSS/JS frontend — no bundler and no npm install. 18 modular CSS files in dashboard/static/css/ concatenate into dashboard/static/style.css via ./dashboard/build-css.sh. JS modules in dashboard/static/js/ load in dependency order from dashboard/index.html under the RS namespace (the only third-party asset is vendor/jsQR.js).

2. Startup sequence & IPC flow​

  1. Tauri's .setup() in src-tauri/src/lib.rs calls ratspeak_tauri::init_core(data_dir, app_handle).
  2. The core acquires the exclusive profile lock (.ratspeak-host.lock) and opens/migrates the SQLite pool via ratspeak-db.
  3. AppHandle is wrapped in TauriEmitter (Arc<dyn Emitter>) and attached to AppState.
  4. ratspeak_runtime::init_rns_lxmf() spawns asynchronously: starts the Reticulum runtime, initializes the LXMF router/delivery manager, registers destinations, and begins background poll/announce loops.
  5. In parallel, the WebView loads dashboard/index.html directly via Tauri's asset protocol. All frontend↔backend traffic uses window.__TAURI__.core.invoke and window.__TAURI__.event.listen — there is no embedded localhost HTTP server.

3. SQLite lock & migration contract​

Contributors modifying storage or lifecycle code must preserve three safety invariants:

  • Single-instance profile lock (.ratspeak-host.lock): On startup, ratspeak-runtime acquires an OS file lock in the .ratspeak data root. If another Ratspeak process already holds the profile, startup halts cleanly with startup_error (code: "profile_in_use") without touching the database. On filesystems that do not support locking, the core warns via profile_lock_warning.
  • WAL mode & r2d2 pooling: ratspeak.db runs in SQLite WAL mode (ratspeak.db-wal / ratspeak.db-shm). Blocking SQLite work must stay on established worker threads — an async fn signature alone does not keep blocking queries off Tokio executor threads. Never delete -wal files out from under a profile.
  • Sequential, one-way migrations (SCHEMA_VERSION): Schema migrations live in ratspeak-db/src/db.rs (schema 54 on Ratspeak 1.1.x). Opening a profile created by a newer schema version fails closed with startup_error (code: "schema_newer" with found and supported versions) and opens the database read-only rather than risking downgrade corruption.

4. Cargo feature gates​

FeatureDefaultPurpose
serialOn (desktop)USB/serial RNode, Serial, and KISS interfaces via serialport. Disabled on mobile (default-features = false).
bleOn (desktop/mobile)Bluetooth LE RNode and Bluetooth Peer mesh across rns-interface, rns-runtime, and ratspeak-runtime.
seedOn (ratspeak-runtime)Pure-Rust BIP-39 12-word mnemonic identity derivation via rns-ratkey (no PC/SC dependency).
hardwareOn (desktop src-tauri)Experimental YubiKey 5 PIV identities via rns-ratkey/hardware (implies seed).
lxst-voiceOn (src-tauri)Experimental voice calls via rsLXST + cpal (non-commercial LXST license; omit with --no-default-features).
rnode-tcpOn (mobile)RNode-over-TCP interface support for iOS/Android Wi-Fi radio bridges.
mobile-throttleOn (mobile)Slows background poll/tick/scan loops when mobile apps are backgrounded (disabled on desktop).

5. Local development & test loop​

Assemble the five-repository sibling layout from Building from source, then iterate inside the owning repo:

# 1. Rebuild dashboard/static/style.css after editing dashboard/static/css/*.css
cd Ratspeak && ./dashboard/build-css.sh

# 2. Launch desktop app in dev mode (reloads dashboard assets on relaunch)
cd Ratspeak/src-tauri && cargo tauri dev

# 3. Fast single-crate test loops
cd Ratspeak && cargo test -p ratspeak-db
cd Ratspeak && cargo test -p ratspeak-runtime
cd Ratspeak && cargo test -p ratspeak-tauri

# 4. Full workspace test suites across affected repos
cd rsReticulum && cargo test --workspace
cd rsLXMF && cargo test --workspace
cd Ratspeak && cargo test --workspace

6. Contributing & pull request checklist​

  1. File issues and PRs in the owning repository: App UI/runtime bugs go to ratspeak/Ratspeak; protocol/daemon bugs to ratspeak/rsReticulum or ratspeak/rsLXMF; handheld firmware to ratspeak/ratspeak-handheld; documentation updates to ratspeak/ratspeak-docs.
  2. Format, lint, and test before opening a PR: Run cargo fmt --check, cargo clippy, and cargo test --workspace in every affected workspace (plus API baseline checks when touching public protocol surfaces).
  3. Commit bottom-up for cross-repo changes: Land changes in rsReticulum → rsLXMF → Ratspeak so each repository compiles independently at every commit.
  4. Never commit secrets or runtime data: Keep .ratspeak/, .reticulum/, .db, .key, recovery phrases, and personal data out of PRs and issue reports.
  5. Include evidence in your PR: List affected repos, exact commands run, screenshots for UI/docs changes, and board/radio details for hardware work.

Next steps​