# lablup/backend.ai-webui architecture

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

- Interactive diagram: https://gitdiagram.com/lablup/backend.ai-webui
- Repository: https://github.com/lablup/backend.ai-webui

## Overview

##### Main Components Architecture

The system should be represented with these primary components:

a) Frontend Layer:
- React Components (in /react/src/components)
- Lit Elements (in /src/components)
- Web Components Integration
- Theme System
- i18n Internationalization

b) Core Services Layer:
- WebSocket Proxy Service
- Authentication Service
- Resource Management
- Session Management
- Storage Management
- Pipeline Management

c) Integration Layer:
- Backend.AI Client Interface
- GraphQL/Relay Integration
- External Services Connectors

##### Key Relationships to Highlight

- Data flow between React components and Backend.AI server
- WebSocket proxy connections for real-time features
- Authentication flow
- Resource allocation and monitoring paths
- Storage system interactions

##### Detailed Component Breakdown

**Rectangle (Blue): Core UI Components**
- Session Management
- Resource Monitoring
- Storage Explorer
- Pipeline Management

**Hexagon (Green): Service Components**
- WebSocket Proxy
- Authentication
- Resource Broker
- Task Manager

**Circle (Orange): Integration Points**
- Backend.AI API Client
- GraphQL/Relay Layer
- External Services

##### Specific Implementation Details

Technical stack indicators:
- Lit-element for Web Components
- React for Modern UI
- Electron for Desktop App
- Rollup for Bundling
- GraphQL/Relay for Data Management

##### Deployment Variants

Different deployment scenarios:
**A) Web Deployment**
- [Nginx] → [Backend.AI WebUI] → [WebSocket Proxy] → [Backend.AI Server]

**B) Desktop App Deployment**
- [Electron Shell] → [Backend.AI WebUI] → [Embedded WS Proxy] → [Backend.AI Server]

##### Cross-cutting Concerns

- Security Layer (Authentication/Authorization)
- Internationalization System
- Theme Management
- Error Handling
- Resource Monitoring

##### Development Tools Integration

Development support systems:
- Testing Framework (Playwright/Jest)
- Build System (Rollup)
- Package Management (pnpm)
- Development Server

##### Security and authentication flow

Remember to include version information and any relevant configuration dependencies, as the system supports multiple deployment scenarios and configurations.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        RC["React Components"]
        LE["Lit Elements"]
        TH["Theme System"]
        I18["i18n System"]
        WC["Web Components"]
    end

    subgraph Core_Services
        WS["WebSocket Proxy"]
        AUTH["Authentication"]
        RM["Resource Management"]
        SM["Session Management"]
        STM["Storage Management"]
        PM["Pipeline Management"]
    end

    subgraph Integration
        CL["Backend.AI Client"]
        GQL["GraphQL/Relay"]
        EXT["External Services"]
    end

    subgraph Development
        TF["Testing Framework"]
        BS["Build System"]
        DS["Dev Server"]
    end

    %% Relationships
    RC --> WC
    LE --> WC
    WC --> CL
    WC --> WS
    AUTH --> CL
    RM --> CL
    SM --> WS
    STM --> CL
    PM --> GQL
    GQL --> CL
    WS --> EXT

    %% Cross-cutting
    TH -.-> WC
    I18 -.-> WC
    AUTH -.-> WC

    %% Styling
    classDef frontend fill:#a8d1ff
    classDef service fill:#90EE90
    classDef integration fill:#FFB347
    classDef dev fill:#d3d3d3

    class RC,LE,TH,I18,WC frontend
    class WS,AUTH,RM,SM,STM,PM service
    class CL,GQL,EXT integration
    class TF,BS,DS dev

    %% Click events
    click RC "https://github.com/lablup/backend.ai-webui/tree/main//react/src/components/"
    click LE "https://github.com/lablup/backend.ai-webui/tree/main//src/components/"
    click TH "https://github.com/lablup/backend.ai-webui/blob/main//resources/theme.json"
    click I18 "https://github.com/lablup/backend.ai-webui/tree/main//resources/i18n/"
    click WS "https://github.com/lablup/backend.ai-webui/tree/main//src/wsproxy/"
    click AUTH "https://github.com/lablup/backend.ai-webui/blob/main//src/components/backend-ai-login.ts"
    click RM "https://github.com/lablup/backend.ai-webui/blob/main//src/components/backend-ai-resource-broker.ts"
    click SM "https://github.com/lablup/backend.ai-webui/blob/main//src/components/backend-ai-session-view.ts"
    click STM "https://github.com/lablup/backend.ai-webui/blob/main//src/components/backend-ai-storage-list.ts"
    click PM "https://github.com/lablup/backend.ai-webui/blob/main//react/src/components/BAIPipelineRunner.tsx"
    click CL "https://github.com/lablup/backend.ai-webui/blob/main//src/lib/backend.ai-client-es6.js"
    click GQL "https://github.com/lablup/backend.ai-webui/blob/main//react/src/RelayEnvironment.ts"
    click TF "https://github.com/lablup/backend.ai-webui/tree/main//e2e/"
```
