# 0xjacky/nginx-ui architecture

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

- Interactive diagram: https://gitdiagram.com/0xjacky/nginx-ui
- Repository: https://github.com/0xjacky/nginx-ui

## Overview

##### Main Components
- Frontend: Represent the “app” directory that houses the Vue 3 application. This component is responsible for the user interface and interacts with the backend through RESTful APIs.
- Backend API: This is implemented in Go, as seen in the “api” and “internal” directories. It contains modules for authentication, certificate management, cluster management, system settings, logging (Nginx logs), notification, and more.
- External / Third-Party Services: Highlight integrations such as:
– Let's Encrypt / ACME for certificate management,
– ChatGPT integration for the assistant,
– External notification services (like Telegram, Dingding, Lark, etc.),
– Possibly DNS providers for auto certificate renewals.
- Infrastructure & Deployment: Include components such as Docker containers (Dockerfile, docker-compose for demo and deployment), systemd services, and configuration scripts that have their dedicated directories.
- Auxiliary Tools: These include CLI commands under “cmd”, build scripts (go generate, makefile references) and devcontainer files for development environment automation.

##### Relationships and Interactions
- ORM’s connection from the backend to the Database.
- Flows from the backend to external services (e.g., certificate authority for auto-renewal or notifications).
- The Nginx reverse proxy configuration is also a key integration point – you might show Nginx UI sitting behind or within a proxy setup.

##### Architectural Patterns / Design Principles
- Separation of concerns: Clear separation between frontend and backend layers.
- Modular design: The backend’s code is decomposed into multiple specialized modules (e.g., configurations, certificates, analytics, notifications, system, user management).
- API-driven architecture: All major functionalities are exposed as RESTful endpoints.
- Containerization and deployment scripting: Dockerfiles, devcontainer settings, and installation scripts are used to create reproducible environments.
- Single executable: The final delivery is a compiled binary that encapsulates the whole backend stack.

##### Relevant Technologies
- Frontend: Vue 3, Vite, TypeScript, and Ant Design Vue
- Backend: Go, Gin Web Framework, GORM, and various internal helper packages
- External Tools/Integrations: lego for ACME/Let’s Encrypt, various DNS providers, and ChatGPT integration.
- Infrastructure: Docker, Docker Compose, systemd, and Nginx (reverse proxy and log management)

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Frontend Layer"
        FE["Frontend UI (Vue 3)"]:::frontend
    end

    subgraph "Backend Layer"
        BE["Backend API (Go, Gin, GORM)"]:::backend
        subgraph "API Modules"
            CERT["Certificate Management"]:::module
            CLUSTER["Cluster Management"]:::module
            NOTIF["Notification Service"]:::module
            LOG["Logging (Nginx)"]:::module
        end
    end

    subgraph "Persistence Layer"
        DB["Database (ORM/GORM)"]:::db
    end

    subgraph "External Services"
        LETS["Let's Encrypt / ACME"]:::external
        DNS["DNS Providers"]:::external
        CHATGPT["ChatGPT Integration"]:::external
        EXTNOTIF["External Notifications"]:::external
    end

    subgraph "Deployment & Infrastructure"
        DOCKER["Docker & Containerization"]:::deployment
        SYSTEMD["systemd Service"]:::deployment
        PROXY["Nginx Reverse Proxy"]:::deployment
    end

    subgraph "Auxiliary Tools"
        AUX["CLI & Build Scripts"]:::auxiliary
    end

    FE -->|"HTTP_calls"| BE
    BE -->|"calls"| CERT
    BE -->|"calls"| CLUSTER
    BE -->|"calls"| NOTIF
    BE -->|"calls"| LOG
    BE -->|"ORM_access"| DB
    CERT -->|"integrates"| LETS
    CERT -->|"integrates"| DNS
    NOTIF -->|"integrates"| EXTNOTIF
    NOTIF -->|"integrates"| CHATGPT
    DOCKER -->|"deploys"| BE
    SYSTEMD -->|"manages"| BE
    PROXY -->|"routes_to"| FE
    AUX -->|"supports"| BE

    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef module fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef db fill:#C0C0C0,stroke:#000,stroke-width:2px;
    classDef external fill:#EE82EE,stroke:#000,stroke-width:2px;
    classDef deployment fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef auxiliary fill:#FFC0CB,stroke:#000,stroke-width:2px;

    click FE "https://github.com/0xjacky/nginx-ui/tree/dev/app/"
    click BE "https://github.com/0xjacky/nginx-ui/tree/dev/api/"
    click BE "https://github.com/0xjacky/nginx-ui/tree/dev/internal/"
    click CERT "https://github.com/0xjacky/nginx-ui/tree/dev/api/certificate/"
    click CERT "https://github.com/0xjacky/nginx-ui/tree/dev/internal/cert/"
    click CLUSTER "https://github.com/0xjacky/nginx-ui/tree/dev/api/cluster/"
    click CLUSTER "https://github.com/0xjacky/nginx-ui/tree/dev/internal/cluster/"
    click NOTIF "https://github.com/0xjacky/nginx-ui/tree/dev/api/external_notify/"
    click NOTIF "https://github.com/0xjacky/nginx-ui/tree/dev/api/notification/"
    click NOTIF "https://github.com/0xjacky/nginx-ui/tree/dev/api/openai/"
    click NOTIF "https://github.com/0xjacky/nginx-ui/tree/dev/internal/notification/"
    click NOTIF "https://github.com/0xjacky/nginx-ui/tree/dev/internal/chatbot/"
    click LOG "https://github.com/0xjacky/nginx-ui/tree/dev/api/nginx_log/"
    click LOG "https://github.com/0xjacky/nginx-ui/tree/dev/internal/nginx_log/"
    click DB "https://github.com/0xjacky/nginx-ui/tree/dev/model/"
    click DB "https://github.com/0xjacky/nginx-ui/tree/dev/query/"
    click DOCKER "https://github.com/0xjacky/nginx-ui/tree/dev/Dockerfile"
    click DOCKER "https://github.com/0xjacky/nginx-ui/blob/dev/docker-compose-demo.yml"
    click DOCKER "https://github.com/0xjacky/nginx-ui/tree/dev/resources/docker/"
    click DOCKER "https://github.com/0xjacky/nginx-ui/tree/dev/.devcontainer/"
    click SYSTEMD "https://github.com/0xjacky/nginx-ui/blob/dev/nginx-ui.service"
    click AUX "https://github.com/0xjacky/nginx-ui/tree/dev/cmd/"
    click AUX "https://github.com/0xjacky/nginx-ui/blob/dev/gen.sh"
```
