# nekename/opendeck architecture

> Architecture diagram of the GitHub repository nekename/opendeck, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nekename/opendeck
- Repository: https://github.com/nekename/opendeck

## Overview

##### Project Type and Purpose
- OpenDeck is a cross-platform desktop application built with Tauri: a Svelte/TypeScript front-end running in a webview, paired with a Rust back-end.
- Its purpose is to drive Elgato Stream Deck and similar hardware on Linux, Windows, and macOS, supporting both native and Windows-only plugins (via Wine).

##### File Structure
- Top-level “src” directory holds the Svelte front-end (components/, lib/, routes/, static assets).
- “src-tauri” holds the Rust back-end: event handlers (events/), device logic (elgato.rs), plugin loader (plugins/), state store (store/), application watcher, zip extraction, plus Tauri config and bundler scripts.
- Build & tooling: deno.json, package.json, Vite, Deno tasks for lint/build, Cargo.toml for Rust.

##### Key Insights from README
- Tauri-based architecture, using the elgato-streamdeck Rust library and Wine for Windows-only plugins.
- Cross-platform packaging (Flatpak, DMG, MSI/EXE).
- Plugins conform to the original Stream Deck SDK or OpenAction API.

##### Main Components & Their Relationships
a. Front-end (Svelte UI)
- Components (ActionList, DeviceView, ProfileManager, PropertyInspector)
- Communicates with back-end via Tauri’s IPC (invokes Rust commands and listens for events).
b. Back-end (Rust/Tauri)
- Device Manager: detects and communicates with Stream Deck hardware (elgato.rs)
- Event Bus: inbound events (hardware keypress, settings changes), outbound events (UI updates, device state changes) organized under src-tauri/src/events
- Plugin Subsystem: loads plugin manifests, spawns plugin web-servers or processes (plugins/webserver.rs, info_param.rs)
- Application Watcher: tracks active OS windows for profile switching
- Store: persists profiles and settings on the file system (store/profiles.rs, simplified_profile.rs)
- ZIP Extractor: unpacks plugin bundles (zip_extract.rs)
c. External/OS Layers
- Wine: hosts Windows-only plugins
- udev rules on Linux for device permissions
- File System: local storage for logs, profiles, plugin files

