# allwefantasy/william-toolbox architecture

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

- Interactive diagram: https://gitdiagram.com/allwefantasy/william-toolbox
- Repository: https://github.com/allwefantasy/william-toolbox

## Overview

##### Main Components Identification
The system consists of these primary components:

a) Frontend Layer (React-based):
- User Interface Components (/frontend/src/components/)
- Model Management Interface
- RAG Management Interface
- Configuration Management
- User Management
- Workflow Visualization

b) Backend Layer (Python-based):
- Server Routers (/src/williamtoolbox/server/)
- Storage System (/src/williamtoolbox/storage/)
- Authentication System
- Model Management Service
- RAG Management Service

**[Client Browser] → [Frontend Server (Port 8006)]**
- ↓
**[Backend Server]**
- ↙     ↓     ↘
**[Storage] [Models] [RAG Systems]**

##### Component Relationships

a) Frontend-Backend Integration:
- REST API calls between frontend components and corresponding backend routers
- WebSocket connections for real-time updates

b) Backend Services:
- Auth.py to all protected routes
- Storage interaction flows
- Model and RAG management workflows

##### Detailed Component Breakdown

Frontend Section:
**[Main App Container]**
- Model Management
- ModelList
- CreateModel
- EditModel
- RAG Management
- RAGList
- CreateRAG
- EditRAG
- Configuration
- User Management

Backend Section:
**[Backend Server]**
- Authentication Service
- Router Layer
- Model Router
- RAG Router
- Config Router
- User Router
- Storage Layer
- External Services Interface

##### Additional Notes

- Separation between the frontend (Port 8006) and backend servers
- Python package structure
- Auto-coder.chat integration
- Configuration file locations
- Logging paths (william-toolbox-backend.log, william-toolbox-frontend.log)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]:::client
    end

    subgraph "Frontend Server Port 8006"
        UI["Main App Container"]:::frontend
        
        subgraph "Model Management"
            ModelList["Model List"]:::frontend
            CreateModel["Create Model"]:::frontend
            EditModel["Edit Model"]:::frontend
        end
        
        subgraph "RAG Management"
            RAGList["RAG List"]:::frontend
            CreateRAG["Create RAG"]:::frontend
            EditRAG["Edit RAG"]:::frontend
        end
        
        subgraph "Other Components"
            Config["Configuration"]:::frontend
            UserMgmt["User Management"]:::frontend
            WorkFlow["Workflow View"]:::frontend
            Chat["Chat Interface"]:::frontend
        end
    end

    subgraph "Backend Server"
        Auth["Authentication Service"]:::backend
        
        subgraph "Routers"
            ModelRouter["Model Router"]:::backend
            RAGRouter["RAG Router"]:::backend
            ConfigRouter["Config Router"]:::backend
            UserRouter["User Router"]:::backend
            ChatRouter["Chat Router"]:::backend
        end
        
        subgraph "Storage Layer"
            JsonStorage["JSON Storage"]:::storage
            ModelStorage["Models Storage"]:::storage
            ConfigStorage["Config Storage"]:::storage
            SuperAnalysis["Super Analysis Storage"]:::storage
        end
        
        subgraph "Logging"
            BackendLog["Backend Log"]:::logging
            FrontendLog["Frontend Log"]:::logging
        end
    end

    subgraph "External Services"
        Models["AI Models"]:::external
        RAGSystems["RAG Systems"]:::external
        AutoCoder["Auto-Coder Actions"]:::external
    end

    %% Connections
    Browser --> UI
    UI --> ModelList & RAGList & Config & UserMgmt & WorkFlow & Chat
    ModelList & CreateModel & EditModel --> ModelRouter
    RAGList & CreateRAG & EditRAG --> RAGRouter
    Config --> ConfigRouter
    UserMgmt --> UserRouter
    Chat --> ChatRouter
    
    ModelRouter & RAGRouter & ConfigRouter & UserRouter & ChatRouter --> Auth
    Auth --> JsonStorage
    JsonStorage --> ModelStorage & ConfigStorage & SuperAnalysis
    
    ModelRouter --> Models
    RAGRouter --> RAGSystems
    ChatRouter --> AutoCoder

    %% Click Events
    click ModelList "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/ModelList.tsx"
    click CreateModel "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/CreateModel.tsx"
    click EditModel "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/EditModel.tsx"
    click RAGList "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/RAGList.tsx"
    click CreateRAG "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/CreateRAG.tsx"
    click EditRAG "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/EditRAG.tsx"
    click Config "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/ConfigList.tsx"
    click UserMgmt "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/UserManagement.tsx"
    click WorkFlow "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/WorkflowView.tsx"
    click Chat "https://github.com/allwefantasy/william-toolbox/blob/master/frontend/src/components/Chat.tsx"
    click Auth "https://github.com/allwefantasy/william-toolbox/blob/master/src/williamtoolbox/server/auth.py"
    click ModelRouter "https://github.com/allwefantasy/william-toolbox/blob/master/src/williamtoolbox/server/model_router.py"
    click RAGRouter "https://github.com/allwefantasy/william-toolbox/blob/master/src/williamtoolbox/server/rag_router.py"
    click ConfigRouter "https://github.com/allwefantasy/william-toolbox/blob/master/src/williamtoolbox/server/config_router.py"
    click UserRouter "https://github.com/allwefantasy/william-toolbox/blob/master/src/williamtoolbox/server/user_router.py"
    click ChatRouter "https://github.com/allwefantasy/william-toolbox/blob/master/src/williamtoolbox/server/chat_router.py"
    click JsonStorage "https://github.com/allwefantasy/william-toolbox/blob/master/src/williamtoolbox/storage/json_file.py"
    click ModelStorage "https://github.com/allwefantasy/william-toolbox/blob/master/models.json"
    click ConfigStorage "https://github.com/allwefantasy/william-toolbox/blob/master/config.json"
    click SuperAnalysis "https://github.com/allwefantasy/william-toolbox/blob/master/super_analysis.json"
    click BackendLog "https://github.com/allwefantasy/william-toolbox/blob/master/william-toolbox-backend.log"
    click FrontendLog "https://github.com/allwefantasy/william-toolbox/blob/master/william-toolbox-frontend.log"
    click AutoCoder "https://github.com/allwefantasy/william-toolbox/tree/master/auto-coder-actions/"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef frontend fill:#a8d1ff,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef storage fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef logging fill:#D3D3D3,stroke:#333,stroke-width:1px
```
