# r82wei/kde-cli architecture

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

- Interactive diagram: https://gitdiagram.com/r82wei/kde-cli
- Repository: https://github.com/r82wei/kde-cli

## Overview

##### Project type and purpose
- KDE-cli is a shell-script–based command-line tool that streamlines local Kubernetes development and deployment workflows.
- It integrates Kind/k3d cluster provisioning, CI/CD scripts (build/deploy/undeploy), volume mounting, service exposure (port-forward/ngrok/Cloudflare Tunnel), and dashboards (K9s/Web UI).

##### File structure
- Top-level:
- install.sh, uninstall.sh, kde.sh (entrypoint)
- dockerfiles/ (build definitions for tunnel proxies, deploy environments, k3d, kind, ngrok)
- scripts/ (each subfolder is a “kde <command>” module: start, stop, status, project, deploy, expose, ngrok, cloudflare-tunnel, k9s, dashboard, etc.)
- scripts/utils/ (shared helpers: environment setup for k3d/kind, tunnel scripts, dashboard scripts, project scaffolding)
- test/, test.sh: integration tests for commands.

##### README for additional insights
- Supports multi-environment management (Kind, K3d), multi-project CI/CD, reversible deploy flows, hot-reload via volume mounts, and multiple exposure methods.
- No built-in programming language dependencies—pure shell + Docker.

