# chef/chef-workstation architecture

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

- Interactive diagram: https://gitdiagram.com/chef/chef-workstation
- Repository: https://github.com/chef/chef-workstation

## Overview

##### Main Components

- Source Code & Component Modules:
– Highlight the “components” directory. Inside are several key subcomponents:
▪ chef-automate-collect (a Go-based component for collecting telemetry or configuration data)
▪ main-chef-wrapper (a central Go-based command-line tool with many commands to interact with Chef tools)
▪ gems (Ruby-related code and tools used by the project)
▪ packaging (scripts and assets for preparing packages – for example, Chocolatey packaging for Windows)
▪ rehash (supplementary Ruby code)

- Build, Test, and Release Infrastructure:
– The “.expeditor” directory contains various automation scripts for releases, versioning, and publishing (e.g., publishing release notes, building tags, etc.).
– The “.github” directory shows CI/CD workflows (like SonarQube analysis and unit tests) and issue templates.
– The “omnibus” directory holds the packaging configuration. Omnibus is used to build and bundle all components into a complete Chef Workstation package.
– Habitat and associated scripts (found in “habitat/plan.sh”) are also part of the build/distribution process.

- Packaging & Distribution:
– The omnibus and packaging directories collaborate to produce native installable packages for different operating systems (using installer files like Dockerfile, MSI, DMG, etc.).
– Scripts for Chocolatey (inside components/packaging/chocolatey) and for other platforms are used to create distribution artifacts.

- Documentation:
– The “docs-chef-io” directory groups all the content and configuration for the online documentation site.
– Developer docs (in “dev-docs”) provide additional architecture and process overviews.

##### Relationships and Data Flows

- Developer/Contributor Workflow:

- CI/CD and Build Pipeline:
– GitHub workflows (.github/workflows) and Expeditor scripts trigger tests (in “coverage”, “spec” files under omnibus/verification) and build processes.
– Connect “Omnibus” and “Packaging” to a “Distribution/Installer” node (for generating installers for various OS platforms).

- Release Process:
– The expeditor scripts (like “publish-release-notes.sh”, “push-git-tag.sh”, etc.) and omnibus configurations interact to publish releases.

- External Integration:

##### Architectural Patterns and Design Principles

- Umbrella/Modular Architecture:
– The project is divided into loosely coupled modules (the various components) that are integrated during the build process (Omnibus and Habitat).

- Separation of Concerns:
– Distinguish between source-level code (components), build and release automation (.expeditor, .github, omnibus), and distribution (packaging artifacts).

- CI/CD Integration:
– Emphasize the automated testing and packaging pipeline which ensures quality before distribution.

- Multi-Platform Packaging:
– Note that the architecture supports packaging for Windows (.msi, Chocolatey), macOS (.dmg), and Linux (package manager formats), so include nodes for each target platform.

##### Final Steps

– Begin by sketching the major layers: “Source Code & Components”, “CI/CD Build and Test”, “Packaging & Distribution”, and “User Delivery/Runtime Environment”.
– Verify that all main directories (components, omnibus, .expeditor, .github, docs-chef-io, packaging) are represented.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Top Level
    Developers("Developers"):::developer
    Docs("Documentation"):::docs

    %% Source Code & Components Layer
    subgraph "Source Code & Components"
        CA["Chef Automate Collect"]:::component
        MCW["Main Chef Wrapper"]:::component
        GEM["Gems (Ruby Code/Tools)"]:::component
        PKG["Packaging Scripts & Assets"]:::component
        RH["Rehash (Supplementary Ruby Code)"]:::component
    end

    %% CI/CD Build & Automation Layer
    subgraph "CI/CD Build & Automation"
        EXP["Build & Release Automation (.expeditor)"]:::ci
        GH["CI/CD Workflows & Issue Templates (.github)"]:::ci
    end

    %% Packaging & Distribution Layer
    subgraph "Packaging & Distribution"
        OMN["Omnibus Packaging (Multi-platform Build)"]:::packaging
        HAB["Habitat Build Script"]:::packaging
        DIST["Distribution/Installer"]:::distribution
    end

    %% User Delivery/Runtime Environment Layer
    subgraph "User Delivery & Runtime Environment"
        CW["Chef Workstation App/CLI Tools"]:::user
        CS["External Chef Services"]:::external
    end

    %% Documentation Subgraph
    subgraph "Documentation"
        DWEB["Documentation Website"]:::docs
        DDEV["Developer Architecture & Process Documents"]:::docs
    end

    %% Relationships
    Developers -->|"commits"| CA
    Developers -->|"commits"| MCW
    Developers -->|"commits"| GEM
    Developers -->|"commits"| PKG
    Developers -->|"commits"| RH

    Developers -->|"maintains"| Docs

    CA -->|"integrates"| EXP
    MCW -->|"integrates"| EXP
    GEM -->|"integrates"| EXP
    PKG -->|"integrates"| EXP
    RH -->|"integrates"| EXP

    EXP -->|"triggers"| GH
    GH -->|"runs tests/build"| OMN

    OMN -->|"builds"| DIST
    HAB -->|"builds"| DIST
    EXP -->|"release automation"| DIST

    DIST -->|"delivers"| CW
    CW <==>|"integrates"| CS

    DWEB --- DDEV

    %% Click Events
    click CA "https://github.com/chef/chef-workstation/tree/main/components/chef-automate-collect"
    click MCW "https://github.com/chef/chef-workstation/tree/main/components/main-chef-wrapper"
    click GEM "https://github.com/chef/chef-workstation/tree/main/components/gems"
    click PKG "https://github.com/chef/chef-workstation/tree/main/components/packaging"
    click RH "https://github.com/chef/chef-workstation/tree/main/components/rehash"
    click EXP "https://github.com/chef/chef-workstation/blob/main/.expeditor"
    click GH "https://github.com/chef/chef-workstation/blob/main/.github"
    click OMN "https://github.com/chef/chef-workstation/tree/main/omnibus"
    click HAB "https://github.com/chef/chef-workstation/blob/main/habitat/plan.sh"
    click DWEB "https://github.com/chef/chef-workstation/tree/main/docs-chef-io"
    click DDEV "https://github.com/chef/chef-workstation/tree/main/dev-docs"

    %% Styles
    classDef developer fill:#f9f,stroke:#333,stroke-width:2px;
    classDef component fill:#bbf,stroke:#333,stroke-width:2px;
    classDef ci fill:#d3f8d3,stroke:#333,stroke-width:2px;
    classDef packaging fill:#ffe599,stroke:#333,stroke-width:2px;
    classDef distribution fill:#f4cccc,stroke:#333,stroke-width:2px;
    classDef user fill:#cfe2f3,stroke:#333,stroke-width:2px;
    classDef external fill:#f9cb9c,stroke:#333,stroke-width:2px;
    classDef docs fill:#ead1dc,stroke:#333,stroke-width:2px;
```