##### Architectural Patterns & Design Principles
- Layered architecture: Presentation (UI), Application (Tauri IPC), Domain (Rust services), Infrastructure (device drivers, file I/O).
- Event-driven: hardware and UI events flow through a Rust event bus.
- Plugin extensibility: clearly defined plugin interface (manifests, web-server protocol) decouples core app from plugin implementations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    User["User"]:::ui -->|"interact"| ActionList

    %% UI Layer
    subgraph "UI Layer (Svelte + Vite)"
        direction TB
        ActionList["ActionList"]:::ui
        DeviceView["DeviceView"]:::ui
        ProfileManager["ProfileManager"]:::ui
        PropertyInspector["PropertyInspector"]:::ui
        PluginManagerUI["PluginManager"]:::ui
        SettingsView["SettingsView"]:::ui
    end

    %% Core Layer
    subgraph "Core Layer (Rust/Tauri)"
        direction TB
        Main["main.rs"]:::backend
        subgraph "Device Manager"
            direction TB
            Elgato["elgato.rs"]:::backend
        end
        subgraph "Event Bus"
            direction TB
            Inbound["inbound/*.rs"]:::backend
            Outbound["outbound/*.rs"]:::backend
            FrontendEvents["frontend/*.rs"]:::backend
        end
        subgraph "Plugin Subsystem"
            direction TB
            PluginMod["mod.rs"]:::backend
            Manifest["manifest.rs"]:::backend
            InfoParam["info_param.rs"]:::backend
            Webserver["webserver.rs"]:::backend
        end
        ApplicationWatcher["application_watcher.rs"]:::backend
        ZipExtractor["zip_extract.rs"]:::backend
        Shared["shared.rs"]:::backend
        subgraph "State Store"
            direction TB
            StoreMod["mod.rs"]:::backend
            Profiles["profiles.rs"]:::backend
            SimplifiedProfile["simplified_profile.rs"]:::backend
        end
    end

    %% Plugin Host
    PluginHost["Plugin Host\n(Native or Wine)"]:::plugin

    %% OS & Hardware
    subgraph "OS & Hardware"
        direction TB
        StreamDeck["Stream Deck Device"]:::os
        FileSystem["File System / udev / Wine"]:::os
    end

    %% Build Pipeline
    Build["Build Pipeline\n(Deno/Vite & Cargo)"]:::build

    %% Connections
    ActionList -->|"invoke IPC"| Main
    DeviceView -->|"invoke IPC"| Main
    ProfileManager -->|"invoke IPC"| Main
    PropertyInspector -->|"invoke IPC"| Main
    PluginManagerUI -->|"invoke IPC"| Main
    SettingsView -->|"invoke IPC"| Main

    Main -->|"manage"| Elgato
    StreamDeck -->|"hardware event"| Elgato
    Elgato -->|"emit event"| Inbound
    Inbound -->|"dispatch"| FrontendEvents
    FrontendEvents -->|"send update"| Outbound
    Outbound -->|"event"| DeviceView
    Outbound -->|"event"| ActionList
    Outbound -->|"event"| PropertyInspector

    Main -->|"load plugins"| PluginMod
    PluginMod --> Manifest
    PluginMod --> InfoParam
    PluginMod --> Webserver
    PluginMod <-->|"spawn/communicate"| PluginHost
    PluginMod -->|"read bundles"| ZipExtractor

    Main -->|"watch windows"| ApplicationWatcher
    Main -->|"access store"| StoreMod
    StoreMod --> Profiles
    StoreMod --> SimplifiedProfile
    StoreMod --> FileSystem
    Main -->|"use shared types"| Shared

    FileSystem -->|"device permissions"| StreamDeck

    Build -->|"bundle frontend"| ActionList
    Build -->|"build backend"| Main

    %% Click Events
    click ActionList "https://github.com/nekename/opendeck/blob/main/src/components/ActionList.svelte"
    click DeviceView "https://github.com/nekename/opendeck/blob/main/src/components/DeviceView.svelte"
    click ProfileManager "https://github.com/nekename/opendeck/blob/main/src/components/ProfileManager.svelte"
    click PropertyInspector "https://github.com/nekename/opendeck/blob/main/src/components/PropertyInspectorView.svelte"
    click PluginManagerUI "https://github.com/nekename/opendeck/blob/main/src/components/PluginManager.svelte"
    click SettingsView "https://github.com/nekename/opendeck/blob/main/src/components/SettingsView.svelte"
    click Main "https://github.com/nekename/opendeck/blob/main/src-tauri/src/main.rs"
    click Elgato "https://github.com/nekename/opendeck/blob/main/src-tauri/src/elgato.rs"
    click ApplicationWatcher "https://github.com/nekename/opendeck/blob/main/src-tauri/src/application_watcher.rs"
    click ZipExtractor "https://github.com/nekename/opendeck/blob/main/src-tauri/src/zip_extract.rs"
    click Shared "https://github.com/nekename/opendeck/blob/main/src-tauri/src/shared.rs"
    click Inbound "https://github.com/nekename/opendeck/tree/main/src-tauri/src/events/inbound"
    click Outbound "https://github.com/nekename/opendeck/tree/main/src-tauri/src/events/outbound"
    click FrontendEvents "https://github.com/nekename/opendeck/tree/main/src-tauri/src/events/frontend"
    click PluginMod "https://github.com/nekename/opendeck/blob/main/src-tauri/src/plugins/mod.rs"
    click Manifest "https://github.com/nekename/opendeck/blob/main/src-tauri/src/plugins/manifest.rs"
    click InfoParam "https://github.com/nekename/opendeck/blob/main/src-tauri/src/plugins/info_param.rs"
    click Webserver "https://github.com/nekename/opendeck/blob/main/src-tauri/src/plugins/webserver.rs"
    click StoreMod "https://github.com/nekename/opendeck/blob/main/src-tauri/src/store/mod.rs"
    click Profiles "https://github.com/nekename/opendeck/blob/main/src-tauri/src/store/profiles.rs"
    click SimplifiedProfile "https://github.com/nekename/opendeck/blob/main/src-tauri/src/store/simplified_profile.rs"
    click Build "https://github.com/nekename/opendeck/blob/main/deno.json"
    click Build "https://github.com/nekename/opendeck/blob/main/vite.config.ts"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0066CC,color:#000;
    classDef backend fill:#DFFFE0,stroke:#339933,color:#000;
    classDef plugin fill:#FFE8C0,stroke:#CC6600,color:#000;
    classDef os fill:#F0F0F0,stroke:#999999,color:#000;
    classDef build fill:#FFDDE0,stroke:#CC3344,color:#000;
```
