# jonssonyan/h-ui architecture

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

- Interactive diagram: https://gitdiagram.com/jonssonyan/h-ui
- Repository: https://github.com/jonssonyan/h-ui

## Overview

##### Project type and purpose
- This is a full-stack, web-based administration panel (“H UI”) for managing Hysteria2 VPN servers.
- Frontend: Vue3 + Vite + Element-Plus application.
- Backend: Go monolith offering RESTful APIs, process management, scheduling, persistence, and integration with Hysteria2 and Telegram.

##### File structure
- Top‐level:
- cmd/, main.go – CLI entrypoints for server, version, reset.
- controller/, router/, middleware/, service/, dao/, model/ – classic layered architecture (HTTP routing → controllers → business services → data access → SQLite).
- proxy/ & util/ – wrappers around Hysteria2 processes and auxiliary functions.
- frontend/ – complete Vue3 SPA.
- docker-compose.yml, Dockerfile, install scripts – containerized deployment.
- Data: docs/sql/h_ui_db.sql (schema), local/… (i18n JSON), volumes mounted in docker-compose for /h-ui/data, /h-ui/logs, /h-ui/export.
- External integrations: Telegram notifications (service/telegram.go); scheduled tasks (service/cron.go, middleware/cron.go).

##### README for additional insights
- Purpose: user management, traffic limits, Hysteria2 config/version management, logs, monitoring, multilingual.
- Deployment: bare‐metal with systemd or Docker, configurable volumes and ports.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        Browser["Client Browser"]:::frontend
        SPA["Frontend SPA (Vue3 + Vite)"]:::frontend
    end

    subgraph "Application Layer"
        direction TB
        HTTPServer["API Gateway / HTTP Server"]:::backend
        subgraph "Router & Middleware"
            direction TB
            Router["HTTP Routing"]:::backend
            Middleware["Middleware Pipeline"]:::backend
        end
        subgraph "Controller Layer"
            Controller["Controller Layer (REST Endpoints)"]:::backend
        end
        subgraph "Service Layer"
            ServiceBL["Service Layer (Business Logic)"]:::backend
            CronSched["Cron Scheduler"]:::backend
        end
        subgraph "DAO / Persistence"
            DAOComp["DAO / Persistence (SQLite)"]:::backend
        end
    end

    subgraph "Hysteria2 Management"
        direction TB
        HManager["Hysteria2 Manager"]:::backend
        HDaemon["Hysteria2 Daemon"]:::backend
    end

    subgraph "External Services"
        TelegramAPI["Telegram Bot API"]:::external
    end

    subgraph "Storage Volumes"
        direction TB
        DB["SQLite Database"]:::storage
        Volumes["Config / Logs / Exports"]:::storage
    end

    Browser -->|HTTPS Static Assets| SPA
    SPA -->|AJAX /api/*| HTTPServer
    HTTPServer --> Router
    Router --> Middleware
    Middleware --> Controller
    Controller --> ServiceBL
    ServiceBL --> DAOComp
    ServiceBL --> CronSched
    ServiceBL -->|spawn/manage| HManager
    HManager --> HDaemon
    ServiceBL -->|notifications| TelegramAPI
    DAOComp -->|CRUD Queries| DB
    HTTPServer -->|embedded assets| SPA
    HTTPServer --> Volumes
    HDaemon --> Volumes

    classDef frontend fill:#87CEFA,stroke:#4682B4,color:#000;
    classDef backend fill:#98FB98,stroke:#2E8B57,color:#000;
    classDef external fill:#FFD700,stroke:#DAA520,color:#000;
    classDef storage fill:#D3D3D3,stroke:#A9A9A9,color:#000;

    click SPA "https://github.com/jonssonyan/h-ui/tree/main/frontend/"
    click HTTPServer "https://github.com/jonssonyan/h-ui/blob/main/main.go"
    click HTTPServer "https://github.com/jonssonyan/h-ui/blob/main/cmd/server.go"
    click Router "https://github.com/jonssonyan/h-ui/tree/main/router/"
    click Middleware "https://github.com/jonssonyan/h-ui/tree/main/middleware/"
    click Controller "https://github.com/jonssonyan/h-ui/tree/main/controller/"
    click ServiceBL "https://github.com/jonssonyan/h-ui/tree/main/service/"
    click CronSched "https://github.com/jonssonyan/h-ui/blob/main/service/cron.go"
    click CronSched "https://github.com/jonssonyan/h-ui/blob/main/middleware/cron.go"
    click DAOComp "https://github.com/jonssonyan/h-ui/tree/main/dao/"
    click HManager "https://github.com/jonssonyan/h-ui/tree/main/proxy/"
    click HManager "https://github.com/jonssonyan/h-ui/blob/main/util/hysteria2.go"
    click TelegramAPI "https://github.com/jonssonyan/h-ui/blob/main/service/telegram.go"
    click DB "https://github.com/jonssonyan/h-ui/blob/main/docs/sql/h_ui_db.sql"
```
