# quipucords/downstream-builder architecture

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

- Interactive diagram: https://gitdiagram.com/quipucords/downstream-builder
- Repository: https://github.com/quipucords/downstream-builder

## Overview

##### Project type and purpose
- This is a containerized CLI tool (“Quipucords Downstream Builder”) written in Python. Its purpose is to orchestrate RPM and container builds for Quipucords/Discovery downstream projects without requiring local installation of `rhpkg` or `brewkoji`.

##### File structure
- Top-level files:
- Containerfile: Defines the container image.
- pyproject.toml: Python packaging/build config.
- README.md/.env-example: Usage and environment defaults.
- configs/: Git & Kerberos configs the container consumes.
- scripts/: Helper shell scripts.
- Python package “discobuilder/”:
- __main__.py: Entry point.
- builder/: Business logic for CLI, installer, server.
- adapter/: Abstraction layer over external tools (git, Kerberos, rhpkg, rpmbuild, chaski, subprocess).
- config.py: Loads .env and config files.

##### README for additional insights
- The workflow:
- Build container.
- Mount host directories (repos, cache).
- Load .env into environment.
- Run interactive CLI that drives downstream builds.
- Interacts via VPN with internal Red Hat build hosts and services.
- External dependencies: git repos, brewkoji, Kerberos, container registry, rpm build services.

##### Detailed capture of architectural elements
- Containerfile as the build descriptor feeding into the Container runtime.
- That after a successful run the user lands in a bash shell inside the container for manual steps.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Host"
        CF["Containerfile"]:::code
        PP["pyproject.toml"]:::data
        ENV[".env-example"]:::data
        README["README.md"]:::data
        Scripts["scripts/helper.sh"]:::code
    end

    CF -->|"builds image"| Container

    subgraph "Container"
        subgraph "Config Loader"
            CFG["discobuilder/config.py"]:::code
            Configs["configs/"]:::data
        end

        subgraph "Presentation Layer"
            CLIEntry["discobuilder/__main__.py"]:::pres
            CLI["discobuilder/builder/cli.py"]:::pres
        end

        subgraph "Application Layer"
            Inst["discobuilder/builder/installer.py"]:::app
            Serv["discobuilder/builder/server.py"]:::app
        end

        subgraph "Infrastructure Layer"
            GitA["discobuilder/adapter/git.py"]:::infra
            KerbA["discobuilder/adapter/kerberos.py"]:::infra
            RHPKGA["discobuilder/adapter/rhpkg.py"]:::infra
            RPMBA["discobuilder/adapter/rpmbuild.py"]:::infra
            ChaskiA["discobuilder/adapter/chaski.py"]:::infra
            SubpA["discobuilder/adapter/subprocess.py"]:::infra
        end
    end

    ENV -->|"loads"| CFG
    Configs -->|"provides configs"| CFG

    CFG -->|"initializes CLI"| CLIEntry
    CLIEntry -->|"starts interactive shell"| CLI

    CLI -->|"orchestrates"| Inst
    CLI -->|"orchestrates"| Serv

    Inst -.->|"calls"| GitA
    Inst -.->|"calls"| KerbA
    Inst -.->|"calls rhpkg build"| RHPKGA

    Serv -.->|"invokes rpmbuild"| RPMBA
    Serv -.->|"invokes container build"| ChaskiA

    GitA -.->|"subprocess"| SubpA
    KerbA -.->|"subprocess"| SubpA
    RHPKGA -.->|"subprocess"| SubpA
    RPMBA -.->|"subprocess"| SubpA
    ChaskiA -.->|"subprocess"| SubpA

    subgraph "External Services"
        Git["Git Server"]:::external
        KDC["Kerberos KDC"]:::external
        Brew["Brewkoji"]:::external
        RPMHost["RPM Build Host"]:::external
        Registry["Container Registry"]:::external
    end

    GitA -->|"clone/push"| Git
    KerbA -->|"authenticate"| KDC
    RHPKGA -->|"submit build"| Brew
    RPMBA -->|"build rpm"| RPMHost
    ChaskiA -->|"push image"| Registry

    Host -->|"mounts .env & repos"| Container

    %% Click Events
    click CF "https://github.com/quipucords/downstream-builder/tree/main/Containerfile"
    click PP "https://github.com/quipucords/downstream-builder/blob/main/pyproject.toml"
    click ENV "https://github.com/quipucords/downstream-builder/blob/main/.env-example"
    click README "https://github.com/quipucords/downstream-builder/blob/main/README.md"
    click Scripts "https://github.com/quipucords/downstream-builder/blob/main/scripts/helper.sh"
    click CFG "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/config.py"
    click Configs "https://github.com/quipucords/downstream-builder/tree/main/configs/"
    click CLIEntry "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/__main__.py"
    click CLI "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/builder/cli.py"
    click Inst "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/builder/installer.py"
    click Serv "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/builder/server.py"
    click GitA "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/adapter/git.py"
    click KerbA "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/adapter/kerberos.py"
    click RHPKGA "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/adapter/rhpkg.py"
    click RPMBA "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/adapter/rpmbuild.py"
    click ChaskiA "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/adapter/chaski.py"
    click SubpA "https://github.com/quipucords/downstream-builder/blob/main/discobuilder/adapter/subprocess.py"

    classDef code fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef data fill:#90EE90,stroke:#333,stroke-width:1px
    classDef pres fill:#1E90FF,stroke:#333,stroke-width:1px
    classDef app fill:#4682B4,stroke:#333,stroke-width:1px
    classDef infra fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef external fill:#F0E68C,stroke:#333,stroke-width:1px
```
