# toricane/jarvis architecture

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

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

## Overview

##### Main Components

a) Input/Interaction Layer:
- Webcam Module (webcam.py)
- Voice Input Module (voice.py)
- Button Interface (button.py)

b) Core Processing Layer:
- Main Controller (main.py)
- Context Management (context.py)
- AI Processing (ai.py)

c) Speech Processing Layer:
- Text-to-Speech (tts.py)
- Azure Speech Services (azurespeech.py)
- Sound Management (sounds.py)

d) Utility Layer:
- Search Functionality (search.py)
- Logging System (setup_logging.py)
- Fast Conversation Handler (superfastconvo.py)

##### Input Flow
- Parallel inputs from webcam, voice, and button components flowing into the main controller
- Sound feedback loop from sounds.py to the user

##### Processing Flow
- Main controller connecting to AI processing
- Context management providing state information to AI processing
- Search module supporting AI processing

##### Output Flow
- AI processing results flowing to speech synthesis (tts.py and azurespeech.py)
- Sound feedback to user through sounds.py

##### Specific Design Elements

Use these visual elements:
- Blue components for input modules
- Green components for core processing
- Yellow components for speech processing
- Gray components for utilities

##### Implementation Details

Technical aspects:
- Azure Speech Services integration
- Sound file management system
- Wake word detection system
- Context management system

**[User Interaction Layer]**
- ↕
**[Input Processing Layer]**
- ↕
**[Core Processing Layer]**
- ↕
**[Output Processing Layer]**
- ↕
**[User Feedback Layer]**

##### Additional Notes

- Version information if relevant
- Notes about the VPN connection requirement (based on connectvpncmd.sh)
- Prompts.py integration with the AI processing system

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef input fill:#a8d1f0,stroke:#000
    classDef core fill:#90EE90,stroke:#000
    classDef speech fill:#FFE5B4,stroke:#000
    classDef utility fill:#D3D3D3,stroke:#000
    classDef soundAsset fill:#FFB6C1,stroke:#000

    %% User at the top
    User((User))

    %% Input Layer
    subgraph InputLayer["Input/Interaction Layer"]
        Webcam["Webcam Module"]
        Voice["Voice Input"]
        Button["Button Interface"]
    end

    %% Core Processing Layer
    subgraph CoreLayer["Core Processing Layer"]
        Main["Main Controller"]
        Context["Context Management"]
        AI["AI Processing"]
        Prompts["Prompts System"]
    end

    %% Speech Processing Layer
    subgraph SpeechLayer["Speech Processing Layer"]
        TTS["Text-to-Speech"]
        Azure["Azure Speech Services"]
        SoundMgmt["Sound Management"]
        
        subgraph SoundAssets["Sound Assets"]
            WakeWord["Wake Word Detection"]
            StartListen["Start Listening"]
            FinishListen["Finish Listening"]
            STT["Speech-to-Text"]
            Camera["Camera Feedback"]
        end
    end

    %% Utility Layer
    subgraph UtilityLayer["Utility Layer"]
        Search["Search Functionality"]
        Logging["Logging System"]
        FastConvo["Fast Conversation Handler"]
        VPN["VPN Connection"]
    end

    %% Connections
    User --> InputLayer
    Webcam --> Main
    Voice --> Main
    Button --> Main
    
    Main --> AI
    Context --> AI
    Prompts --> AI
    AI --> Search
    
    AI --> TTS
    AI --> Azure
    TTS --> SoundMgmt
    Azure --> SoundMgmt
    SoundMgmt --> SoundAssets
    SoundAssets --> User
    
    Logging -.-> Main
    FastConvo -.-> AI
    VPN -.-> Azure

    %% Click events
    click Webcam "https://github.com/Toricane/JARVIS/blob/main/webcam.py"
    click Voice "https://github.com/Toricane/JARVIS/blob/main/voice.py"
    click Button "https://github.com/Toricane/JARVIS/blob/main/button.py"
    click Main "https://github.com/Toricane/JARVIS/blob/main/main.py"
    click Context "https://github.com/Toricane/JARVIS/blob/main/context.py"
    click AI "https://github.com/Toricane/JARVIS/blob/main/ai.py"
    click Prompts "https://github.com/Toricane/JARVIS/blob/main/prompts.py"
    click TTS "https://github.com/Toricane/JARVIS/blob/main/tts.py"
    click Azure "https://github.com/Toricane/JARVIS/blob/main/azurespeech.py"
    click SoundMgmt "https://github.com/Toricane/JARVIS/blob/main/sounds.py"
    click SoundAssets "https://github.com/Toricane/JARVIS/tree/main/sounds/"
    click WakeWord "https://github.com/Toricane/JARVIS/blob/main/sounds/wake_word_detected.wav"
    click StartListen "https://github.com/Toricane/JARVIS/blob/main/sounds/start_listening.wav"
    click FinishListen "https://github.com/Toricane/JARVIS/blob/main/sounds/finish_listening.wav"
    click STT "https://github.com/Toricane/JARVIS/blob/main/sounds/stt.wav"
    click Camera "https://github.com/Toricane/JARVIS/blob/main/sounds/camera_shutter.wav"
    click Search "https://github.com/Toricane/JARVIS/blob/main/search.py"
    click Logging "https://github.com/Toricane/JARVIS/blob/main/setup_logging.py"
    click FastConvo "https://github.com/Toricane/JARVIS/blob/main/superfastconvo.py"
    click VPN "https://github.com/Toricane/JARVIS/blob/main/connectvpncmd.sh"

    %% Style applications
    class Webcam,Voice,Button input
    class Main,Context,AI,Prompts core
    class TTS,Azure,SoundMgmt speech
    class WakeWord,StartListen,FinishListen,STT,Camera soundAsset
    class Search,Logging,FastConvo,VPN utility
```
