# cuinixam/yanga architecture

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

- Interactive diagram: https://gitdiagram.com/cuinixam/yanga
- Repository: https://github.com/cuinixam/yanga

## Overview

##### Main components
a. **User Interfaces**
- CLI entrypoint (`src/yanga/ymain.py` & `src/yanga/__run.py`)
- GUI frontend (`src/yanga/gui/ygui.py`, `src/yanga/commands/gui.py`)
b. **Command Layer** (`src/yanga/commands/`)
- `run`, `install`, `gui`, `base` commands
- Dispatchers that interpret user input and invoke domain services
c. **Domain/Core Services** (`src/yanga/domain/`)
- Configuration parsing & slurping (`config.py`, `config_slurper.py`, `project_slurper.py`)
- Component analysis (`component_analyzer.py`, `components.py`, `artifacts.py`)
- Execution context (`execution_context.py`)
d. **CMake Backend** (`src/yanga/cmake/`)
- Generator (`generator.py`), Builder (`builder.py`), Runner (`runner.py`), Executable creator (`create_executable.py`), GTest integration (`gtest.py`)
- Abstracts CMake & Ninja invocation
e. **Kickstart (Project Scaffolding)** (`src/yanga/kickstart/`)
- `create.py` and templates directory
- Provides “starter” templates for new projects
f. **Steps Pipeline** (`src/yanga/steps/`)
- Discrete build steps (e.g., `execute_build.py`, `kconfig_gen.py`) used in pypeline
g. **External Systems & Tools**
- Python runtime & 3rd-party libs
- CMake & Ninja build tools
- pypeline (CI/workflow orchestrator)
- UV (packaging)

##### Component relationships & data flow
- **User** → (CLI/GUI) → **Commands** → **Domain services** → **CMake Backend** → **External Build Tools**
- **Commands** also invoke **Kickstart** to scaffold projects
- **Domain** loads configuration & project metadata; passes to backend
- **Steps pipeline** (via pypeline) orchestrates tests, docs, packaging

##### Architectural patterns & design principles
- **Layered architecture**: UI layer (CLI/GUI), Command layer, Domain layer, Backend layer, External tools
- **Separation of concerns**: Domain logic isolated from CLI/GUI, backend details hidden behind adapters
- **Template method**: Kickstart uses template files + create logic
- **Pipeline orchestration**: pypeline defines sequences of steps

