Skip to content

Architecture

Isllan Toso edited this page Nov 21, 2026 · 2 revisions

Architecture

Bullet is structured as a multi-crate Rust (2024 edition) workspace designed around strict state isolation, supervised async tasks, and zero-panic binary parsing.

Workspace Crates

Crate Responsibility
bullet-core Pure domain types, AppState, named state transitions, GamePhase state machine, Supervisor, and IdentityLoadout validation (#![forbid(unsafe_code)]).
bullet-wad Custom WAD v3.4 reader/writer (zstd, flate2, xxhash-rust), .bin (PROP) parser/serializer, .fantome / .modpkg handling, and parallel game WAD hash index.
bullet-classic On-demand skin, chroma, Exalted/multi-form (Ctrl+5), TFT cosmetic, localized loading-screen (RST v5 / StringOverrides), and Classic Rift (JADE) mod generator.
bullet-inject Native overlay builder (overlay_builder), incremental OverlayCache, mod compatibility & repair (mod_compat), injection pipeline orchestration (InjectionPipeline), and built-in macOS Mach-O patcher (macos_patcher).
bullet-lcu League Client Update (LCU) REST & WebSocket observer (lockfile + command-line fallback discovery for all regional clients).
bullet-party Encrypted Party Mode client (X25519 key exchange + XChaCha20-Poly1305 payload encryption).
bullet-relay Optional self-hosted WebSocket relay server matching the relay-worker/ Cloudflare Durable Object protocol.
bullet-platform OS-isolated abstractions (#[cfg(windows)] / #[cfg(target_os = "macos")]): Slint UI windows, system tray, process discovery, elevation, atomic writes, and i18n (en, pt, es).
bullet-app Application entry point, lifecycle wiring (boot/), injection trigger (trigger/), selection/catalog/presets (selection/), live match stats (game/), party manager (party/), and Ed25519-verified auto-updates (updates/).

Additional top-level components in the public repository:

  • relay-worker/: TypeScript Cloudflare Worker + Durable Object for Party Mode relay.
  • installer/: Inno Setup 6 script (bullet.iss) for Bullet-Setup-<version>-x64.exe.
  • xtask/: Workspace automation (check, package, installer, skin-audit, wad-probe, comments, sign-sums, set-version).

Dependency Rules

  • bullet-core has zero workspace dependencies.
  • bullet-platform depends only on bullet-core plus OS/UI crates (windows-rs, libc, slint).
  • Domain crates (bullet-wad, bullet-classic, bullet-inject, bullet-lcu, bullet-party) never depend on bullet-app.
  • Crates without FFI declare #![forbid(unsafe_code)].

Concurrency & State Model

  • Immutable Snapshot Broadcast (tokio::sync::watch): Shared application state (AppState) is updated exclusively through named transition helpers in bullet-core::state (set_phase, set_overlay_target, set_injection_status, etc.). Consumers subscribe to changes rather than polling.
  • Supervised Tasks (Supervisor): Every background task is spawned under a Supervisor bound to a CancellationToken. Task exits and panics are detected and logged; bare tokio::spawn calls are prohibited.
  • Blocking I/O Isolation: Heavy WAD parsing, hashing, and overlay construction run inside tokio::task::spawn_blocking so the async runtime and UI loop stay responsive.
  • Choice-Driven Arming: Overlay preparation is debounced (100 ms on initial pick, 900 ms after selection changes) and disarmed immediately if the player switches champions/skins before match start.
  • RAII Resource Guards: Active overlay sessions and temporary staging directories are cleaned up automatically via RAII guards and shutdown hooks.

Engineering Quality Gates (xtask)

Every PR and release runs cargo xtask check:

  1. Error-handling & lint sweep: Every discarded Result must carry an explicit // ignore-ok: <reason> justification; zero comments are permitted in source files; every code file must be <= 400 lines and every directory <= 5 code files.
  2. Formatting & Static Analysis: cargo fmt --all -- --check and cargo clippy --workspace --all-targets -- -D warnings.
  3. Test Suite: Unit, integration, property-based, and fuzzing suites across all crates.

Clone this wiki locally