How pwilkin/catapult works
1. Overall shape
- Catapult is a desktop launcher with two user-facing shells over the same Rust core: a GUI built with Tauri v2 + React/TypeScript (src/) and a TUI built with ratatui/crossterm (src-tauri/src/tui).
- The GUI runs inside the Tauri webview and talks to Rust through Tauri IPC; the TUI bypasses the web layer and drives the same backend modules directly.
2. Backend boundary
- The Rust side is the system-of-record for anything that touches the machine: downloading runtimes/models, reading hardware, launching/stopping subprocesses, and persisting settings/presets.
- The key shared backend modules are hardware.rs, runtime.rs, models.rs, server.rs, huggingface.rs, and config.rs, with lib.rs/main.rs wiring the app entrypoints.
3. GUI presentation layer
- The React app is organized by domain screens: Dashboard, Runtime, Models, Server, Chat, and Wizard.
- Layout.tsx and shared components provide the chrome/navigation, while page components mostly render state and dispatch actions into the Tauri backend.
4. TUI presentation layer
- The terminal app is split into tabs that mirror the GUI’s core workflows: dashboard, runtime, models, server, logs, and chat.
- app.rs, event.rs, and server_ctl.rs manage the TUI event loop and backend interaction; tab-specific logic lives under src-tauri/src/tui/tabs/.
5. Runtime management subsystem
- runtime.rs handles llama.cpp runtime discovery, version management, activation, and likely download/install orchestration.
- The app supports both managed runtimes pulled from GitHub releases and custom local runtimes, with hardware-aware backend scoring from hardware.rs to recommend CUDA/Metal/ROCm/Vulkan/CPU builds.
6. Model management subsystem
- models.rs and huggingface.rs cover model discovery, metadata parsing, recommended-model listings, and downloads.
- Models are discovered from local directories, with GGUF metadata read from file headers; downloads come from HuggingFace with resume/retry behavior, and vision models get mmproj pairing support.
7. Server configuration and process control
- server.rs is the main boundary for constructing and managing the llama-server process.
- The GUI exposes configuration through tabbed parameter groups; the TUI exposes the same underlying flags through autocomplete-driven parameter editing.
- Presets are first-class: named configurations can be saved/loaded, and model selection can recall the last-used preset.
8. Execution and log flow
- Launching the server produces a long-running subprocess whose output is streamed back into the UI.
- The TUI has a dedicated logs tab for this stream; the GUI surfaces status and controls from the dashboard/server views.
- Stopping, restarting, and aborting downloads are explicit lifecycle controls in both interfaces.
9. Chat subsystem
- The chat experience is not a separate backend service; it is another process/UI mode built on top of the selected model and server settings.
- In the GUI, chat is embedded via the llama.cpp WebUI in an iframe and can be popped out to a separate window.
- In the TUI, chat launches llama-cli as a subprocess and returns control when it exits.
10. Persistence and local state
- State appears to be file-based rather than database-backed: runtime installs, model files, presets, and configuration live on disk in user-controlled locations.
- config.rs and the Tauri app configuration define the app’s local settings and permissions boundary, while the Rust backend mediates all filesystem and process access.
11. First-launch and system discovery
- The GUI includes a wizard that combines hardware detection, runtime recommendation, and model selection to get to a working setup quickly.
- This is a good diagram boundary to show: hardware info feeds recommendations, recommendations feed runtime/model choices, and those choices feed server launch.
12. External dependencies
- The app depends on GitHub Releases for managed llama.cpp binaries and HuggingFace for model discovery/download.
- It also orchestrates external local executables from the llama.cpp ecosystem: llama-server, the WebUI, and llama-cli.
13. Useful diagram summary
- A good architecture diagram would show three layers: presentation (GUI/TUI), Rust backend services (hardware/runtime/models/server/config), and external/local execution targets (filesystem, GitHub, HuggingFace, llama.cpp subprocesses).
- The main data flows are: hardware detection → runtime/model recommendation → download/install → server configuration → subprocess launch → log/chat output back to UI.
Main entry points: server.rs Server manager · runtime.rs Runtime manager · models.rs Model manager · App.tsx GUI shell
Components 21
Presentation
GUI and TUI shells that drive the app
- GUI shell · Tauri webview app and shared chrome/navigation
src/App.tsx - Dashboard · Status and quick actions
src/pages/Dashboard.tsx - Runtime · Runtime discovery and selection
src/pages/Runtime.tsx - Models · Model browsing and downloads
src/pages/Models.tsx - Server · Server configuration and controls
src/pages/Server.tsx - Chat · Embedded chat and pop-out view
src/pages/Chat.tsx - Wizard · First-launch setup flow
src/pages/Wizard.tsx - TUI shell · Terminal UI event loop and screen management
src-tauri/src/tui/app.rs - TUI tabs · Dashboard, runtime, models, server, logs, and chat tabs
src-tauri/src/tui/tabs/mod.rs - TUI server ctl · Server lifecycle and backend interaction for the TUI
src-tauri/src/tui/server_ctl.rs - TUI params · Parameter editing and autocomplete widgets
src-tauri/src/tui/params.rs
Rust backend
Shared system-of-record services and process orchestration
- App entry · Rust entrypoints and app wiring
src-tauri/src/main.rs - Config · Local settings, presets, and app configuration
src-tauri/src/config.rs - Hardware · System detection and hardware-aware scoring
src-tauri/src/hardware.rs - Runtime manager · Runtime discovery, versioning, activation, and install orchestration
src-tauri/src/runtime.rs - Model manager · Local model discovery, metadata, and model selection
src-tauri/src/models.rs - Server manager · Constructs and runs the llama-server process
src-tauri/src/server.rs - Hugging Face · Model catalog and download client
src-tauri/src/huggingface.rs
External targets
Local state, package sources, and spawned executables
- Local files · Runtime installs, model files, presets, and configuration on disk
- GitHub releases · Managed runtime release source
- llama.cpp tools · llama-server, llama-cli, and WebUI executables
Connections 34
- GUI shell → Dashboard: navigates · Shared UI chrome routes users across domain pages
- GUI shell → Runtime: navigates · Routes to runtime management
- GUI shell → Models: navigates · Routes to model management
- GUI shell → Server: navigates · Routes to server configuration
- GUI shell → Chat: navigates · Routes to chat mode
- GUI shell → Wizard: navigates · Routes to first-launch setup
- TUI shell → TUI tabs: renders · Manages tabbed terminal views
- TUI shell → TUI server ctl: drives · Coordinates backend actions and lifecycle events
- TUI shell → TUI params: edits · Uses autocomplete-driven parameter entry
- App entry → Config: loads · Initializes local configuration and permissions
- App entry → Hardware: starts · Bootstraps hardware discovery
- App entry → Runtime manager: wires · Connects runtime service into the app
- App entry → Model manager: wires · Connects model service into the app
- App entry → Server manager: wires · Connects server control into the app
- Hardware → Runtime manager: recommends · Hardware profile informs runtime build selection
- Hardware → Model manager: recommends · Hardware profile informs model suggestions
- Runtime manager → GitHub releases: downloads · Managed runtimes are fetched from releases
- Runtime manager → Local files: installs · Runtime binaries and metadata live on disk
- Model manager → Hugging Face: queries · Remote catalog and downloads come from Hugging Face
- Model manager → Local files: reads · Discovers local model files and GGUF metadata
- Hugging Face → Local files: stores · Downloaded models are persisted locally
- Server manager → Runtime manager: uses · Server launch depends on the selected runtime
- Server manager → Model manager: uses · Server launch depends on the selected model
- Server manager → Config: applies · Presets and named settings shape server flags
- Server manager → llama.cpp tools: spawns · Runs llama-server and related tools as subprocesses
- Chat → llama.cpp tools: spawns · Chat uses llama.cpp WebUI or CLI execution paths
- TUI tabs → Server manager: controls · Server tab and logs tab reflect backend process state
- Wizard → Hardware: reads · First-launch setup begins with system discovery
- Wizard → Runtime manager: selects · Wizard helps choose an appropriate runtime
- Wizard → Model manager: selects · Wizard helps choose an initial model
- Server → Server manager: configures · Server page edits flags, presets, and launch settings
- Models → Model manager: manages · Model page triggers discovery and downloads
- Runtime → Runtime manager: manages · Runtime page triggers install and activation
- Dashboard → Server manager: monitors · Dashboard surfaces server state and lifecycle controls