# patchipup/jarvis-mark-ii architecture

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

- Interactive diagram: https://gitdiagram.com/patchipup/jarvis-mark-ii
- Repository: https://github.com/patchipup/jarvis-mark-ii

## Overview

##### Project type and purpose
- This is a local, modular, voice-controlled AI assistant (Jarvis) with no web UI. It runs as a desktop/CLI app, uses speech recognition and TTS, parses embedded commands, and integrates with external services (OBS, Spotify).

##### File structure
- Top-level orchestrator:
- main.py – bootstraps the system
- setup.bat / start.bat – Windows entry points
- config.ini + config.py – centralized settings loader
- input_listener.py – “press-and-hold T” detector
- audio.py – audio capture and TTS playback
- chat.py – AI/chat integration (e.g. OpenAI/Gemini)
- commands.py – parser for embedded in-text commands
- command_modules/ – dispatchers for each action type:
– main_module.py (general commands)
– obs_module.py (OBS WebSocket)
– spotify_module.py (Spotify Web API)
– music_module.py (local music folder)
– macro_module.py (user-defined command sequences)
- localization.py + locales/ – loads .po/.mo translations
- personality.py + personalities/ – loads persona JSONs
- tasks.py – scheduled or background tasks
- updater.py – self-update functionality
- Sounds & music/ – static media assets

##### README for additional insights
- Confirms modular design, lists speech engines (vosk, speech_recognition, faster_whisper), OBS & Spotify integration, macros, personalities, locales.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Orchestrator & Entry
    A["main.py (Orchestrator)"]:::core
    click A "https://github.com/patchipup/jarvis-mark-ii/blob/main/main.py"
    B["setup.bat / start.bat"]:::core
    click B "https://github.com/patchipup/jarvis-mark-ii/blob/main/setup.bat"
    click B "https://github.com/patchipup/jarvis-mark-ii/blob/main/start.bat"
    C["exit.py (Exit Handler)"]:::core
    click C "https://github.com/patchipup/jarvis-mark-ii/blob/main/exit.py"

    A -->|"1 Initialize & Listen"| B
    B --> A
    A -->|“Press T”| D

    %% User I/O Layer
    subgraph "User I/O Layer"
        direction TB
        D["Keyboard Listener"]:::io
        click D "https://github.com/patchipup/jarvis-mark-ii/blob/main/input_listener.py"
        E["Microphone Capture"]:::io
        click E "https://github.com/patchipup/jarvis-mark-ii/blob/main/audio.py"
        F["Speaker Output (TTS)"]:::io
        click F "https://github.com/patchipup/jarvis-mark-ii/blob/main/audio.py"
    end

    D -->|"2 Trigger Audio Capture"| E

    %% Core Processing Layer
    subgraph "Core Processing Layer"
        direction TB
        G["Speech Recognition Engine"]:::core
        style G stroke-dasharray: 5 5
        click G "https://github.com/patchipup/jarvis-mark-ii/blob/main/audio.py"
        H["Chat Engine"]:::core
        click H "https://github.com/patchipup/jarvis-mark-ii/blob/main/chat.py"
        I["Personality Loader"]:::core
        click I "https://github.com/patchipup/jarvis-mark-ii/blob/main/personality.py"
        click I "https://github.com/patchipup/jarvis-mark-ii/blob/main/personalities/jarvis.json"
        J["Command Parser"]:::core
        click J "https://github.com/patchipup/jarvis-mark-ii/blob/main/commands.py"
        K["Localization Loader"]:::core
        click K "https://github.com/patchipup/jarvis-mark-ii/blob/main/localization.py"
        click K "https://github.com/patchipup/jarvis-mark-ii/tree/main/locales/"
    end

    E -->|"3 Stream Audio to STT"| G
    G -->|"4 Text Output"| H
    H -->|"5 Response with Persona"| I
    I --> H
    H -->|"6 Raw Response"| J
    J -->|"7 Localize Text"| K

    K --> L

    %% Branch to TTS or Action
    subgraph "Response Handling"
        direction TB
        L["Interpreter"]:::core
    end

    K -->|"8 Analyze Commands"| L
    L -->|"9a Speak"| F
    L -->|"9b Action Dispatch"| M

    %% Action Dispatch Layer
    subgraph "Action Dispatch Layer"
        direction TB
        M["Dispatcher"]:::dispatch
        click M "https://github.com/patchipup/jarvis-mark-ii/blob/main/command_modules/main_module.py"
        M --> N["Main Module"]:::dispatch
        click N "https://github.com/patchipup/jarvis-mark-ii/blob/main/command_modules/main_module.py"
        O["OBS Module"]:::dispatch
        click O "https://github.com/patchipup/jarvis-mark-ii/blob/main/command_modules/obs_module.py"
        P["Spotify Module"]:::dispatch
        click P "https://github.com/patchipup/jarvis-mark-ii/blob/main/command_modules/spotify_module.py"
        Q["Music Module"]:::dispatch
        click Q "https://github.com/patchipup/jarvis-mark-ii/blob/main/command_modules/music_module.py"
        R["Macro Module"]:::dispatch
        click R "https://github.com/patchipup/jarvis-mark-ii/blob/main/command_modules/macro_module.py"
    end

    M --> N
    M --> O
    M --> P
    M --> Q
    M --> R

    %% Configuration & Resources
    subgraph "Configuration & Resources"
        direction TB
        S["config.ini / config.py"]:::resource
        click S "https://github.com/patchipup/jarvis-mark-ii/blob/main/config.ini"
        click S "https://github.com/patchipup/jarvis-mark-ii/blob/main/config.py"
        T["Personality JSONs"]:::resource
        click T "https://github.com/patchipup/jarvis-mark-ii/tree/main/personalities/"
        U["Locales (.po/.mo)"]:::resource
        click U "https://github.com/patchipup/jarvis-mark-ii/tree/main/locales/"
        V["Sounds Assets"]:::resource
        click V "https://github.com/patchipup/jarvis-mark-ii/tree/main/sounds/"
        W["Music Folders"]:::resource
        click W "https://github.com/patchipup/jarvis-mark-ii/tree/main/music/"
    end

    A --> S
    I --> T
    K --> U
    L --> V
    Q --> W

    %% Support Services
    subgraph "Support Services"
        direction TB
        X["Updater"]:::service
        click X "https://github.com/patchipup/jarvis-mark-ii/blob/main/updater.py"
        Y["Scheduled Tasks"]:::service
        click Y "https://github.com/patchipup/jarvis-mark-ii/blob/main/tasks.py"
    end

    A --> X
    A --> Y
    C --> Y

    %% Styles
    classDef io fill:#f9f,stroke:#333,stroke-width:1px,shape:parallelogram
    classDef core fill:#ccf,stroke:#333,stroke-width:1px,shape:rectangle
    classDef dispatch fill:#cfc,stroke:#333,stroke-width:1px,shape:rectangle
    classDef resource fill:#eee,stroke:#333,stroke-width:1px,shape:cylinder
    classDef service fill:#fcf,stroke:#333,stroke-width:1px,shape:rectangle
```
