# notnonex/easytier architecture

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

- Interactive diagram: https://gitdiagram.com/notnonex/easytier
- Repository: https://github.com/notnonex/easytier

## Overview

##### Project’s main components
- Core VPN Node (easytier): This is the heart of the application that handles network connections, peer management, tunneling, routing (NAT traversal, UDP/TCP switching), and service discovery. Look at directories like src/arch, src/connector, src/peer_center, src/tunnel, and src/gateway.
- Command-line Interface (CLI): Commands provided by easytier-cli to inspect nodes, routes, and peers.
- GUI Client (easytier-gui): A Tauri-based GUI that wraps the Rust backend and includes a modern web frontend (Vue or similar). It includes both a JavaScript/TypeScript codebase and a “src-tauri” folder that connects to the main Rust code.
- Web Management Interface (easytier-web): Contains two parts—a “frontend-lib” (providing a reusable component library) and a “frontend” directory for the actual application UI. Also, there is backend logic integrated within the Rust code (in src/ of easytier-web) that handles API requests, session management, and database interactions.
- RPC & Plugin Components: The “easytier-rpc-build” module shows the generation of RPC interfaces used in inter-node communication, while “tauri-plugin-vpnservice” represents an external plugin to extend VPN functionalities, with its own mobile-specific implementations.
- External Communication Interfaces: The README details integration with WireGuard (tunnel configuration via the vpn-portal option), connection with public server clusters, and support for external networking without public IP using shared nodes.

##### Components in layers and highlight their interactions
▪ The Networking Engine (implemented in Rust): Modules for connectors, NAT traversal (UDP hole punching), encryption (WireGuard integration, AES-GCM in peers/encrypt), and tunnel/packet processing.
▪ The Database and Configuration Management: Shown in the “easytier” module under src/common/config and src/db for persistent configuration, routing, and state management.
- Then, include the API/Interface Layer:
▪ Command-line Interface (CLI) interacting with the core for diagnostics.
▪ RPC interfaces that allow inter-node communication, details of which are generated by the easytier-rpc-build module.
- At the application layer, place:
▪ The GUI Client (Tauri-based) that packages frontend (Vue/JS code from easytier-gui/src) with its Rust backend set up in “easytier-gui/src-tauri”.
▪ The Web Management Interface (front end and backend components from the easytier-web folder). This part can be diagrammed as an independent subsystem interfacing with the core node.
▪ The Mobile VPN Plugin (tauri-plugin-vpnservice), with connections to the core, providing mobile service integration.
- Finally, denote external interactions:
▪ WireGuard Client Connection (illustrating how a mobile client uses the WireGuard configuration provided by easytier-cli).
▪ Public Shared Node Servers that allow nodes behind NAT and without public IP to connect.
▪ Integration with external services (like updates via GitHub actions, build scripts, etc.).

##### Architectural patterns and design principles
- Modularity: Each major feature (core networking, GUI, web management, plugins) is kept in separate directories/repositories, which suggests a clear separation of concerns.
- Layered Architecture: The networking engine supports multiple interfaces (CLI, GUI, Web, and plugins) through a well-defined API and RPC mechanism.
- Cross-platform considerations: Special handling for Android and potential iOS support is visible in separate directories.
- Extensibility: The use of plugins (tauri-plugin-vpnservice) and modular design in the project structure hint at a strategy aiming for ease of adding new protocols or features in the future.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Interfaces Layer
    subgraph "External Interfaces"
        WG["WireGuard Client"]:::external
        PS["Public Shared Node Servers"]:::external
    end

    %% API/Interface Layer
    subgraph "API/Interface Layer"
        CLI["CLI Tool\n(inspect nodes, routes, peers)"]:::rust
        RPC["RPC Services\n(RPC Generation)"]:::rust
    end

    %% Application Layer
    subgraph "Application Layer"
        GUI["GUI Client\n(Tauri-based, frontend & src-tauri)"]:::frontend
        WEB["Web Management Interface\n(frontend-lib, frontend, backend API)"]:::frontend
        VPN["VPN Service Plugin\n(mobile VPN integration)"]:::mobile
    end

    %% Core Networking Layer
    subgraph "Core Networking Layer"
        CORE["EasyTier Core Node"]:::rust
        subgraph "Core Modules"
            ARCH["Network Connections\n(arch, connector)"]:::rust
            PEER["Peer Management\n(peer_center, peers)"]:::rust
            TUNNEL["Tunneling\n(tunnel)"]:::rust
            GATEWAY["Gateway Functions\n(gateway)"]:::rust
        end
        CONFIG["Database & Configuration\n(src/common/config, src/db)"]:::rust
    end

    %% Interactions from API/Interface Layer to Core
    CLI -->|"commands"| CORE
    RPC -->|"RPC calls"| CORE

    %% Interactions from Application Layer to Core
    GUI -->|"frontend requests"| CORE
    WEB -->|"API calls"| CORE
    VPN -->|"plugin integration"| CORE

    %% External interactions with Core/Interfaces
    WG -->|"configures via CLI"| CLI
    PS -->|"connects to"| CORE

    %% Internal Core Module interactions (for clarity)
    CORE --- ARCH
    CORE --- PEER
    CORE --- TUNNEL
    CORE --- GATEWAY
    CORE --- CONFIG

    %% Click Events
    click CORE "https://github.com/notnonex/easytier/tree/main/easytier/src"
    click CLI "https://github.com/notnonex/easytier/blob/main/easytier/src/easytier-cli.rs"
    click GUI "https://github.com/notnonex/easytier/tree/main/easytier-gui"
    click WEB "https://github.com/notnonex/easytier/tree/main/easytier-web"
    click RPC "https://github.com/notnonex/easytier/tree/main/easytier-rpc-build"
    click VPN "https://github.com/notnonex/easytier/tree/main/tauri-plugin-vpnservice"

    %% Styles
    classDef rust fill:#f6d365,stroke:#e09c00,stroke-width:2px;
    classDef frontend fill:#a2d2ff,stroke:#0096c7,stroke-width:2px;
    classDef mobile fill:#ffafcc,stroke:#d00000,stroke-width:2px;
    classDef external fill:#d3f8e2,stroke:#1b4332,stroke-width:2px;
```
