# zarf-dev/zarf architecture

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

- Interactive diagram: https://gitdiagram.com/zarf-dev/zarf
- Repository: https://github.com/zarf-dev/zarf

## Overview

##### Main Components

a. Core Components:
- CLI Interface (entry point)
- Package Manager
- Cluster Manager
- Registry Services
- Git Services (Gitea)
- Injection System
- SBOM Generator
- Authentication/Security Layer

b. External Integrations:
- Kubernetes Clusters
- OCI Registries
- Git Repositories
- Container Images
- Helm Charts

##### User Interface Layer
- CLI Commands (zarf init, package, connect, etc.)
- Interactive Prompts
- Configuration Management

##### Core Processing Layer
- Package Management System
- Component Processor
- Variable Template Engine
- Action Runner
- Image Transformer

##### Integration Layer
- Kubernetes Client
- Registry Client
- Git Client
- Helm Client
- SBOM Tools

##### Infrastructure Layer
- Local Storage
- Network Services
- Security Services
- Caching System

##### Key Relationships to Highlight

- Bidirectional flow between CLI and Package Manager
- How the Mutating Webhook interacts with Kubernetes
- Demonstrate the transformation pipeline for container images
- Relationship between packages and their components
- Flow of SBOMs and security scanning

##### Important Details

- Package Creation Flow
- Deployment Pipeline
- Air Gap Boundary
- Security Checkpoints
- Component Lifecycle
- Resource Transformation Points

##### Specific Implementation Notes

- Zero-dependency nature of the CLI
- Composable package system
- Where variable templating occurs
- Points where SBOM generation happens
- Where cosign signature verification takes place

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "User Interface Layer"
        CLI["CLI Interface"]
        Config["Configuration Management"]
        Prompt["Interactive Prompts"]
    end

    subgraph "Core Processing Layer"
        PackageManager["Package Manager"]
        CompProcessor["Component Processor"]
        VarEngine["Variable Template Engine"]
        ActionRunner["Action Runner"]
        Transform["Transform Pipeline"]
        Layout["Package Layout System"]
    end

    subgraph "Integration Layer"
        K8sClient["Kubernetes Client"]
        RegClient["OCI Registry Client"]
        GitClient["Git Client"]
        HelmClient["Helm Client"]
        SBOM["SBOM Generator"]
    end

    subgraph "Infrastructure Layer"
        Storage["Local Storage"]
        Network["Network Services"]
        Security["PKI Security"]
        Cache["Caching System"]
        Agent["Agent Service"]
        Registry["Registry Services"]
        Gitea["Git Services"]
        Auth["Authentication Layer"]
        Injector["Injection System"]
    end

    %% Relationships
    CLI --> PackageManager
    CLI --> Config
    CLI --> Prompt
    PackageManager --> CompProcessor
    PackageManager --> VarEngine
    PackageManager --> ActionRunner
    CompProcessor --> Transform
    CompProcessor --> Layout
    Transform --> RegClient
    Transform --> GitClient
    Transform --> HelmClient
    ActionRunner --> K8sClient
    ActionRunner --> SBOM
    K8sClient --> Injector
    RegClient --> Registry
    GitClient --> Gitea
    Security --> Auth
    Auth --> Agent

    %% Click Events
    click CLI "https://github.com/zarf-dev/zarf/tree/main/src/cmd/"
    click PackageManager "https://github.com/zarf-dev/zarf/tree/main/src/pkg/packager/"
    click K8sClient "https://github.com/zarf-dev/zarf/tree/main/src/pkg/cluster/"
    click Registry "https://github.com/zarf-dev/zarf/tree/main/packages/zarf-registry/"
    click Gitea "https://github.com/zarf-dev/zarf/tree/main/packages/gitea/"
    click Injector "https://github.com/zarf-dev/zarf/tree/main/src/injector/"
    click SBOM "https://github.com/zarf-dev/zarf/tree/main/src/pkg/packager/sbom/"
    click Auth "https://github.com/zarf-dev/zarf/blob/main/src/pkg/utils/auth.go"
    click Layout "https://github.com/zarf-dev/zarf/tree/main/src/pkg/layout/"
    click VarEngine "https://github.com/zarf-dev/zarf/tree/main/src/pkg/variables/"
    click Transform "https://github.com/zarf-dev/zarf/tree/main/src/pkg/transform/"
    click Security "https://github.com/zarf-dev/zarf/tree/main/src/pkg/pki/"
    click Agent "https://github.com/zarf-dev/zarf/tree/main/packages/zarf-agent/"
    click RegClient "https://github.com/zarf-dev/zarf/tree/main/src/pkg/zoci/"

    %% Styling
    classDef core fill:#2374ab
    classDef external fill:#57a773
    classDef security fill:#ff8c42
    classDef infrastructure fill:#848484

    class CLI,PackageManager,CompProcessor,VarEngine,ActionRunner,Transform,Layout core
    class K8sClient,RegClient,GitClient,HelmClient external
    class Security,Auth,SBOM security
    class Storage,Network,Cache,Agent,Registry,Gitea,Injector infrastructure
```
