# truenas/webui architecture

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

- Interactive diagram: https://gitdiagram.com/truenas/webui
- Repository: https://github.com/truenas/webui

## Overview

##### High-Level Architecture Components

a. Frontend Layer:
- Angular Application (Main UI)
- Core Modules
- Feature Modules
- Shared Components
- State Management (NgRx Store)

b. Communication Layer:
- WebSocket Service
- REST API Service
- Authentication Service

c. Backend Integration:
- TrueNAS Core/Scale System
- WebSocket Connection
- API Endpoints

##### Key Components

a. Core Infrastructure:
- Authentication Module
- WebSocket Handler
- Global Store
- Router/Navigation System
- Translation System

b. Feature Modules:
- Storage Management
- Network Configuration
- System Settings
- Virtual Machines
- Applications
- Backup/Restore
- Monitoring/Reporting

c. Shared Services:
- Error Handling
- Dialog Service
- Notification System
- Form Management
- Schema Service

##### Details

a. Module Relationships:
- How feature modules interact with core services
- Data flow between components
- Authentication/authorization paths

b. State Management:
- Store/reducer connections
- Action/effect flows
- Subscription patterns

##### Technical Specifications

Notes about:
- Angular version
- Node.js requirements
- WebSocket protocol
- State management patterns
- Module lazy loading

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        direction TB
        Forms["Forms Module"]:::shared
        Dialog["Dialog Module"]:::shared
        Tables["Tables Module"]:::shared
        Charts["Charts Module"]:::shared
        Icons["Icons Module"]:::shared
    end

    subgraph FM["Feature Modules Layer"]
        direction TB
        Storage["Storage Management"]:::feature
        Network["Network Configuration"]:::feature
        System["System Settings"]:::feature
        VM["Virtual Machines"]:::feature
        Apps["Applications"]:::feature
        Backup["Backup/Restore"]:::feature
        Monitor["Monitoring/Reporting"]:::feature
    end

    subgraph Core["Core Services Layer"]
        direction TB
        Auth["Authentication Module"]:::core
        WebSocket["WebSocket Handler"]:::core
        Store["Global Store"]:::core
        Router["Router System"]:::core
        Trans["Translation System"]:::core
    end

    subgraph State["State Management"]
        direction TB
        StoreRoot["Store Root"]:::state
        ServicesStore["Services Store"]:::state
        SysConfigStore["System Config Store"]:::state
        RouterStore["Router Store"]:::state
    end

    subgraph Comm["Communication Layer"]
        direction TB
        WSService["WebSocket Service"]:::comm
        RestAPI["REST API Service"]:::comm
        AuthService["Authentication Service"]:::comm
    end

    subgraph Backend["Backend Integration"]
        direction TB
        TrueNAS["TrueNAS Core/Scale"]:::backend
    end

    %% Connections
    UI --> FM
    FM --> Core
    Core --> Comm
    Comm --> Backend
    Core --> State
    FM --> State

    %% Click Events
    click Forms "https://github.com/truenas/webui/tree/master/src/app/modules/forms/"
    click Dialog "https://github.com/truenas/webui/tree/master/src/app/modules/dialog/"
    click Tables "https://github.com/truenas/webui/tree/master/src/app/modules/ix-table/"
    click Charts "https://github.com/truenas/webui/tree/master/src/app/modules/charts/"
    click Icons "https://github.com/truenas/webui/tree/master/src/app/modules/ix-icon/"
    
    click Storage "https://github.com/truenas/webui/tree/master/src/app/pages/storage/"
    click Network "https://github.com/truenas/webui/tree/master/src/app/pages/network/"
    click System "https://github.com/truenas/webui/tree/master/src/app/pages/system/"
    click VM "https://github.com/truenas/webui/tree/master/src/app/pages/vm/"
    click Apps "https://github.com/truenas/webui/tree/master/src/app/pages/apps/"
    click Backup "https://github.com/truenas/webui/tree/master/src/app/pages/data-protection/"
    click Monitor "https://github.com/truenas/webui/tree/master/src/app/pages/reports-dashboard/"
    
    click Auth "https://github.com/truenas/webui/tree/master/src/app/modules/auth/"
    click WebSocket "https://github.com/truenas/webui/tree/master/src/app/modules/websocket/"
    click Store "https://github.com/truenas/webui/tree/master/src/app/services/global-store/"
    click Router "https://github.com/truenas/webui/tree/master/src/app/services/navigation/"
    click Trans "https://github.com/truenas/webui/tree/master/src/app/modules/language/"
    
    click WSService "https://github.com/truenas/webui/blob/master/src/app/modules/websocket/websocket-handler.service.ts"
    click RestAPI "https://github.com/truenas/webui/blob/master/src/app/modules/websocket/api.service.ts"
    click AuthService "https://github.com/truenas/webui/blob/master/src/app/modules/auth/auth.service.ts"
    
    click StoreRoot "https://github.com/truenas/webui/tree/master/src/app/store/"
    click ServicesStore "https://github.com/truenas/webui/tree/master/src/app/store/services/"
    click SysConfigStore "https://github.com/truenas/webui/tree/master/src/app/store/system-config/"
    click RouterStore "https://github.com/truenas/webui/tree/master/src/app/store/router/"

    %% Styles
    classDef core fill:#2196F3,color:white
    classDef feature fill:#4CAF50,color:white
    classDef comm fill:#FFC107,color:black
    classDef backend fill:#9E9E9E,color:white
    classDef state fill:#FF5722,color:white
    classDef shared fill:#9C27B0,color:white

    %% Legend
    subgraph Legend
        direction TB
        L1["Core Components"]:::core
        L2["Feature Modules"]:::feature
        L3["Communication Services"]:::comm
        L4["Backend Systems"]:::backend
        L5["State Management"]:::state
        L6["Shared Components"]:::shared
    end
```
