# igorbayerl/gdcli architecture

> Architecture diagram of the GitHub repository igorbayerl/gdcli, 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/igorbayerl/gdcli
- Repository: https://github.com/igorbayerl/gdcli

## Overview

##### Project type and purpose
- `gdcli` is a standalone command-line tool (written in Go) that helps initialize Godot project scaffolding, manage Godot versions (install/open), and provides utility commands (clean, version, help).
- It is not a web app or microservice; it is a local developer tool with optional CI/CD for releases.

##### File structure
- Top-level “cmd” directory: each `.go` file defines a subcommand (`init`, `install`, `open`, `clean`, `version`, `help` and the root command).
- `main.go` wires up the CLI (likely via a library like Cobra).
- `internal/config`: reads/stores CLI configuration (paths, default versions).
- `internal/core`: business logic (engine.go handles installs/opens; version.go tracks CLI version).
- `.github/workflows/release.yml`: GitHub Actions workflow for building and publishing releases.
- `docs`: MkDocs configuration and Markdown files for user documentation.
- `setup.iss`: Windows installer script (Inno Setup).

##### Pulling in README insights
- Confirms usage patterns: `gdcli init`, `gdcli install`, `gdcli open`.
- Mentions future installer, extension support, templates.
- Shows project’s CI/CD (Git tags → GitHub Actions → release binaries).

##### Main components and their interactions
a. CLI Layer
- **main.go / root command**
- Bootstraps the application.
- **Command Handlers** (cmd/*.go)
- `init` → project scaffolding
- `install` → download/install correct Godot version
- `open` → launch project with installed Godot binary
- `clean` → remove generated artifacts
- `version`, `help`

b. Core Logic Layer (internal/core)
- **Engine Module** (`engine.go`)
- Downloads, caches, and invokes Godot binaries
- **Version Module** (`version.go`)
- Tracks & reports `gdcli` version

c. Configuration Layer (internal/config)
- Loads CLI settings, paths, default versions, templates

d. File System & External Dependencies
- Reads/Writes project directories
- Stores downloaded Godot engine binaries
- Launches external Godot process

e. Documentation & CI/CD
- **Docs**: MkDocs site generation from `docs/docs`
- **Release Pipeline**: GitHub Actions workflow triggers on tag → builds executables for multiple OS → publishes on GitHub Releases
- **Installer**: Windows Inno Setup script (`setup.iss`)

##### Architectural patterns and design principles
- Layered architecture:
- Presentation (CLI commands)
- Business logic (core modules)
- Configuration & persistence (FS for config & caches)
- Separation of concerns: each command lives in its own file; core logic isolated in `internal/core`; no circular dependencies
- Extensibility: future commands, templates, and global extensions can hook into the CLI layer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        Main["main.go"]:::cli
        RootCmd["cmd/root.go"]:::cli
        InitCmd["cmd/init.go"]:::cli
        InstallCmd["cmd/install.go"]:::cli
        OpenCmd["cmd/open.go"]:::cli
        CleanCmd["cmd/clean.go"]:::cli
        VersionCmd["cmd/version.go"]:::cli
        HelpCmd["cmd/help.go"]:::cli
    end

    %% Config Service
    subgraph "Configuration Service"
        ConfigDir["internal/config"]:::config
        ConfigSvc["internal/config/config.go"]:::config
    end

    %% Core Logic Layer
    subgraph "Core Logic Layer"
        CoreDir["internal/core"]:::core
        Engine["internal/core/engine.go"]:::core
        VersionMod["internal/core/version.go"]:::core
    end

    %% File System & External
    FS[(Local File System)]:::fs
    Godot["Godot Engine Binaries"]:::external

    %% Dev & CI/CD
    subgraph "Documentation & CI/CD"
        DocsGen["docs/mkdocs.yml"]:::docs
        DocsDir["docs/docs"]:::docs
        CI[".github/workflows/release.yml"]:::ci
        Installer["setup.iss"]:::installer
    end

    %% Connections
    Main -->|bootstraps CLI| RootCmd
    RootCmd -->|handles init| InitCmd
    RootCmd -->|handles install| InstallCmd
    RootCmd -->|handles open| OpenCmd
    RootCmd -->|handles clean| CleanCmd
    RootCmd -->|handles version| VersionCmd
    RootCmd -->|handles help| HelpCmd

    RootCmd -->|reads config| ConfigSvc
    ConfigSvc -->|loads settings| FS

    RootCmd -->|invokes engine| Engine
    RootCmd -->|checks version| VersionMod
    Engine -->|caches binaries| FS
    Engine -->|spawns process| Godot

    DocsGen -->|reads markdown| DocsDir
    CI -->|builds & releases| FS
    CI -->|publishes binaries| Godot
    Installer -->|uses script| FS

    %% Click Events
    click Main "https://github.com/igorbayerl/gdcli/blob/main/main.go"
    click RootCmd "https://github.com/igorbayerl/gdcli/blob/main/cmd/root.go"
    click InitCmd "https://github.com/igorbayerl/gdcli/blob/main/cmd/init.go"
    click InstallCmd "https://github.com/igorbayerl/gdcli/blob/main/cmd/install.go"
    click OpenCmd "https://github.com/igorbayerl/gdcli/blob/main/cmd/open.go"
    click CleanCmd "https://github.com/igorbayerl/gdcli/blob/main/cmd/clean.go"
    click VersionCmd "https://github.com/igorbayerl/gdcli/blob/main/cmd/version.go"
    click HelpCmd "https://github.com/igorbayerl/gdcli/blob/main/cmd/help.go"
    click ConfigDir "https://github.com/igorbayerl/gdcli/tree/main/internal/config"
    click ConfigSvc "https://github.com/igorbayerl/gdcli/blob/main/internal/config/config.go"
    click CoreDir "https://github.com/igorbayerl/gdcli/tree/main/internal/core"
    click Engine "https://github.com/igorbayerl/gdcli/blob/main/internal/core/engine.go"
    click VersionMod "https://github.com/igorbayerl/gdcli/blob/main/internal/core/version.go"
    click DocsGen "https://github.com/igorbayerl/gdcli/blob/main/docs/mkdocs.yml"
    click DocsDir "https://github.com/igorbayerl/gdcli/tree/main/docs/docs"
    click CI "https://github.com/igorbayerl/gdcli/blob/main/.github/workflows/release.yml"
    click Installer "https://github.com/igorbayerl/gdcli/blob/main/setup.iss"

    %% Styles
    classDef cli fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef config fill:#FCF3CF,stroke:#7D6608,color:#1B2631
    classDef core fill:#D5F5E3,stroke:#145A32,color:#1B2631
    classDef fs fill:#FADBD8,stroke:#78281F,color:#1B2631
    classDef external fill:#E5E8E8,stroke:#566573,color:#1B2631
    classDef docs fill:#EBDEF0,stroke:#512E5F,color:#1B2631
    classDef ci fill:#F5B7B1,stroke:#922B21,color:#1B2631
    classDef installer fill:#FDEBD0,stroke:#7E5109,color:#1B2631

    class Main,RootCmd,InitCmd,InstallCmd,OpenCmd,CleanCmd,VersionCmd,HelpCmd cli
    class ConfigDir,ConfigSvc config
    class CoreDir,Engine,VersionMod core
    class FS fs
    class Godot external
    class DocsGen,DocsDir docs
    class CI ci
    class Installer installer
```
