1.8 KiB
1.8 KiB
Sprimo Frontend Architecture
Workspace Layout
crates/sprimo-app: process entrypoint and runtime wiring.crates/sprimo-api: axum-based localhost control server.crates/sprimo-config: config schema, path resolution, persistence.crates/sprimo-platform: platform abstraction for overlay operations.crates/sprimo-protocol: shared API/state/command protocol types.crates/sprimo-sprite: sprite pack manifest loading and fallback logic.
Runtime Data Flow
sprimo-apploads or createsconfig.toml.- App builds initial
FrontendStateSnapshot. - App starts
sprimo-apion a Tokio runtime. - API authenticates commands and deduplicates IDs.
- Commands are bridged from Tokio channel to Bevy main-thread systems.
- Bevy systems apply commands to sprite state, window/platform operations, and config persistence.
- Shared snapshot is exposed by API via
/v1/stateand/v1/health.
Sprite Reload Semantics
SetSpritePackuses a two-phase flow:
- Validate and build candidate pack runtime (manifest + clips + atlas layout + texture handle).
- Commit atomically only on success.
- On reload failure, current pack remains active and snapshot
last_erroris updated.
Threading Model
- Main task: startup + shutdown signal.
- API task: axum server.
- Bridge task: forwards API commands into Bevy ingest channel.
- Bevy main thread: rendering, animation, command application, and window behavior.
- Optional hotkey thread (Windows): registers global hotkey and pushes recovery events.
- Snapshot is shared via
Arc<RwLock<_>>.
Design Constraints
- Bind API to localhost only.
- Token auth by default for mutating and state endpoints.
- Keep protocol crate renderer-agnostic for future backend/frontend reuse.
- Keep platform crate isolated for per-OS implementations.