# khuedoan/homelab architecture

> Architecture diagram of the GitHub repository khuedoan/homelab, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khuedoan/homelab
- Repository: https://github.com/khuedoan/homelab

## Overview

Khue’s Homelab is an Infrastructure-as-Code and GitOps framework for provisioning and operating self-hosted services across staging and production. The documented workflow starts with bare-metal/PXE provisioning, installs and manages Kubernetes, then deploys applications and platform services through GitOps. Separate branches cover networking, identity and secrets, storage and backups, observability, and CI. Script excerpts show Forgejo and Kanidm configuration using OpenBao; other subsystem links reflect README-level capabilities, not inspected implementation details.

Main entry points: [`infra/src/modules/platform`](https://github.com/khuedoan/homelab/tree/master/infra/src/modules/platform) (Platform services), [`infra/staging`](https://github.com/khuedoan/homelab/tree/master/infra/staging) (Staging and production), [`infra/src/modules/argocd/main.tf`](https://github.com/khuedoan/homelab/blob/master/infra/src/modules/argocd/main.tf) (Argo CD GitOps), [`infra/src/modules/dns`](https://github.com/khuedoan/homelab/tree/master/infra/src/modules/dns) (DNS management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_provision["Infrastructure provisioning"]
  node_environments["Staging and production"]
  node_hardware["Bare-metal PXE"]
  node_cluster_install["Kubernetes enrollment<br/>[cluster.py]"]
  node_dns["DNS management"]
  node_tunnel["Internet exposure"]
end

subgraph group_cluster["Cluster and GitOps"]
  node_argocd["Argo CD GitOps<br/>[main.tf]"]
end

subgraph group_platform["Platform services"]
  node_platform_apps["Platform services"]
  node_certs["Certificate management<br/>[cert_manager.tf]"]
  node_networking["Cluster networking<br/>[istio.tf]"]
  node_storage["Distributed storage<br/>[rook_ceph.tf]"]
  node_backup["Backup and restore<br/>[main.tf]"]
  node_monitoring["Monitoring and alerts"]
  node_vpn["VPN access<br/>[tailscale.tf]"]
end

subgraph group_identity["Identity and secrets"]
  node_kanidm["SSO configuration<br/>[sso.py]"]
  node_user_admin["User administration<br/>[user.py]"]
  node_openbao[("OpenBao secrets<br/>[openbao.py]")]
end

subgraph group_workloads["Applications and operations"]
  node_forgejo["Forgejo and CI<br/>[forgejo.py]"]
  node_applications["Self-hosted applications"]
end

node_operator(("Homelab operator"))
node_cloudflare["Cloudflare"]

node_operator -->|"configures"| node_environments
node_environments -->|"provisions"| node_hardware
node_hardware -->|"installs cluster"| node_cluster_install
node_environments -->|"configures"| node_dns
node_environments -->|"configures"| node_tunnel
node_cluster_install -->|"enables GitOps"| node_argocd
node_argocd -->|"deploys"| node_applications
node_argocd -->|"deploys"| node_platform_apps
node_platform_apps -->|"provides certificates"| node_certs
node_platform_apps -->|"provides networking"| node_networking
node_platform_apps -->|"provides storage"| node_storage
node_platform_apps -->|"provides backups"| node_backup
node_platform_apps -->|"provides observability"| node_monitoring
node_platform_apps -->|"provides VPN"| node_vpn
node_platform_apps -->|"exposes services"| node_tunnel
node_platform_apps -->|"updates records"| node_dns
node_forgejo -->|"reads and writes"| node_openbao
node_kanidm -->|"reads and writes"| node_openbao
node_user_admin -->|"administers users"| node_kanidm
node_user_admin -->|"opens connection"| node_openbao
node_dns -->|"updates DNS"| node_cloudflare
node_tunnel -->|"uses tunnel"| node_cloudflare

click node_environments "https://github.com/khuedoan/homelab/tree/master/infra/staging"
click node_hardware "https://github.com/khuedoan/homelab/tree/master/infra/src/modules/metal/flake"
click node_cluster_install "https://github.com/khuedoan/homelab/blob/master/infra/src/modules/cluster/cluster.py"
click node_dns "https://github.com/khuedoan/homelab/tree/master/infra/src/modules/dns"
click node_tunnel "https://github.com/khuedoan/homelab/tree/master/infra/src/modules/tunnel"
click node_argocd "https://github.com/khuedoan/homelab/blob/master/infra/src/modules/argocd/main.tf"
click node_platform_apps "https://github.com/khuedoan/homelab/tree/master/infra/src/modules/platform"
click node_certs "https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/cert_manager.tf"
click node_networking "https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/istio.tf"
click node_storage "https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/rook_ceph.tf"
click node_backup "https://github.com/khuedoan/homelab/blob/master/infra/src/modules/backup/main.tf"
click node_monitoring "https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/monitoring_system.tf"
click node_vpn "https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/tailscale.tf"
click node_forgejo "https://github.com/khuedoan/homelab/blob/master/infra/src/scripts/forgejo.py"
click node_applications "https://github.com/khuedoan/homelab/tree/master/apps"
click node_kanidm "https://github.com/khuedoan/homelab/blob/master/infra/src/scripts/sso.py"
click node_user_admin "https://github.com/khuedoan/homelab/blob/master/infra/src/scripts/user.py"
click node_openbao "https://github.com/khuedoan/homelab/blob/master/infra/src/scripts/openbao.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_environments,node_hardware,node_cluster_install,node_dns,node_tunnel toneBlue
class node_argocd toneAmber
class node_platform_apps,node_certs,node_networking,node_storage,node_backup,node_monitoring,node_vpn toneMint
class node_kanidm,node_user_admin,node_openbao toneRose
class node_forgejo,node_applications,node_operator,node_cloudflare toneIndigo
```

## Components

### Infrastructure provisioning

- [Staging and production](https://github.com/khuedoan/homelab/tree/master/infra/staging): `infra/staging`
- [Bare-metal PXE](https://github.com/khuedoan/homelab/tree/master/infra/src/modules/metal/flake): `infra/src/modules/metal/flake`
- [Kubernetes enrollment](https://github.com/khuedoan/homelab/blob/master/infra/src/modules/cluster/cluster.py): `infra/src/modules/cluster/cluster.py`
- [DNS management](https://github.com/khuedoan/homelab/tree/master/infra/src/modules/dns): `infra/src/modules/dns`
- [Internet exposure](https://github.com/khuedoan/homelab/tree/master/infra/src/modules/tunnel): `infra/src/modules/tunnel`

### Cluster and GitOps

- [Argo CD GitOps](https://github.com/khuedoan/homelab/blob/master/infra/src/modules/argocd/main.tf): `infra/src/modules/argocd/main.tf`

### Platform services

- [Platform services](https://github.com/khuedoan/homelab/tree/master/infra/src/modules/platform): `infra/src/modules/platform`
- [Certificate management](https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/cert_manager.tf): `infra/src/modules/platform/cert_manager.tf`
- [Cluster networking](https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/istio.tf): `infra/src/modules/platform/istio.tf`
- [Distributed storage](https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/rook_ceph.tf): `infra/src/modules/platform/rook_ceph.tf`
- [Backup and restore](https://github.com/khuedoan/homelab/blob/master/infra/src/modules/backup/main.tf): `infra/src/modules/backup/main.tf`
- [Monitoring and alerts](https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/monitoring_system.tf): `infra/src/modules/platform/monitoring_system.tf`
- [VPN access](https://github.com/khuedoan/homelab/blob/master/infra/src/modules/platform/tailscale.tf): `infra/src/modules/platform/tailscale.tf`

### Identity and secrets

- [SSO configuration](https://github.com/khuedoan/homelab/blob/master/infra/src/scripts/sso.py): `infra/src/scripts/sso.py`
- [User administration](https://github.com/khuedoan/homelab/blob/master/infra/src/scripts/user.py): `infra/src/scripts/user.py`
- [OpenBao secrets](https://github.com/khuedoan/homelab/blob/master/infra/src/scripts/openbao.py): `infra/src/scripts/openbao.py`

### Applications and operations

- [Forgejo and CI](https://github.com/khuedoan/homelab/blob/master/infra/src/scripts/forgejo.py): `infra/src/scripts/forgejo.py`
- [Self-hosted applications](https://github.com/khuedoan/homelab/tree/master/apps): `apps`

### Other components

- **Homelab operator**
- **Cloudflare**

## Connections

- Homelab operator → Staging and production: configures
- Staging and production → Bare-metal PXE: provisions
- Bare-metal PXE → Kubernetes enrollment: installs cluster
- Staging and production → DNS management: configures
- Staging and production → Internet exposure: configures
- Kubernetes enrollment → Argo CD GitOps: enables GitOps
- Argo CD GitOps → Self-hosted applications: deploys
- Argo CD GitOps → Platform services: deploys
- Platform services → Certificate management: provides certificates
- Platform services → Cluster networking: provides networking
- Platform services → Distributed storage: provides storage
- Platform services → Backup and restore: provides backups
- Platform services → Monitoring and alerts: provides observability
- Platform services → VPN access: provides VPN
- Platform services → Internet exposure: exposes services
- Platform services → DNS management: updates records
- Forgejo and CI → OpenBao secrets: reads and writes (evidence: `infra/src/scripts/forgejo.py`)
- SSO configuration → OpenBao secrets: reads and writes (evidence: `infra/src/scripts/sso.py`)
- User administration → SSO configuration: administers users (evidence: `infra/src/scripts/user.py`)
- User administration → OpenBao secrets: opens connection (evidence: `infra/src/scripts/user.py`)
- DNS management → Cloudflare: updates DNS
- Internet exposure → Cloudflare: uses tunnel
