# zuramai/chatllm architecture

> Architecture diagram of the GitHub repository zuramai/chatllm, 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/zuramai/chatllm
- Repository: https://github.com/zuramai/chatllm

## Overview

##### Main Components

a. Frontend Layer (Vue.js Application):
- UI Components (src/components/ui/*)
- Domain Components (src/components/domain/*)
- Views/Pages (src/views/*)
- State Management (src/store/*)
- Router (src/router/*)

b. Core Processing Layer:
- WebGPU Integration (src/composables/useWebGPU.ts)
- LLM Processing (src/composables/useLLM.ts)
- Model Management (src/composables/useModel.ts)
- Database Operations (src/composables/useDb.ts)

c. Web Worker Layer:
- Background Processing (src/web-worker.ts)

##### Specific Elements

**┌─────────────────────────────────────────────────────────┐**
- Vue.js Frontend                       │
- ┬───────────────┬──────────────┬─────────────┤
- Views   │ UI Components │    Router    │    Store    │
- (Pages)  │              │              │   (Pinia)   │
- ┬─────┴───────┬───────┴──────┬───────┴─────────────┘

**┌─────▼─────────────▼──────────────▼───────────────────┐**
- Core Processing Layer                  │
- ┬──────────────┬────────────┬──────────┤
- Model      │     LLM      │  WebGPU    │    DB    │
- Manager     │   Service    │  Service   │ Service  │
- ┬───────┴──────┬───────┴─────┬──────┴────┬─────┘

**┌──────▼──────────────▼──────────────▼───────────▼─────┐**
- Web Worker Layer                     │
- (Background Processing & GPU Tasks)          │
- ┘

##### Technical Details to Highlight

- Vue 3 component architecture
- WebGPU implementation for GPU acceleration
- Pinia state management
- Web Worker implementation for background processing
- Local database integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#e1f5fe,stroke:#01579b
    classDef core fill:#e8f5e9,stroke:#1b5e20
    classDef worker fill:#fff3e0,stroke:#e65100
    classDef database fill:#f3e5f5,stroke:#4a148c

    %% Frontend Layer
    subgraph Frontend
        UI["UI Components"]:::frontend
        Domain["Domain Components"]:::frontend
        Views["Views/Pages"]:::frontend
        Router["Router"]:::frontend
        Store["State Management"]:::frontend
        
        %% Frontend Components
        UI --> Store
        Domain --> Store
        Views --> Store
        Router --> Views
        
        %% Bot Management
        BotCreate["Create Bot Form"]:::frontend
        BotUpdate["Update Bot Form"]:::frontend
        ChatInterface["Chat Interface"]:::frontend
        
        %% Views
        HomeView["Home View"]:::frontend
        ModelsView["Models View"]:::frontend
        PromptsView["Prompts View"]:::frontend
        
        Views --- HomeView
        Views --- ModelsView
        Views --- PromptsView
        Domain --- BotCreate
        Domain --- BotUpdate
        UI --- ChatInterface
    end

    %% Core Processing Layer
    subgraph Core
        ModelMgr["Model Manager"]:::core
        LLMService["LLM Service"]:::core
        WebGPUService["WebGPU Service"]:::core
        DBService["Database Service"]:::core
        
        ModelMgr --> LLMService
        LLMService --> WebGPUService
        ModelMgr --> DBService
    end

    %% Web Worker Layer
    subgraph Worker
        WebWorker["Web Worker\n(Background Processing)"]:::worker
    end

    %% Cross-layer connections
    Frontend --> Core
    Core --> WebWorker
    WebWorker --> WebGPUService

    %% Click events for component mapping
    click UI "https://github.com/zuramai/ChatLLM/tree/main/src/components/ui/*"
    click Domain "https://github.com/zuramai/ChatLLM/tree/main/src/components/domain/*"
    click Views "https://github.com/zuramai/ChatLLM/tree/main/src/views/*"
    click Store "https://github.com/zuramai/ChatLLM/tree/main/src/store/*"
    click Router "https://github.com/zuramai/ChatLLM/blob/main/src/router/index.ts"
    click WebGPUService "https://github.com/zuramai/ChatLLM/blob/main/src/composables/useWebGPU.ts"
    click LLMService "https://github.com/zuramai/ChatLLM/blob/main/src/composables/useLLM.ts"
    click ModelMgr "https://github.com/zuramai/ChatLLM/blob/main/src/composables/useModel.ts"
    click DBService "https://github.com/zuramai/ChatLLM/blob/main/src/composables/useDb.ts"
    click WebWorker "https://github.com/zuramai/ChatLLM/blob/main/src/web-worker.ts"
    click BotCreate "https://github.com/zuramai/ChatLLM/blob/main/src/components/domain/bot/CreateBotForm.vue"
    click BotUpdate "https://github.com/zuramai/ChatLLM/blob/main/src/components/domain/bot/UpdateBotForm.vue"
    click HomeView "https://github.com/zuramai/ChatLLM/blob/main/src/views/Home.vue"
    click ModelsView "https://github.com/zuramai/ChatLLM/blob/main/src/views/Models.vue"
    click PromptsView "https://github.com/zuramai/ChatLLM/blob/main/src/views/Prompts.vue"
    click ChatInterface "https://github.com/zuramai/ChatLLM/blob/main/src/components/ui/chat/ChatMessage.vue"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Core_L["Core Service"]:::core
        Worker_L["Worker Component"]:::worker
    end
```
