# priler/jarvis architecture

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

- Interactive diagram: https://gitdiagram.com/priler/jarvis
- Repository: https://github.com/priler/jarvis

## Overview

##### Project Type and Overall Purpose
- This is a full-stack, offline voice assistant application.
- The backend is written in Rust (using Cargo and Tauri for the desktop integration) that handles core voice functionalities – speech-to-text (using Vosk), wake-word detection (via Rustpotter and Porcupine), and command execution (including an interesting array of commands driven by AutoHotkey scripts).
- The frontend is built with Vite and Svelte (via Tauri) to provide the user interface.
- The project architecture emphasizes offline operation, privacy, and open-source transparency.

##### File Structure for Architectural Components
- The directory tree clearly separates the backend (in the “app” folder) from the GUI (in the “gui” folder):
- “app” contains Rust source code (in app/src) for various modules like audio handling (audio.rs, recorder/*), speech-to-text (stt/*), listener modules (including integrations for porcupine, vosk, and rustpotter), and configuration/logging.
- Within “app”, the “commands” directory organizes a set of system actions (like browser control, calculator, steam, volume, windows, etc.) with each command having its own YAML configuration and associated AutoHotkey (AHK/EXE) scripts. This makes it clear that command processing is modular.
- “gui” holds the frontend code developed in Svelte, with Tauri configuration files linking to the Rust backend. It also includes static assets, CSS, and TypeScript files.

##### Instructing the Principal Software Engineer
– “User Interface (Svelte, Vite)” connected to “Tauri Bridge”.
– “Audio Input Module” (recorder).
– “Speech-To-Text Module (Vosk)”.
– “Wake Word Detection (Rustpotter/Porcupine)” within the “Listener Module”.
– “Command Engine” (with submodules per command: browser, calculator, steam, etc.).
– “Configuration/Database/Logging” modules.
– “Neural Networks / Future NLU Integration” (even if not fully implemented yet).
– From the GUI to the backend showing Tauri commands.
– From the audio input to the STT module, then to the listener.
– From the listener to the command engine.
– From the command engine outwards to invoking system-level actions (via AutoHotkey).
– UI components vs. backend logic.
– System integration components (e.g., audio, STT, wake-word) versus configuration/support modules.
– External dependencies (e.g., Vosk models, AHK scripts) should be clearly annotated.

##### Final Recommendations
– Keep all components clearly labeled and well-organized.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend"
        UI["User Interface (Svelte, Vite)"]:::ui
        Tauri["Tauri Bridge"]:::tauri
    end

    %% Backend Core (Rust)
    subgraph "Backend Core (Rust)"
        Recorder["Audio Recorder Module"]:::recorder
        Audio["Audio Processing Module"]:::audio
        STT["Speech-To-Text Module (Vosk)"]:::stt
        Listener["Listener Module (Rustpotter/Porcupine)"]:::listener
        Command["Command Engine"]:::command
        Config["Configuration Module"]:::config
        DB["Database Module"]:::db
        Log["Logging Module"]:::log
        Neural["Neural Networks / Future NLU"]:::neural
    end

    %% External/System Actions node for command execution via AutoHotkey
    System["System Actions (AHK Scripts)"]:::system

    %% Connections from Frontend to Backend
    UI -->|"sendsCommand"| Tauri
    Tauri -->|"triggersAudioCapture"| Recorder

    %% Audio Flow in Backend
    Recorder -->|"providesAudio"| Audio
    Audio -->|"convertsToText"| STT
    STT -->|"activatesListener"| Listener
    Listener -->|"detectsCommand"| Command

    %% Command Execution Flow
    Command -->|"executes"| System

    %% Support Modules feeding into Command Engine
    Config -->|"suppliesConfig"| Command
    DB -->|"suppliesData"| Command
    Log -->|"logsEvents"| Command
    Neural -->|"futureIntegration"| Command

    %% Click Events
    click UI "https://github.com/priler/jarvis/blob/master/gui/src/App.svelte"
    click Tauri "https://github.com/priler/jarvis/tree/master/gui/src-tauri"
    click Recorder "https://github.com/priler/jarvis/tree/master/app/src/recorder"
    click Audio "https://github.com/priler/jarvis/blob/master/app/src/audio.rs"
    click STT "https://github.com/priler/jarvis/blob/master/app/src/stt/vosk.rs"
    click Listener "https://github.com/priler/jarvis/tree/master/app/src/listener"
    click Command "https://github.com/priler/jarvis/tree/master/app/commands"
    click Config "https://github.com/priler/jarvis/tree/master/app/src/config"
    click DB "https://github.com/priler/jarvis/tree/master/app/src/db"
    click Log "https://github.com/priler/jarvis/blob/master/app/src/log.rs"

    %% Styles
    classDef ui fill:#f9e79f,stroke:#000,stroke-width:2px;
    classDef tauri fill:#aed6f1,stroke:#000,stroke-width:2px;
    classDef recorder fill:#abebc6,stroke:#000,stroke-width:2px;
    classDef audio fill:#d1f2eb,stroke:#000,stroke-width:2px;
    classDef stt fill:#f5cba7,stroke:#000,stroke-width:2px;
    classDef listener fill:#fcf3cf,stroke:#000,stroke-width:2px;
    classDef command fill:#f5b7b1,stroke:#000,stroke-width:2px;
    classDef config fill:#d4efdf,stroke:#000,stroke-width:2px;
    classDef db fill:#d6eaf8,stroke:#000,stroke-width:2px;
    classDef log fill:#fadbd8,stroke:#000,stroke-width:2px;
    classDef neural fill:#d2b4de,stroke:#000,stroke-width:2px;
    classDef system fill:#e8daef,stroke:#000,stroke-width:2px;
```
