# hdcola/lexiai architecture

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

- Interactive diagram: https://gitdiagram.com/hdcola/lexiai
- Repository: https://github.com/hdcola/lexiai

## Overview

##### Main System Components

a) Frontend Layer (Vue.js Application):
- User Interface Components
- State Management (Stores)
- Router
- Asset Management

b) Gemini AI Integration Layer:
- WebSocket Client
- Audio Processing System
- Tools Integration
- Configuration Management

c) External Services:
- Authentication System
- AI Services
- Tool Services (Weather, Google Search)

##### Detailed Component Breakdown

Frontend Architecture:
- Vue 3 component hierarchy
- Main views (Home, Login, Register, Settings, Gemini)
- Stores (auth, jwt, user) and their interactions
- Routing system

Gemini Integration:
- Audio Processing Pipeline
- Audio Recorder
- Audio Streamer
- Audio Worklets
- WebSocket Communication
- Tool Management System

**┌─ User Interface Layer ─────────────────────┐**
- ┌─ Views ─┐ ┌─ Components ─┐ ┌─ Stores ─┐ │
- Home    │ │ GeminiChat   │ │ Auth    │ │
- Login   │ │ AudioUI      │ │ JWT     │ │
- Settings│ │ Selection    │ │ User    │ │
- ┘ └─────────────┘ └─────────┘ │
- Gemini Integration Layer ───────────────┤
- ┌─ Audio ─┐ ┌─ Tools ───┐ ┌─ Utils ──┐ │
- Recorder│ │ Search    │ │ Logger   │ │
- Streamer│ │ Weather   │ │ ErrorMgmt│ │
- Worklets│ │ Manager   │ │ Registry │ │
- ┘ └───────────┘ └──────────┘ │
- External Services ────────────────────┤
- ┌─ Auth ──┐ ┌─ AI ─────┐ ┌─ APIs ───┐ │
- JWT     │ │ Gemini   │ │ Weather  │ │
- Session │ │ Speech   │ │ Search   │ │
- ┘ └──────────┘ └─────────┘ │
- ┘

##### Implementation Details

- Vue 3 + TypeScript stack
- Vite as build tool
- Pinia for state management
- WebSocket for real-time communication
- Audio Worklet architecture
- External API integrations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        UI["User Interface"]
        Views["Views Layer"]:::views
        Components["UI Components"]:::components
        Stores["State Management"]:::stores
        Router["Router System"]:::router
    end

    subgraph "Gemini Integration Layer"
        WSClient["WebSocket Client"]:::wsClient
        
        subgraph "Audio Processing"
            Recorder["Audio Recorder"]:::recorder
            Streamer["Audio Streamer"]:::streamer
            Worklets["Audio Worklets"]:::worklets
        end
        
        subgraph "Tool System"
            ToolMgr["Tool Manager"]:::toolMgr
            Search["Search Tool"]:::search
            Weather["Weather Tool"]:::weather
        end
        
        Config["Configuration"]:::config
        Utils["Utilities"]:::utils
    end

    subgraph "Component Details"
        GChat["Gemini Chat"]:::gchat
        GAudio["Gemini Audio"]:::gaudio
        Select["Selection System"]:::select
        Settings["Settings"]:::settings
    end

    subgraph "State Stores"
        AuthStore["Auth Store"]:::authStore
        JWTStore["JWT Store"]:::jwtStore
        UserStore["User Store"]:::userStore
    end

    subgraph "External Services"
        Auth["Authentication"]
        AI["AI Services"]
        APIs["External APIs"]
    end

    UI --> Views
    UI --> Components
    UI --> Router
    Components --> GChat
    Components --> GAudio
    Components --> Select
    Components --> Settings
    Stores --> AuthStore
    Stores --> JWTStore
    Stores --> UserStore
    WSClient --> AI
    Recorder --> Streamer
    Streamer --> Worklets
    ToolMgr --> Search
    ToolMgr --> Weather
    Search --> APIs
    Weather --> APIs
    AuthStore --> Auth
    JWTStore --> Auth

    %% Click Events
    click Views "https://github.com/hdcola/lexiai/tree/main/src/views/"
    click Components "https://github.com/hdcola/lexiai/tree/main/src/components/"
    click Stores "https://github.com/hdcola/lexiai/tree/main/src/stores/"
    click Router "https://github.com/hdcola/lexiai/blob/main/src/router/index.ts"
    click WSClient "https://github.com/hdcola/lexiai/blob/main/src/lib/gemini/websocket-client.js"
    click Recorder "https://github.com/hdcola/lexiai/blob/main/src/lib/gemini/audio/audio-recorder.js"
    click Streamer "https://github.com/hdcola/lexiai/blob/main/src/lib/gemini/audio/audio-streamer.js"
    click Worklets "https://github.com/hdcola/lexiai/tree/main/src/lib/gemini/audio/worklets/"
    click ToolMgr "https://github.com/hdcola/lexiai/blob/main/src/lib/gemini/tools/tool-manager.js"
    click Search "https://github.com/hdcola/lexiai/blob/main/src/lib/gemini/tools/google-search.js"
    click Weather "https://github.com/hdcola/lexiai/blob/main/src/lib/gemini/tools/weather-tool.js"
    click Config "https://github.com/hdcola/lexiai/tree/main/src/lib/gemini/config/"
    click Utils "https://github.com/hdcola/lexiai/tree/main/src/lib/gemini/utils/"
    click GChat "https://github.com/hdcola/lexiai/blob/main/src/components/GeminiChat.vue"
    click GAudio "https://github.com/hdcola/lexiai/blob/main/src/components/GeminiAudio.vue"
    click Select "https://github.com/hdcola/lexiai/tree/main/src/components/selection/"
    click Settings "https://github.com/hdcola/lexiai/tree/main/src/components/settings/"
    click AuthStore "https://github.com/hdcola/lexiai/blob/main/src/stores/auth.ts"
    click JWTStore "https://github.com/hdcola/lexiai/blob/main/src/stores/jwt.ts"
    click UserStore "https://github.com/hdcola/lexiai/blob/main/src/stores/user.ts"

    classDef views fill:#e1f5fe,stroke:#01579b
    classDef components fill:#e8f5e9,stroke:#1b5e20
    classDef stores fill:#fff3e0,stroke:#e65100
    classDef router fill:#f3e5f5,stroke:#4a148c
    classDef wsClient fill:#fce4ec,stroke:#880e4f
    classDef recorder fill:#f1f8e9,stroke:#33691e
    classDef streamer fill:#f9fbe7,stroke:#827717
    classDef worklets fill:#fff8e1,stroke:#ff6f00
    classDef toolMgr fill:#fff3e0,stroke:#e65100
    classDef search fill:#fbe9e7,stroke:#bf360c
    classDef weather fill:#e0f2f1,stroke:#004d40
    classDef config fill:#e8eaf6,stroke:#1a237e
    classDef utils fill:#efebe9,stroke:#3e2723
    classDef gchat fill:#e3f2fd,stroke:#0d47a1
    classDef gaudio fill:#e0f7fa,stroke:#006064
    classDef select fill:#f3e5f5,stroke:#4a148c
    classDef settings fill:#e8f5e9,stroke:#1b5e20
    classDef authStore fill:#fce4ec,stroke:#880e4f
    classDef jwtStore fill:#f3e5f5,stroke:#4a148c
    classDef userStore fill:#e1f5fe,stroke:#01579b
```
