# rikardg/bygg architecture

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

- Interactive diagram: https://gitdiagram.com/rikardg/bygg
- Repository: https://github.com/rikardg/bygg

## Overview

##### Main Components

a. Command Layer (cmd/)
- Configuration handling
- Argument parsing
- Build dispatching
- Environment management

b. Core Engine (core/)
- Action management
- DAG (Directed Acyclic Graph) handling
- Cache system
- Runner and scheduler
- Digest system

c. Output System (output/)
- Job output handling
- Status display
- Logging

##### Architectural Flow

**[Configuration Files] → [Command Layer] → [Core Engine] → [Output System]**
- (Byggfile.*)          ↑                    ↕             ↓
- [CLI Interface]      [Cache System]  [Console Output]

##### Key Design Elements

a. Input Processing:
- Multiple configuration file types (TOML, YAML, Python) feeding into the system
- Evaluation order (TOML → YAML → Python)

b. Core Processing:
- DAG processing flow
- Action execution pipeline
- Demonstrate cache interaction

c. Output Handling:
- Job status flow
- Logging pathways

##### Specific Implementation Details

- Rectangles: Core components
- Parallelograms: Input/Output files
- Hexagons: Processing units

- Blue: Core components
- Green: Input processing
- Yellow: Execution components
- Gray: Storage/Cache
- Red: Output/Logging

##### Component Relationships

Key interactions:
**[CLI Interface] → [Argument Parser] → [Configuration Manager]**
- ↓
**[Byggfile.*] → [Configuration Loader] → [Dispatcher]**
- ↓
- [Action Manager] ⟷ [DAG Handler]
- ↓
- [Runner/Scheduler] ⟷ [Cache]
- ↓
- [Output Manager] → [Console]

##### Notes Section
A notes section explaining:
- The build system's incremental nature
- Cache invalidation rules
- Environment handling
- Completion system integration

Remember to indicate the Python version requirement (3.11+) and show how the system integrates with external tools and environments.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        CF1[/"Byggfile.toml"/]
        CF2[/"Byggfile.yaml"/]
        CF3[/"Byggfile.py"/]
    end

    subgraph "Command Layer"
        CLI["CLI Interface"]:::cli
        AP["Argument Parser"]:::cmd
        CH["Configuration Handler"]:::cmd
        CL["Configuration Loader"]:::cmd
        BD["Build Dispatcher"]:::cmd
        EM["Environment Manager"]:::cmd
        CS["Completion System"]:::cmd
    end

    subgraph "Core Engine"
        AM["Action Manager"]:::core
        DH["DAG Handler"]:::core
        RN["Runner"]:::core
        SC["Scheduler"]:::core
        DS["Digest System"]:::core
        CA[(Cache System)]:::core
    end

    subgraph "Output System"
        JO["Job Output Handler"]:::output
        SD["Status Display"]:::output
        LS["Logging System"]:::output
        CO[/"Console Output"/]
    end

    %% Input to Command Layer
    CF1 & CF2 & CF3 --> CL
    CL --> CH
    CLI --> AP
    AP --> CH
    CH --> BD
    BD --> EM
    CS --> CLI

    %% Command Layer to Core Engine
    BD --> AM
    AM <--> DH
    DH --> RN
    RN <--> SC
    SC <--> DS
    DS <--> CA

    %% Core Engine to Output
    RN --> JO
    JO --> SD
    SD --> CO
    LS --> CO

    %% Cache Interactions
    CA <-.-> RN
    CA <-.-> AM

    %% Styles
    classDef cmd fill:#a8d5ff
    classDef core fill:#ffb366
    classDef output fill:#ff9999
    classDef cli fill:#99ff99

    %% Click Events
    click CLI "https://github.com/rikardg/bygg/blob/master/src/bygg/main.py"
    click AP "https://github.com/rikardg/bygg/blob/master/src/bygg/cmd/argument_parsing.py"
    click CH "https://github.com/rikardg/bygg/blob/master/src/bygg/cmd/configuration.py"
    click CL "https://github.com/rikardg/bygg/blob/master/src/bygg/cmd/apply_configuration.py"
    click BD "https://github.com/rikardg/bygg/blob/master/src/bygg/cmd/dispatcher.py"
    click EM "https://github.com/rikardg/bygg/blob/master/src/bygg/cmd/environments.py"
    click CS "https://github.com/rikardg/bygg/blob/master/src/bygg/cmd/completions.py"
    click AM "https://github.com/rikardg/bygg/blob/master/src/bygg/core/action.py"
    click DH "https://github.com/rikardg/bygg/blob/master/src/bygg/core/dag.py"
    click RN "https://github.com/rikardg/bygg/blob/master/src/bygg/core/runner.py"
    click SC "https://github.com/rikardg/bygg/blob/master/src/bygg/core/scheduler.py"
    click DS "https://github.com/rikardg/bygg/blob/master/src/bygg/core/digest.py"
    click CA "https://github.com/rikardg/bygg/blob/master/src/bygg/core/cache.py"
    click JO "https://github.com/rikardg/bygg/blob/master/src/bygg/output/job_output.py"
    click SD "https://github.com/rikardg/bygg/blob/master/src/bygg/output/status_display.py"
    click LS "https://github.com/rikardg/bygg/blob/master/src/bygg/logging.py"
```
