How embroidery-space/embroiderly works
Project Type and Purpose
• Full-stack desktop application (not a web service) built with Tauri.
• Purpose: allow users to create, edit, view, and export cross-stitch patterns.
• Key characteristics: local file I/O of pattern files (OXs/XSD), in-app pattern rendering, interactive UI.
High-Level Architectural Components
a. Frontend Layer
– Vue.js SPA (src/)
– Components (CanvasPanel, PalettePanel, dialogs, toolbar, etc.)
– State management via Pinia (stores/)
– API wrappers (src/api/*.ts) that call into Tauri commands
– Assets & themes (src/assets/)
– Pixi plugin for canvas rendering (src/plugins/pixi/)
b. Tauri Runtime & IPC
– Tauri acts as a bridge between WebView UI and the Rust binary
– IPC channels for invoking “commands” defined in Rust
c. Backend Layer (Rust in src-tauri/)
– Command interface (src-tauri/src/commands/*.rs) – entry points for IPC from frontend
– Core domain logic (src-tauri/src/core/)
• Actions (display, grid, palette, stitches, fabric, history)
• Parser submodules for .oxs and .xsd formats
• Pattern model, project serialization, printing
– Utilities (logger, state, path helpers)
d. Persistence & File System
– Local filesystem reads/writes for patterns, palettes, fabrics
– Config/state persisted via JSON or binary (Borsh) formats
Relationships and Data Flow
1. User interacts with Vue UI → triggers a UI event.
2. UI calls an API wrapper in src/api → invokes a Tauri command over IPC.
3. Tauri routes the call to the corresponding Rust command handler.
4. Command handler invokes core domain logic (parsers, actions).
5. Core logic may:
• Read or parse pattern/fabric files from disk
• Modify in-memory pattern model or history
• Serialize state changes (history, project save) back to disk
6. Rust returns a result (data structure or status) via IPC to the frontend.
7. Frontend receives data → commits to Pinia store → UI updates (canvas repaint via Pixi).
Architectural Patterns and Principles
• Layered separation – UI layer, application layer (API wrappers), domain/core layer, persistence layer.
• Command pattern – each operation exposed via a distinct Rust command module.
• MVVM‐style frontend – Vue components + Pinia stores.
• Plugin/extensible design – “extensions” and “capabilities” directories in src-tauri for third-party add-ons.
• Strict type/schema definitions – schemas/pattern and core/parser modules, tests for coverage.