# burnsbert/comfyui-ebu-lmstudio architecture

> Architecture diagram of the GitHub repository burnsbert/comfyui-ebu-lmstudio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/burnsbert/comfyui-ebu-lmstudio
- Repository: https://github.com/burnsbert/comfyui-ebu-lmstudio

## Overview

##### Project Type and Purpose
- This is a full-stack LLM gateway and AI asset management system ("New API")
- Frontends: a React/Vite SPA under **web/** and an Electron desktop client under **electron/**
- Backend: a Go-based HTTP API server (entry point **main.go**), using Gin for routing, layered into routers, middleware, controllers, services, models, and common utilities
- Core purpose: receive user requests, enforce auth/quotas, route to downstream LLMs (OpenAI, Claude, Gemini, etc.), perform format conversions, billing, caching, analytics, and persist data

##### File Structure & Architectural Insights
- Top-level “layers”:
- **router/** – API endpoints grouping (api, relay, web, dashboard)
- **middleware/** – request preprocessing (auth, rate-limit, logging, CORS, etc.)
- **controller/** – HTTP handlers implementing business flows
- **service/** – core business logic, external calls, billing, caching
- **model/** + **common/database.go** – ORM/data objects and DB access
- **relay/** – adapter implementations for each external LLM provider, organized by channel
- **oauth/** – OAuth provider registry and handling
- **pkg/** – reusable libraries (cachex, ionet)
- **setting/** – runtime configuration definitions (rate limits, quotas, payment, model settings)
- **types/** + **dto/** – algebraic types, request/response schemas
- **web/** + **electron/** – two UIs consuming the same HTTP API
- **bin/**, **Dockerfile**, **docker-compose.yml** – build & deployment scripts
- External dependencies: MySQL/PostgreSQL or SQLite, Redis cache, Pyroscope for profiling, multiple third-party LLMs via HTTP/gRPC

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Clients"
        direction TB
        web["Web SPA"]:::frontend
        electron["Electron App"]:::frontend
    end

    %% API Gateway Layer
    subgraph "API Gateway"
        direction TB
        Main["main.go"]:::gateway
        Middleware["Middleware Layer"]:::gateway
        Router["Router Layer"]:::gateway
    end

    %% Business Layer
    subgraph "Business Layer"
        direction TB
        Controllers["Controllers"]:::business
        Services["Services"]:::business
        Relay["Relay Adapters"]:::business
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Models["Models (ORM)"]:::datastore
        SQLDB["SQL Database"]:::datastore
        Redis["Redis Cache"]:::datastore
    end

    %% Utilities
    subgraph "Utilities & Config"
        direction TB
        Common["Common Utilities"]:::utility
        DBUtil["DB Init & Access"]:::utility
        Setting["Configuration & Settings"]:::utility
        DTO["DTO / Schemas"]:::utility
        TypesNode["Types"]:::utility
        Cachex["pkg/cachex"]:::utility
        Ionet["pkg/ionet"]:::utility
    end

    %% External Services
    subgraph "External Systems"
        direction TB
        LLMs["LLM Providers\n(OpenAI, Claude,\nGemini, etc.)"]:::external
        Payment["Payment Gateways\n(Stripe, EPay)"]:::external
        OAuthNode["OAuth Providers\n(Discord, GitHub,\nLinuxDO, OIDC)"]:::external
    end

    %% Deployment
    subgraph "Deployment"
        direction TB
        DockerfileNode["Dockerfile"]:::utility
        DockerCompose["docker-compose.yml"]:::utility
        Bin["bin/"]:::utility
    end

    %% Connections
    web -->|HTTPS| Main
    electron -->|HTTPS| Main
    Main --> Middleware
    Middleware --> Router
    Router --> Controllers
    Controllers --> Services
    Services --> Models
    Models --> SQLDB
    Services --> Redis
    Services --> Relay
    Relay --> LLMs
    Services --> Payment
    Services --> OAuthNode

    %% Utilities Connections
    Services --> Common
    Services --> Setting
    Controllers --> DTO
    Controllers --> TypesNode
    Common --> DBUtil
    Common --> Cachex
    Common --> Ionet

    %% Deployment connections
    Main --> DockerfileNode
    Main --> DockerCompose
    Main --> Bin

    %% Click Events
    click web "https://github.com/quantumnous/new-api/tree/main/web/"
    click electron "https://github.com/quantumnous/new-api/tree/main/electron/"
    click Main "https://github.com/quantumnous/new-api/blob/main/main.go"
    click Middleware "https://github.com/quantumnous/new-api/tree/main/middleware/"
    click Router "https://github.com/quantumnous/new-api/tree/main/router/"
    click Controllers "https://github.com/quantumnous/new-api/tree/main/controller/"
    click Services "https://github.com/quantumnous/new-api/tree/main/service/"
    click Models "https://github.com/quantumnous/new-api/tree/main/model/"
    click DBUtil "https://github.com/quantumnous/new-api/blob/main/common/database.go"
    click Common "https://github.com/quantumnous/new-api/tree/main/common/"
    click Relay "https://github.com/quantumnous/new-api/tree/main/relay/"
    click OAuthNode "https://github.com/quantumnous/new-api/tree/main/oauth/"
    click Cachex "https://github.com/quantumnous/new-api/tree/main/pkg/cachex/"
    click Ionet "https://github.com/quantumnous/new-api/tree/main/pkg/ionet/"
    click Setting "https://github.com/quantumnous/new-api/tree/main/setting/"
    click DTO "https://github.com/quantumnous/new-api/tree/main/dto/"
    click TypesNode "https://github.com/quantumnous/new-api/tree/main/types/"
    click Bin "https://github.com/quantumnous/new-api/tree/main/bin/"
    click DockerfileNode "https://github.com/quantumnous/new-api/tree/main/Dockerfile"
    click DockerCompose "https://github.com/quantumnous/new-api/blob/main/docker-compose.yml"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000
    classDef gateway fill:#90EE90,stroke:#000
    classDef business fill:#FFA500,stroke:#000
    classDef datastore fill:#D3D3D3,stroke:#000
    classDef utility fill:#F0E68C,stroke:#000
    classDef external fill:#DDA0DD,stroke:#000
```