##### Essential elements
- **Component labels** matching directory names
- CLI/GUI → Commands → Domain → Backend → External Tools
- Commands → Kickstart → Generated Project
- pypeline → Steps → Commands/Domain/Backend/Test Suite

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        CLI["CLI Entrypoint"]:::python
        GUI["GUI Frontend"]:::python
    end

    %% Command Layer
    subgraph "Command Layer"
        Base["base.py"]:::commands
        RunCmd["run.py"]:::commands
        InstallCmd["install.py"]:::commands
        GuiCmd["gui.py"]:::commands
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Config["config.py"]:::domain
        Slurper["config_slurper.py"]:::domain
        ProjectSlurp["project_slurper.py"]:::domain
        Analyzer["component_analyzer.py"]:::domain
        Components["components.py"]:::domain
        Artifacts["artifacts.py"]:::domain
        Context["execution_context.py"]:::domain
    end

    %% Backend Layer
    subgraph "CMake Backend"
        Generator["generator.py"]:::backend
        Builder["builder.py"]:::backend
        Runner["runner.py"]:::backend
        CreateExe["create_executable.py"]:::backend
        GTest["gtest.py"]:::backend
        BackendMain["cmake_backend.py"]:::backend
    end

    %% Kickstart Module
    subgraph "Kickstart Module"
        CreateKS["create.py"]:::python
        Templates["templates"]:::templates
    end

    %% Steps Pipeline
    subgraph "Steps Pipeline"
        ExecBuild["execute_build.py"]:::steps
        Kconfig["kconfig_gen.py"]:::steps
        StepsIndex["__init__.py"]:::steps
    end

    %% External Tools
    subgraph "External Tools"
        Python["Python runtime & Libs"]:::external
        CMake["CMake & Ninja"]:::external
        PipelineTool["pypeline"]:::external
        UV["UV packaging"]:::external
    end

    %% Relationships
    CLI -->|invokes| Base
    CLI -->|invokes| RunCmd
    CLI -->|invokes| InstallCmd
    GUI -->|invokes| GuiCmd

    Base -->|uses| Config
    RunCmd -->|uses| DomainLayer
    InstallCmd -->|uses| DomainLayer
    GuiCmd -->|uses| DomainLayer

    Base --> DomainLayer
    RunCmd --> DomainLayer
    InstallCmd --> DomainLayer
    GuiCmd --> DomainLayer

    DomainLayer(("Domain Layer")) -->|calls| BackendMain
    DomainLayer --> Analyzer
    DomainLayer --> Components
    DomainLayer --> Artifacts
    DomainLayer --> Context

    BackendMain -->|invokes| Generator
    BackendMain -->|invokes| Builder
    BackendMain -->|invokes| Runner
    BackendMain -->|invokes| CreateExe
    BackendMain -->|integrates| GTest
    BackendMain -->|executes| CMake

    RunCmd -->|scaffolds| CreateKS
    InstallCmd -->|scaffolds| CreateKS
    CreateKS -->|reads| Templates

    PipelineTool --> StepsIndex
    StepsIndex --> ExecBuild
    StepsIndex --> Kconfig

    ExecBuild --> RunCmd
    ExecBuild --> BackendMain
    Kconfig --> BackendMain

    CMake -->|provides| Ninja["Ninja"]:::external

    %% Click Events
    click CLI "https://github.com/cuinixam/yanga/blob/main/src/yanga/ymain.py"
    click CLI "https://github.com/cuinixam/yanga/blob/main/src/yanga/__run.py"
    click GUI "https://github.com/cuinixam/yanga/blob/main/src/yanga/gui/ygui.py"
    click GuiCmd "https://github.com/cuinixam/yanga/blob/main/src/yanga/commands/gui.py"
    click Base "https://github.com/cuinixam/yanga/blob/main/src/yanga/commands/base.py"
    click RunCmd "https://github.com/cuinixam/yanga/blob/main/src/yanga/commands/run.py"
    click InstallCmd "https://github.com/cuinixam/yanga/blob/main/src/yanga/commands/install.py"
    click Config "https://github.com/cuinixam/yanga/blob/main/src/yanga/domain/config.py"
    click Slurper "https://github.com/cuinixam/yanga/blob/main/src/yanga/domain/config_slurper.py"
    click ProjectSlurp "https://github.com/cuinixam/yanga/blob/main/src/yanga/domain/project_slurper.py"
    click Analyzer "https://github.com/cuinixam/yanga/blob/main/src/yanga/domain/component_analyzer.py"
    click Components "https://github.com/cuinixam/yanga/blob/main/src/yanga/domain/components.py"
    click Artifacts "https://github.com/cuinixam/yanga/blob/main/src/yanga/domain/artifacts.py"
    click Context "https://github.com/cuinixam/yanga/blob/main/src/yanga/domain/execution_context.py"
    click Generator "https://github.com/cuinixam/yanga/blob/main/src/yanga/cmake/generator.py"
    click Builder "https://github.com/cuinixam/yanga/blob/main/src/yanga/cmake/builder.py"
    click Runner "https://github.com/cuinixam/yanga/blob/main/src/yanga/cmake/runner.py"
    click CreateExe "https://github.com/cuinixam/yanga/blob/main/src/yanga/cmake/create_executable.py"
    click GTest "https://github.com/cuinixam/yanga/blob/main/src/yanga/cmake/gtest.py"
    click BackendMain "https://github.com/cuinixam/yanga/blob/main/src/yanga/cmake/cmake_backend.py"
    click CreateKS "https://github.com/cuinixam/yanga/blob/main/src/yanga/kickstart/create.py"
    click Templates "https://github.com/cuinixam/yanga/tree/main/src/yanga/kickstart/templates/"
    click ExecBuild "https://github.com/cuinixam/yanga/blob/main/src/yanga/steps/execute_build.py"
    click Kconfig "https://github.com/cuinixam/yanga/blob/main/src/yanga/steps/kconfig_gen.py"
    click StepsIndex "https://github.com/cuinixam/yanga/blob/main/src/yanga/steps/__init__.py"

    %% Styles
    classDef python fill:#D0E8FF,stroke:#02457A,color:#02457A
    classDef commands fill:#B3DFFF,stroke:#0366A3,color:#0366A3
    classDef domain fill:#FFE5B4,stroke:#CC8016,color:#CC8016
    classDef backend fill:#E5D0FF,stroke:#6A1B9A,color:#6A1B9A
    classDef templates fill:#DFFFE0,stroke:#228B22,color:#228B22
    classDef steps fill:#FFF4C2,stroke:#D4A017,color:#D4A017
    classDef external fill:#EEEEEE,stroke:#777777,color:#555555
    class DomainLayer domain
    class Ninja external
```
