# nbonamy/witsy architecture

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

- Interactive diagram: https://gitdiagram.com/nbonamy/witsy
- Repository: https://github.com/nbonamy/witsy

## Overview

##### Main System Components

a) User Interface Layer
- Main Window (src/screens/Main.vue)
- Multiple specialized windows (Prompt Anywhere, Commands, Settings, etc.)
- Components (src/components/)
- Themes and styling (css/)

b) Core Application Layer
- Main Process (src/main/)
- Renderer Process (src/renderer.ts)
- IPC Communication Layer

c) Service Layer
- LLM Services (src/llms/)
- Voice Services (src/voice/)
- RAG System (src/rag/)
- Automation Services (src/automations/)
- Plugin System (src/plugins/)

d) External Integrations
- AI Providers (OpenAI, Anthropic, Ollama, etc.)
- External Services (Tavily, YouTube, etc.)
- File System Integration
- System Integration (OS-level features)

##### Component Relationships

a) Data Flow
- User Input → UI Components → Core Services
- LLM Services → Message Processing → UI Updates
- File System → RAG System → LLM Integration
- Voice Input → STT Services → Text Processing
- Text Output → TTS Services → Audio Playback

b) Integration Points
- Plugin System ↔ External Services
- Automation System ↔ OS Integration
- LLM Services ↔ AI Providers
- RAG System ↔ Document Storage

##### Architectural Patterns

Patterns:

a) Event-Driven Architecture
- Event Bus (src/composables/event_bus.ts)
- Message Processing Pipeline

b) Plugin Architecture
- Plugin System (src/plugins/)
- Service Extensions

c) Model-View Architecture
- Vue.js Components
- State Management

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        MW["Main Window"]:::ui
        PA["Prompt Anywhere"]:::ui
        CMD["Commands"]:::ui
        SET["Settings"]:::ui
        COMP["UI Components"]:::ui
        THM["Themes & Styling"]:::ui
    end

    subgraph CORE["Core Application Layer"]
        MP["Main Process"]:::core
        RP["Renderer Process"]:::core
        IPC["IPC Communication"]:::core
        EVT["Event Bus"]:::core
        WM["Window Management"]:::core
    end

    subgraph SERVICES["Service Layer"]
        subgraph LLM["LLM Services"]
            OPENAI["OpenAI Integration"]:::llm
            ANTHR["Anthropic Integration"]:::llm
            OLLAMA["Ollama Integration"]:::llm
        end

        subgraph VOICE["Voice Services"]
            STT["Speech-to-Text"]:::voice
            TTS["Text-to-Speech"]:::voice
        end

        subgraph RAG["RAG System"]
            DOCB["Document Base"]:::rag
            VECTDB["Vector Database"]:::rag
            EMB["Embedder"]:::rag
        end

        subgraph AUTO["Automation Services"]
            WINAUTO["Windows Automation"]:::auto
            MACAUTO["MacOS Automation"]:::auto
        end

        subgraph PLUG["Plugin System"]
            PBASE["Plugin Base"]:::plugin
            PMGR["Plugin Manager"]:::plugin
        end
    end

    subgraph EXT["External Integrations"]
        AI["AI Providers"]:::ext
        EXTS["External Services"]:::ext
        FS["File System"]:::ext
        OS["OS Integration"]:::ext
    end

    %% Connections
    MW --> IPC
    PA --> IPC
    CMD --> IPC
    SET --> IPC
    
    IPC --> MP
    IPC --> RP
    
    MP -.-> WM
    RP -.-> EVT
    
    EVT --> LLM
    EVT --> VOICE
    EVT --> RAG
    EVT --> AUTO
    EVT --> PLUG
    
    LLM --> AI
    VOICE --> AI
    RAG --> FS
    AUTO --> OS
    PLUG --> EXTS

    %% Click Events
    click MW "https://github.com/nbonamy/witsy/blob/main/src/screens/Main.vue"
    click PA "https://github.com/nbonamy/witsy/blob/main/src/screens/PromptAnywhere.vue"
    click CMD "https://github.com/nbonamy/witsy/blob/main/src/screens/CommandEditor.vue"
    click SET "https://github.com/nbonamy/witsy/blob/main/src/screens/Settings.vue"
    click COMP "https://github.com/nbonamy/witsy/tree/main/src/components/"
    click THM "https://github.com/nbonamy/witsy/tree/main/css/themes/"
    click MP "https://github.com/nbonamy/witsy/tree/main/src/main/"
    click RP "https://github.com/nbonamy/witsy/blob/main/src/renderer.ts"
    click WM "https://github.com/nbonamy/witsy/tree/main/src/main/windows/"
    click EVT "https://github.com/nbonamy/witsy/blob/main/src/composables/event_bus.ts"
    click OPENAI "https://github.com/nbonamy/witsy/blob/main/src/llms/openai.ts"
    click ANTHR "https://github.com/nbonamy/witsy/blob/main/src/llms/anthropic.ts"
    click OLLAMA "https://github.com/nbonamy/witsy/blob/main/src/llms/ollama.ts"
    click STT "https://github.com/nbonamy/witsy/blob/main/src/voice/stt.ts"
    click TTS "https://github.com/nbonamy/witsy/blob/main/src/voice/tts.ts"
    click DOCB "https://github.com/nbonamy/witsy/blob/main/src/rag/docbase.ts"
    click VECTDB "https://github.com/nbonamy/witsy/blob/main/src/rag/vectordb.ts"
    click EMB "https://github.com/nbonamy/witsy/blob/main/src/rag/embedder.ts"
    click WINAUTO "https://github.com/nbonamy/witsy/blob/main/src/automations/windows.ts"
    click MACAUTO "https://github.com/nbonamy/witsy/blob/main/src/automations/macos.ts"
    click PBASE "https://github.com/nbonamy/witsy/blob/main/src/plugins/plugin.ts"
    click PMGR "https://github.com/nbonamy/witsy/blob/main/src/plugins/plugins.ts"

    %% Styles
    classDef ui fill:#9370DB,stroke:#333,stroke-width:2px
    classDef core fill:#4169E1,stroke:#333,stroke-width:2px
    classDef llm fill:#20B2AA,stroke:#333,stroke-width:2px
    classDef voice fill:#98FB98,stroke:#333,stroke-width:2px
    classDef rag fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef auto fill:#F0E68C,stroke:#333,stroke-width:2px
    classDef plugin fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef ext fill:#FFA07A,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Core Components"]:::core
        L3["LLM Services"]:::llm
        L4["Voice Services"]:::voice
        L5["RAG System"]:::rag
        L6["Automation"]:::auto
        L7["Plugins"]:::plugin
        L8["External"]:::ext
    end
```
