# andrejsstepanovs/bobik architecture

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

- Interactive diagram: https://gitdiagram.com/andrejsstepanovs/bobik
- Repository: https://github.com/andrejsstepanovs/bobik

## Overview

##### Main Components

a) Core Application Layer:
- Entry Point (run.py)
- Application Manager (src/manager.py)
- State Management (src/state.py)
- Configuration Handler (src/config.py)

b) I/O Layer:
- Input Handlers (src/io_input.py)
- Text Input
- Voice Input (Deepgram)
- Clipboard Input
- File Input
- Output Handlers (src/io_output.py)
- Text Output
- Voice Output (ffplay)
- File Output (History)

c) LLM Integration Layer:
- LLM Provider Interface (src/llm_provider.py)
- LLM Agent Handler (src/llm_agent.py)
- Supported Providers:
- OpenAI
- Groq
- Mistral
- Google
- Ollama
- RunPod
- LM Studio

d) Tools Layer:
- Tool Loader (src/tool_loader.py)
- Built-in Tools:
- Weather
- Calendar
- News
- DateTime
- State Management

e) Support Systems:
- History Management (src/history.py)
- Enrichers (src/enrichers.py)
- Parsers (src/parsers.py)

**[User Interface Layer]**
- ↕
**[I/O Handler Layer]**
- ↕
**[Core Application Layer]**
- ↕
**[LLM Integration Layer] ←→ [External LLM Providers]**
- ↕
**[Tools Layer] ←→ [External Services]**

##### Flow Representation

- User input flow through the system
- Configuration loading and distribution
- State changes and management
- Tool execution paths
- LLM provider interactions

##### Detailed Component Interactions

- How the pre-parser interacts with input processing
- How the LLM agent coordinates with tools
- How state changes propagate through the system
- How history management integrates with the core flow

##### Notes Section

Annotations for:
- Platform-specific considerations (Windows/Linux/Mac)
- Configuration requirements
- External dependencies
- Key feature toggles

Remember to emphasize the dynamic nature of the system, particularly how it handles runtime state changes and model switching, as these are key features of the application.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph User["User Interface"]
        UI_IN[User Input]
        UI_OUT[User Output]
    end

    subgraph IO["I/O Handler Layer"]
        IN[Input Handlers]:::io
        OUT[Output Handlers]:::io
        
        subgraph Input_Types["Input Types"]
            TEXT_IN[Text Input]
            VOICE_IN[Voice Input]
            CLIP_IN[Clipboard Input]
            FILE_IN[File Input]
        end
        
        subgraph Output_Types["Output Types"]
            TEXT_OUT[Text Output]
            VOICE_OUT[Voice Output]
            FILE_OUT[File Output]
        end
    end

    subgraph Core["Core Application Layer"]
        ENTRY[Entry Point]:::core
        APP_MGR[Application Manager]:::core
        STATE[State Management]:::core
        CONFIG[Configuration Handler]:::core
    end

    subgraph LLM["LLM Integration Layer"]
        LLM_INTERFACE[LLM Provider Interface]:::llm
        LLM_AGENT[LLM Agent Handler]:::llm
        
        subgraph Providers["LLM Providers"]
            OPENAI[OpenAI]
            GROQ[Groq]
            MISTRAL[Mistral]
            GOOGLE[Google]
            OLLAMA[Ollama]
            RUNPOD[RunPod]
            LMSTUDIO["LM Studio"]
        end
    end

    subgraph Tools["Tools Layer"]
        TOOL_LOADER[Tool Loader]:::tool
        
        subgraph Built_In_Tools["Built-in Tools"]
            WEATHER[Weather]:::tool
            CALENDAR[Calendar]:::tool
            NEWS[News]:::tool
            DATETIME[DateTime]:::tool
            TOOL_STATE[State Tool]:::tool
        end
    end

    subgraph Support["Support Systems"]
        HISTORY[History Management]:::support
        ENRICHERS[Enrichers]:::support
        PARSERS[Parsers]:::support
    end

    %% Connections
    UI_IN --> IN
    IN --> APP_MGR
    APP_MGR --> OUT
    OUT --> UI_OUT
    
    Input_Types --> IN
    OUT --> Output_Types
    
    CONFIG --> APP_MGR
    STATE --> APP_MGR
    APP_MGR --> LLM_AGENT
    LLM_AGENT --> LLM_INTERFACE
    LLM_INTERFACE --> Providers
    
    APP_MGR --> TOOL_LOADER
    TOOL_LOADER --> Built_In_Tools
    
    APP_MGR --> HISTORY
    APP_MGR --> ENRICHERS
    APP_MGR --> PARSERS

    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef io fill:#4CAF50,stroke:#2E7D32,color:white
    classDef llm fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef tool fill:#FF9800,stroke:#EF6C00,color:white
    classDef support fill:#9E9E9E,stroke:#616161,color:white

    %% Click Events
    click ENTRY "https://github.com/andrejsstepanovs/bobik/blob/main/run.py"
    click APP_MGR "https://github.com/andrejsstepanovs/bobik/blob/main/src/manager.py"
    click STATE "https://github.com/andrejsstepanovs/bobik/blob/main/src/state.py"
    click CONFIG "https://github.com/andrejsstepanovs/bobik/blob/main/src/config.py"
    click IN "https://github.com/andrejsstepanovs/bobik/blob/main/src/io_input.py"
    click OUT "https://github.com/andrejsstepanovs/bobik/blob/main/src/io_output.py"
    click LLM_INTERFACE "https://github.com/andrejsstepanovs/bobik/blob/main/src/llm_provider.py"
    click LLM_AGENT "https://github.com/andrejsstepanovs/bobik/blob/main/src/llm_agent.py"
    click TOOL_LOADER "https://github.com/andrejsstepanovs/bobik/blob/main/src/tool_loader.py"
    click WEATHER "https://github.com/andrejsstepanovs/bobik/blob/main/src/tools/weather.py"
    click CALENDAR "https://github.com/andrejsstepanovs/bobik/blob/main/src/tools/my_calendar.py"
    click NEWS "https://github.com/andrejsstepanovs/bobik/blob/main/src/tools/news.py"
    click DATETIME "https://github.com/andrejsstepanovs/bobik/blob/main/src/tools/datetime.py"
    click TOOL_STATE "https://github.com/andrejsstepanovs/bobik/blob/main/src/tools/state.py"
    click HISTORY "https://github.com/andrejsstepanovs/bobik/blob/main/src/history.py"
    click ENRICHERS "https://github.com/andrejsstepanovs/bobik/blob/main/src/enrichers.py"
    click PARSERS "https://github.com/andrejsstepanovs/bobik/blob/main/src/parsers.py"
```
