# ahinko/home-ops architecture

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

- Interactive diagram: https://gitdiagram.com/ahinko/home-ops
- Repository: https://github.com/ahinko/home-ops

## Overview

- Git Repository (Configuration Source): Represent the repository as the “single source of truth.” This is where all the declarative configurations (Kubernetes manifests, Helm charts, Kustomizations, Taskfiles, Ansible playbooks) are stored.
- GitOps Pipeline: Include components such as Flux and Renovate. Flux monitors changes in the repository and applies them to the Kubernetes cluster, while Renovate automates dependency updates.
- Kubernetes Cluster: This is the core runtime environment for the homelab. Within the cluster, note that there is an extensive organization of “apps” (e.g., cert-manager, databases, media, downloads, observability, selfhosted services, etc.) arranged by directories.
- Underlying Infrastructure & Provisioning:
- Talos: The operating system for the Kubernetes nodes, with scripts and Taskfiles for automatic OS and cluster updates.
- Ansible: Used for provisioning non-Kubernetes components and additional hardware (backup servers, pikvm, etc.).
- Taskfiles & Custom Scripts: These handle repetitive tasks and orchestrate parts of the provisioning or maintenance processes.
- External/Non-Kubernetes Services: Include Docker containers running on a NAS that complement the Kubernetes services.

- Inside the Kubernetes Cluster, divide the space into sub-sections according to application categories (e.g., “Home Automation,” “Downloads,” “Databases,” “Observability,” “Selfhosted,” and “Networking/Storage”). This mirrors the vast directory structure under “kubernetes/apps/”.
- A separate block to represent “Infrastructure Provisioning & Management” which contains:
- Talos (node provisioning and updates)
- Ansible (hardware provisioning, configuration management for non-cluster systems)
- Taskfiles/Scripts (manual/automation tools)
- Directional data flows or control flows where:
- The Git repository feeds into both GitOps (Flux) and CI/CD pipelines (GitHub Actions).
- The CI/CD section triggers Talos updates and manages node provisioning.
- Ansible and Taskfiles operate on the non-Kubernetes or peripheral hardware elements.

##### Architectural patterns and design principles
- GitOps Pattern: Emphasize that the repository is the source of truth and that Flux continuously reconciles the declared state with the cluster state.
- Infrastructure as Code (IaC): Note the use of declarative Kubernetes manifests, Helm releases, and kustomizations, as well as Ansible playbooks.
- Modularity: The structure is very modular. Each domain (such as databases, media, networking, and security) is organized under its dedicated directory in the Kubernetes configuration, encapsulating domain-specific configuration.
- Automation & Continuous Delivery: Use of Renovate for dependency management, pre-commit hooks, GitHub workflows, and repeated Taskfile tasks illustrates a high degree of automation.

##### Relevant technologies, frameworks, and tools
- Kubernetes (with GitOps using Flux)
- Talos (lightweight OS for cluster nodes)
- Ansible (for hardware provisioning and non-Kubernetes configurations)
- Taskfile (for executing repetitive tasks and scripts)
- GitHub Actions/Workflows, Renovate (for continuous updates and automation)
- Helm/Kustomize (for templating and deploying Kubernetes manifests)
- Various application stacks (cert-manager, databases like Cloudnative-PG, Prometheus/Grafana for observability, and more)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-Level: Configuration Source
    subgraph "Configuration"
        GitRepo["Git Repository – Configurations & IaC"]:::config
    end

    %% GitOps Pipeline
    subgraph "GitOps Pipeline"
        FluxWorkflow["Flux Workflow"]:::gitops
        FluxConfig["Flux Config"]:::gitops
        RenovateConfig["Renovate Config"]:::gitops
        RenovateWorkflow["Renovate Workflow"]:::gitops
    end

    %% Kubernetes Cluster
    subgraph "Kubernetes Cluster"
        K8sApps["Kubernetes Apps & Manifests"]:::k8s
        K8sBootstrap["Kubernetes Bootstrap"]:::k8s
    end

    %% Infrastructure Provisioning & Management
    subgraph "Infrastructure Provisioning & Management"
        TalosConfig["Talos Config"]:::infra
        TalosTaskfile["Talos Taskfile"]:::infra
        AnsiblePlaybooks["Ansible Playbooks"]:::infra
        RootTaskfile["Root Taskfile"]:::infra
        AdditionalTaskfiles["Additional Taskfiles"]:::infra
        CustomScripts["Custom Scripts"]:::infra
    end

    %% External Services
    External["External Services"]:::external

    %% Relationships
    GitRepo -->|"push_config"| FluxWorkflow
    GitRepo -->|"push_config"| RenovateWorkflow

    FluxWorkflow -->|"apply_declarative"| K8sApps
    FluxConfig -->|"apply_declarative"| K8sApps

    RenovateConfig -->|"manage_deps"| GitRepo
    RenovateWorkflow -->|"trigger_updates"| GitRepo

    GitRepo -->|"trigger_provisioning"| TalosConfig
    GitRepo -->|"trigger_provisioning"| AnsiblePlaybooks
    GitRepo -->|"trigger_provisioning"| RootTaskfile
    GitRepo -->|"trigger_provisioning"| AdditionalTaskfiles
    GitRepo -->|"trigger_provisioning"| CustomScripts

    TalosConfig -->|"orchestrate_nodes"| K8sApps
    TalosTaskfile -->|"execute_updates"| TalosConfig

    K8sApps -->|"integrates_with"| External
    K8sBootstrap -->|"initial_setup"| K8sApps

    %% Click Events
    click GitRepo "https://github.com/ahinko/home-ops/blob/main/README.md"
    click FluxWorkflow "https://github.com/ahinko/home-ops/blob/main/.github/workflows/flux-local.yaml"
    click FluxConfig "https://github.com/ahinko/home-ops/tree/main/kubernetes/flux/"
    click RenovateConfig "https://github.com/ahinko/home-ops/tree/main/.renovate/"
    click RenovateWorkflow "https://github.com/ahinko/home-ops/blob/main/.github/workflows/renovate.yaml"
    click K8sApps "https://github.com/ahinko/home-ops/tree/main/kubernetes/apps/"
    click K8sBootstrap "https://github.com/ahinko/home-ops/tree/main/kubernetes/bootstrap/"
    click TalosConfig "https://github.com/ahinko/home-ops/tree/main/infrastructure/talos/"
    click TalosTaskfile "https://github.com/ahinko/home-ops/blob/main/.taskfiles/talos/taskfile.yaml"
    click AnsiblePlaybooks "https://github.com/ahinko/home-ops/tree/main/infrastructure/ansible/"
    click RootTaskfile "https://github.com/ahinko/home-ops/blob/main/Taskfile.yml"
    click AdditionalTaskfiles "https://github.com/ahinko/home-ops/tree/main/.taskfiles/"
    click CustomScripts "https://github.com/ahinko/home-ops/tree/main/.github/scripts/"

    %% Styles
    classDef config fill:#c2f0c2,stroke:#2d7a2d,stroke-width:2px;
    classDef gitops fill:#c2d6f0,stroke:#2d4a7a,stroke-width:2px;
    classDef k8s fill:#f0d6c2,stroke:#7a4a2d,stroke-width:2px;
    classDef infra fill:#e0c2f0,stroke:#6a2d7a,stroke-width:2px;
    classDef external fill:#f0e6c2,stroke:#7a6a2d,stroke-width:2px;
```
