# krezh/dextek architecture

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

- Interactive diagram: https://gitdiagram.com/krezh/dextek
- Repository: https://github.com/krezh/dextek

## Overview

<explanation>
1.  Project Type and Purpose
    - This is a GitOps‑driven “home operations” repository. You manage multiple Kubernetes clusters (Talos‑provisioned), infrastructure components (IPXE, OpnSense, RouterOS), and applications via declarative manifests (Kustomize, Helm) in Git.
    - FluxCD operators in each cluster reconcile the manifests. Terraform handles Talos OS provisioning and router/firewall infrastructure. GitHub Actions and Renovate automate CI/CD and dependency updates.

2.  File‑Structure Analysis
    - Top‑level concern separation:
      • clusters/…: per‑cluster overlays (dextek, jotunheim, shared) with apps, namespaces, kustomizations  
      • infrastructure/…: IPXE build scripts, OpnSense/RouterOS configurations, Terraform modules  
      • .github/, Taskfile.yaml, .taskfiles/: CI/CD workflows (GitHub Actions), tasks (Taskfile)  
      • bootstrap/flux, clusters/*/bootstrap: initial Flux and Helmfile setups  
    - Each cluster dir contains:
      • apps/: HelmRelease + Kustomize overlays for apps grouped by domain (auth, databases, network, monitoring, games, etc.)  
      • flux‑system/: Flux operator config (KustomizeController, HelmController, GitRepository, etc.)  
    - Shared components under clusters/shared/templates and clusters/shared/repositories for common Helm/chart definitions.
    - Terraform in clusters/<cluster>/terraform and infrastructure/terraform drives Talos provisioning and router/firewall modules.

3.  README Insights
    - Badges confirm use of Kubernetes, Talos, Flux, Renovate.
    - Highlights cluster age, uptime, node and pod counts—emphasizes full observability/monitoring.

4.  System‑Design Diagram Guidance
    a. Main Components
       - GitHub Repository  
       - CI/CD Pipelines: GitHub Actions (workflows under .github/workflows), Renovate  
       - Terraform Service (CLI or GitHub Actions)  
       - FluxCD Operators in each cluster (KustomizeController, HelmController, NotificationController)  
       - Kubernetes Clusters (dextek, jotunheim) on Talos OS  
       - Infrastructure Hosts (PXE/IPXE builder, OpnSense Firewall, RouterOS)  
       - External Dependencies: Secret stores (Doppler, ExternalSecrets), Container registries (OCI, Helm repos)  
    b. Relationships and Data Flows
       - Developer → GitHub Repo (push manifests, update kustomize overlays)  
       - GitHub Actions → run linting, tests, publish schema, optionally trigger Terraform/apply  
       - Renovate → open PRs for chart/terraform provider updates  
       - FluxCD in-cluster → polls GitHub repo → detects new commits → reconciles Kustomize & HelmRelease resources → Kubernetes API  
       - Terraform → provisions Talos control plane & worker machines, configures network infrastructure (OpnSense, RouterOS)  
       - ExternalSecrets Controller → fetches secrets from Doppler → injects into Kubernetes Secrets  
    c. Architectural Patterns
       - GitOps: single source of truth in Git  
       - Declarative infra: Kustomize overlays and HelmRelease CRDs  
       - Multi‑cluster: per‑cluster overlays under clusters/<cluster>  
       - Modular reuse: shared templates and repositories  
       - Infrastructure as code: Terraform + Talos schema + Taskfile orchestration  
    d. Key Technologies
       - FluxCD (GitRepository, KustomizationController, HelmRelease)  
       - Kustomize & Helm  
       - Terraform (with modules under infrastructure/terraform)  
       - Talos OS for Kubernetes nodes  
       - GitHub Actions & Renovate  
       - ExternalSecrets (Doppler provider)

5.  Tailoring to a GitOps‑Managed Infra Project
    - Emphasize the separation:
      • Infrastructure provisioning (Terraform, OpnSense, IPXE) vs. application delivery (Flux + Helm/Kustomize)  
      • Cluster‑bootstrap → flux-system → apps  
    - Show hierarchy: GitHub Repo → Branches/Overlays → Flux Controllers → Kubernetes resources  
    - Illustrate feedback loops: cluster health metrics flow back to badge endpoints (prometheus, pushgateway)

6.  Diagram Elements to Include
    - Clear labels on each box: e.g., “GitHub Repo: home‑ops”  
    - Directional arrows:  
      • Solid arrows for “push” or “reconcile” flows  
      • Dashed arrows for “monitoring/metrics” or “secret fetch” flows  
    - Color coding or shapes:  
      • Blue rectangles for Git/GitHub components  
      • Green for cluster‑resident controllers & resources  
      • Orange for CI/CD pipelines  
      • Grey for external services (Doppler, OCI registries)  
    - Group related items inside containers:  
      • One container per cluster showing Flux controllers + Kubernetes API + deployed apps  
      • One container for “Infrastructure” with Terraform, IPXE compiler, OpnSense, RouterOS  

7.  Level of Detail
    - Capture every major overlay directory as a component if helpful (e.g., clusters/<cluster>/apps/network)  
    - Don’t go down to individual YAML files—focus on groups (apps, monitoring, network, kube-system)  
    - Highlight controllers (Flux Kustomize, Flux Helm, Terraform) and their targets (machines, clusters)

By following this structure and using the recommended elements, you’ll produce a clear, accurate architecture diagram that reflects the GitOps‑centric, multi‑cluster, multi‑infrastructure nature of this home‑ops project.
</explanation>

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% GitHub Repository
    subgraph "GitHub"
        GH["GitHub Repo: home-ops"]:::github
    end
    Developer["Developer"]:::external -->|push manifests| GH

    %% CI/CD Pipelines
    subgraph "CI/CD Pipelines"
        GHActions["GitHub Actions"]:::cicd
        Renovate["Renovate"]:::cicd
        Taskfile["Taskfile"]:::cicd
    end
    GH --> GHActions
    GH --> Renovate
    GH --> Taskfile

    %% Terraform Service
    subgraph "Terraform Service"
        SharedTF["Shared Terraform Modules"]:::infra
        DexTF["Dextek Terraform Talos"]:::infra
        JotTF["Jotunheim Terraform Talos"]:::infra
    end
    GHActions -->|trigger apply| SharedTF
    GHActions --> DexTF
    GHActions --> JotTF

    %% Infrastructure Hosts
    subgraph "Infrastructure Hosts"
        IPXE["IPXE Builder"]:::infra
        Opn["OpnSense Firewall"]:::infra
        ROS["RouterOS"]:::infra
    end
    SharedTF --> IPXE
    SharedTF --> Opn
    SharedTF --> ROS

    %% Flux Bootstrap
    subgraph "Bootstrap Flux"
        SharedBS["Shared Bootstrap"]:::infra
        DexBS["Dextek Bootstrap"]:::infra
        JotBS["Jotunheim Bootstrap"]:::infra
    end
    SharedBS --> DexBS
    SharedBS --> JotBS

    %% Shared Overlays
    subgraph "Shared Overlays"
        SharedTemplates["Templates"]:::external
        SharedRepos["Repositories"]:::external
    end
    SharedTemplates --> AppsDex
    SharedTemplates --> AppsJot
    SharedRepos --> AppsDex
    SharedRepos --> AppsJot

    %% Cluster: dextek
    subgraph "Cluster: dextek" 
        subgraph "flux-system"
            DexKustomize["KustomizeController"]:::cluster
            DexHelmCtrl["HelmController"]:::cluster
            DexNotif["NotificationController"]:::cluster
        end
        KubeAPI["Kubernetes API"]:::cluster
        AppsDex["Apps Overlays"]:::cluster
        ESDex["ExternalSecrets (Doppler)"]:::cluster
    end

    %% Cluster: jotunheim
    subgraph "Cluster: jotunheim"
        subgraph "flux-system"
            JotKustomize["KustomizeController"]:::cluster
            JotHelmCtrl["HelmController"]:::cluster
            JotNotif["NotificationController"]:::cluster
        end
        KubeAPI2["Kubernetes API"]:::cluster
        AppsJot["Apps Overlays"]:::cluster
        ESJot["ExternalSecrets (Doppler)"]:::cluster
    end

    %% Flows to clusters
    GH -->|reconcile| DexKustomize
    GH -->|reconcile| JotKustomize
    DexKustomize --> KubeAPI
    DexHelmCtrl --> KubeAPI
    DexNotif --> KubeAPI
    JotKustomize --> KubeAPI2
    JotHelmCtrl --> KubeAPI2
    JotNotif --> KubeAPI2

    AppsDex --> KubeAPI
    AppsJot --> KubeAPI2
    ESDex --> KubeAPI
    ESJot --> KubeAPI2

    %% External Services
    subgraph "External Services"
        Doppler["Doppler (Secrets)"]:::external
        OCI["OCI & Helm Registries"]:::external
    end
    Doppler --> ESDex
    Doppler --> ESJot
    OCI --> DexHelmCtrl
    OCI --> JotHelmCtrl

    %% Click Events
    click GH "https://github.com/krezh/dextek/tree/main//"
    click GHActions "https://github.com/krezh/dextek/tree/main//.github/workflows/"
    click Renovate "https://github.com/krezh/dextek/blob/main//.github/renovate.json5"
    click Renovate "https://github.com/krezh/dextek/tree/main//.github/renovate/"
    click Taskfile "https://github.com/krezh/dextek/blob/main//Taskfile.yaml"
    click Taskfile "https://github.com/krezh/dextek/tree/main//.taskfiles/"
    click SharedTF "https://github.com/krezh/dextek/tree/main//infrastructure/terraform/"
    click DexTF "https://github.com/krezh/dextek/tree/main//clusters/dextek/terraform/talos/"
    click JotTF "https://github.com/krezh/dextek/tree/main//clusters/jotunheim/terraform/"
    click IPXE "https://github.com/krezh/dextek/tree/main//infrastructure/ipxe/"
    click Opn "https://github.com/krezh/dextek/tree/main//infrastructure/opnsense/"
    click ROS "https://github.com/krezh/dextek/tree/main//infrastructure/terraform/routeros/"
    click SharedBS "https://github.com/krezh/dextek/tree/main//bootstrap/flux/"
    click DexBS "https://github.com/krezh/dextek/tree/main//clusters/dextek/bootstrap/flux/"
    click JotBS "https://github.com/krezh/dextek/tree/main//clusters/jotunheim/bootstrap/flux/"
    click AppsDex "https://github.com/krezh/dextek/tree/main//clusters/dextek/"
    click AppsJot "https://github.com/krezh/dextek/tree/main//clusters/jotunheim/"
    click SharedTemplates "https://github.com/krezh/dextek/tree/main//clusters/shared/templates/"
    click SharedRepos "https://github.com/krezh/dextek/tree/main//clusters/shared/repositories/"
    click ESDex "https://github.com/krezh/dextek/tree/main//clusters/dextek/apps/kube-system/external-secrets/"
    click ESJot "https://github.com/krezh/dextek/tree/main//clusters/jotunheim/apps/kube-system/external-secrets/"

    %% Styles
    classDef github fill:#1f78d1,stroke:#000,color:#fff
    classDef cicd fill:#ffb400,stroke:#000,color:#000
    classDef infra fill:#cccccc,stroke:#000,color:#000
    classDef cluster fill:#33a02c,stroke:#000,color:#000
    classDef external fill:#6a6a6a,stroke:#000,color:#fff
```
