# simonccc/kopsrox architecture

> Architecture diagram of the GitHub repository simonccc/kopsrox, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/simonccc/kopsrox
- Repository: https://github.com/simonccc/kopsrox

## Overview

##### Main Components Identification

a) Core Application Layer:
- Main script (kopsrox.py)
- Configuration handling (lib/kopsrox_config.py, lib/kopsrox_ini.py)
- Command modules (lib/verb_*.py files)

b) Infrastructure Layer:
- ProxmoxVE integration (lib/kopsrox_proxmox.py)
- K3s cluster management (lib/kopsrox_k3s.py)
- Kube-vip integration (lib/kubevip/)
- ETCD backup/restore functionality

**User Interface Layer**

**Configuration Layer**

**Core Logic Layer**

**Infrastructure Layer**

**External Systems**

##### Component Relationships

- User input → Configuration handling
- Configuration → Core logic modules
- Core logic → Infrastructure components
- Infrastructure → External systems (ProxmoxVE, S3 storage)

##### Specific Elements

a) User Interface Components:
- CLI interface (kopsrox.py)
- Configuration file parsing
- Command verb handlers

b) Core Components:
- Cluster management
- Node operations
- ETCD backup/restore
- Image management

c) Infrastructure Integration:
- ProxmoxVE API interaction
- K3s cluster operations
- Kube-vip HA setup
- S3 storage integration

##### Additional Details

Annotations for:
- Configuration file locations
- API endpoints
- Storage locations
- Command flow paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef config fill:#90CAF9,stroke:#1565C0,color:black
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef infra fill:#FF9800,stroke:#F57C00,color:white
    classDef external fill:#9E9E9E,stroke:#616161,color:white
    classDef storage fill:#795548,stroke:#5D4037,color:white
    classDef docs fill:#E91E63,stroke:#C2185B,color:white

    %% User Interface Layer
    CLI[CLI Interface]:::cli
    click CLI "https://github.com/simonccc/kopsrox/blob/main/kopsrox.py"

    %% Configuration Layer
    subgraph ConfigLayer[Configuration Management]
        Config[Configuration Handler]:::config
        IniParser[INI Parser]:::config
        MsgHandler[Message Handler]:::config
    end
    click Config "https://github.com/simonccc/kopsrox/blob/main/lib/kopsrox_config.py"
    click IniParser "https://github.com/simonccc/kopsrox/blob/main/lib/kopsrox_ini.py"
    click MsgHandler "https://github.com/simonccc/kopsrox/blob/main/lib/kopsrox_kmsg.py"

    %% Core Logic Layer
    subgraph CoreLayer[Command Modules]
        ClusterCmd[Cluster Operations]:::core
        NodeCmd[Node Management]:::core
        ETCDCmd[ETCD Operations]:::core
        ImageCmd[Image Management]:::core
        K3sCmd[K3s Operations]:::core
    end
    click ClusterCmd "https://github.com/simonccc/kopsrox/blob/main/lib/verb_cluster.py"
    click NodeCmd "https://github.com/simonccc/kopsrox/blob/main/lib/verb_node.py"
    click ETCDCmd "https://github.com/simonccc/kopsrox/blob/main/lib/verb_etcd.py"
    click ImageCmd "https://github.com/simonccc/kopsrox/blob/main/lib/verb_image.py"
    click K3sCmd "https://github.com/simonccc/kopsrox/blob/main/lib/verb_k3s.py"

    %% Infrastructure Layer
    subgraph InfraLayer[Infrastructure Integration]
        ProxmoxAPI[ProxmoxVE API]:::infra
        K3sManager[K3s Manager]:::infra
        KubeVIP[Kube-vip HA]:::infra
    end
    click ProxmoxAPI "https://github.com/simonccc/kopsrox/blob/main/lib/kopsrox_proxmox.py"
    click K3sManager "https://github.com/simonccc/kopsrox/blob/main/lib/kopsrox_k3s.py"
    click KubeVIP "https://github.com/simonccc/kopsrox/blob/main/lib/kubevip/kubevip.yaml"

    %% External Systems
    ProxmoxVE[ProxmoxVE Server]:::external
    S3[S3 Storage]:::storage

    %% Development and Documentation
    subgraph DevDocs[Development & Documentation]
        DevTools[Development Tools]:::docs
        Docs[Documentation]:::docs
    end
    click DevTools "https://github.com/simonccc/kopsrox/tree/main/dev/"
    click Docs "https://github.com/simonccc/kopsrox/tree/main/docs/"

    %% Relationships
    CLI --> Config
    Config --> IniParser
    Config --> MsgHandler
    
    Config --> ClusterCmd
    Config --> NodeCmd
    Config --> ETCDCmd
    Config --> ImageCmd
    Config --> K3sCmd
    
    ClusterCmd --> ProxmoxAPI
    NodeCmd --> ProxmoxAPI
    ETCDCmd --> S3
    ImageCmd --> ProxmoxAPI
    K3sCmd --> K3sManager
    
    ProxmoxAPI --> ProxmoxVE
    K3sManager --> KubeVIP
    KubeVIP --> ProxmoxVE
    
    %% Legend
    subgraph Legend
        L1[CLI Component]:::cli
        L2[Configuration Component]:::config
        L3[Core Component]:::core
        L4[Infrastructure Component]:::infra
        L5[External System]:::external
        L6[Storage]:::storage
        L7[Documentation]:::docs
    end
```