##### Elements
– CLI layer
– Utilities layer
– External runtimes/services layer
– “kde.sh → module loader → module script → utils”
– “module script → Docker CLI → Kind/k3d clusters → Kubernetes API”
– “expose modules → ngrok or Cloudflare Tunnel images → public endpoint”
– “dashboard modules → k9s or Web UI Pod → user browser”
– Shell scripts (blue)
– Docker/K8s (orange)
– External cloud services (green)
– User-facing UI components (purple)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% CLI Layer
    subgraph "CLI Layer"
        User["User"]:::external
        Entry["kde.sh (EntryPoint)"]:::shell_script
        click Entry "https://github.com/r82wei/kde-cli/blob/main/kde.sh"
    end

    %% Command Modules
    subgraph "Command Modules"
        direction TB
        DR["Dispatcher"]:::shell_script
        click DR "https://github.com/r82wei/kde-cli/blob/main/kde.sh"

        subgraph "Environment Management"
            Start["start"]:::shell_script
            click Start "https://github.com/r82wei/kde-cli/blob/main/scripts/start/command.sh"
            Stop["stop"]:::shell_script
            click Stop "https://github.com/r82wei/kde-cli/blob/main/scripts/stop/command.sh"
            Status["status"]:::shell_script
            click Status "https://github.com/r82wei/kde-cli/blob/main/scripts/status/command.sh"
        end

        subgraph "Project Management"
            Project["project"]:::shell_script
            click Project "https://github.com/r82wei/kde-cli/blob/main/scripts/project/command.sh"
            Projects["projects"]:::shell_script
            click Projects "https://github.com/r82wei/kde-cli/blob/main/scripts/projects/command.sh"
        end

        subgraph "CI/CD Pipeline"
            DeployEnvBuild["deploy-env Build"]:::docker_k8s
            click DeployEnvBuild "https://github.com/r82wei/kde-cli/tree/main/dockerfiles/deploy-env/Dockerfile"
            click DeployEnvBuild "https://github.com/r82wei/kde-cli/blob/main/dockerfiles/deploy-env/build.sh"
        end

        subgraph "Service Exposure"
            Expose["expose"]:::shell_script
            click Expose "https://github.com/r82wei/kde-cli/blob/main/scripts/expose/command.sh"
            Ngrok["ngrok"]:::shell_script
            click Ngrok "https://github.com/r82wei/kde-cli/blob/main/scripts/ngrok/command.sh"
            CF["cloudflare-tunnel"]:::shell_script
            click CF "https://github.com/r82wei/kde-cli/blob/main/scripts/cloudflare-tunnel/command.sh"
        end

        subgraph "Dashboard"
            K9s["k9s"]:::shell_script
            click K9s "https://github.com/r82wei/kde-cli/blob/main/scripts/k9s/command.sh"
            WebUI["dashboard"]:::shell_script
            click WebUI "https://github.com/r82wei/kde-cli/blob/main/scripts/dashboard/command.sh"
        end
    end

    %% Utility Library
    subgraph "Utility Library"
        direction TB
        EnvUtils["environment/"]:::shell_script
        click EnvUtils "https://github.com/r82wei/kde-cli/tree/main/scripts/utils/environment/"
        CloudflareUtil["cloudflare.sh"]:::shell_script
        click CloudflareUtil "https://github.com/r82wei/kde-cli/blob/main/scripts/utils/cloudflare.sh"
        DashboardUtil["dashboard.sh"]:::shell_script
        click DashboardUtil "https://github.com/r82wei/kde-cli/blob/main/scripts/utils/dashboard.sh"
        K9sUtil["k9s.sh"]:::shell_script
        click K9sUtil "https://github.com/r82wei/kde-cli/blob/main/scripts/utils/k9s.sh"
        NgrokUtil["ngrok.sh"]:::shell_script
        click NgrokUtil "https://github.com/r82wei/kde-cli/blob/main/scripts/utils/ngrok.sh"
        ProjectUtil["project.sh"]:::shell_script
        click ProjectUtil "https://github.com/r82wei/kde-cli/blob/main/scripts/utils/project.sh"
        ProjectsUtil["projects.sh"]:::shell_script
        click ProjectsUtil "https://github.com/r82wei/kde-cli/blob/main/scripts/utils/projects.sh"
    end

    %% Docker Build Subsystem
    subgraph "Docker Build Subsystem"
        direction TB
        CFProxyImg["cloudflare-tunnel-proxy"]:::docker_k8s
        click CFProxyImg "https://github.com/r82wei/kde-cli/tree/main/dockerfiles/cloudflare-tunnel-proxy/Dockerfile"
        click CFProxyImg "https://github.com/r82wei/kde-cli/blob/main/dockerfiles/cloudflare-tunnel-proxy/build.sh"
        DeployEnvImg["deploy-env"]:::docker_k8s
        click DeployEnvImg "https://github.com/r82wei/kde-cli/tree/main/dockerfiles/deploy-env/Dockerfile"
        click DeployEnvImg "https://github.com/r82wei/kde-cli/blob/main/dockerfiles/deploy-env/build.sh"
        k3dImg["k3d"]:::docker_k8s
        click k3dImg "https://github.com/r82wei/kde-cli/tree/main/dockerfiles/k3d/Dockerfile"
        click k3dImg "https://github.com/r82wei/kde-cli/blob/main/dockerfiles/k3d/build.sh"
        kindImg["kind"]:::docker_k8s
        click kindImg "https://github.com/r82wei/kde-cli/blob/main/dockerfiles/kind/kind.Dockerfile"
        click kindImg "https://github.com/r82wei/kde-cli/blob/main/dockerfiles/kind/build.sh"
        NgrokProxyImg["ngrok-proxy"]:::docker_k8s
        click NgrokProxyImg "https://github.com/r82wei/kde-cli/tree/main/dockerfiles/ngrok-proxy/Dockerfile"
        click NgrokProxyImg "https://github.com/r82wei/kde-cli/blob/main/dockerfiles/ngrok-proxy/build.sh"
    end

    %% External Runtimes & Services
    subgraph "External Runtimes & Services"
        direction TB
        DockerEngine["Docker Engine"]:::docker_k8s
        KindCluster["Kind / k3d Cluster"]:::docker_k8s
        K8sAPI["Kubernetes API Server"]:::docker_k8s
        NgrokService["ngrok Service"]:::external
        CFService["Cloudflare Tunnel Service"]:::external
        K9sCLI["k9s CLI"]:::external
        DashboardUI["kubernetesui/dashboard Web UI"]:::ui
        UserBrowser["User Browser"]:::ui
    end

    %% Connections
    User --> Entry
    Entry --> DR

    DR --> Start
    DR --> Stop
    DR --> Status
    DR --> Project
    DR --> Projects
    DR --> DeployEnvBuild
    DR --> Expose
    DR --> Ngrok
    DR --> CF
    DR --> K9s
    DR --> WebUI

    %% Module to Utils
    Start --> EnvUtils
    Stop --> EnvUtils
    Status --> EnvUtils
    Project --> ProjectUtil
    Projects --> ProjectsUtil
    Ngrok --> NgrokUtil
    CF --> CloudflareUtil
    K9s --> K9sUtil
    WebUI --> DashboardUtil

    %% Environment provisioning
    Start --> k3dImg
    Start --> kindImg
    k3dImg --> DockerEngine
    kindImg --> DockerEngine
    Start --> KindCluster
    KindCluster --> K8sAPI

    %% CI/CD Build
    DeployEnvBuild --> DockerEngine

    %% Service Exposure
    Expose --> DockerEngine
    Expose --> K8sAPI
    Ngrok --> NgrokProxyImg
    NgrokProxyImg --> NgrokService
    CF --> CFProxyImg
    CFProxyImg --> CFService

    %% Dashboard
    K9s --> K9sCLI
    WebUI --> DashboardUI
    DashboardUI --> UserBrowser

    %% Styles
    classDef shell_script fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef docker_k8s fill:#FFE4B5,stroke:#DAA520,stroke-width:1px
    classDef external fill:#E2F0CB,stroke:#78BE20,stroke-width:1px
    classDef ui fill:#F0DBFF,stroke:#A020F0,stroke-width:1px
```
