# jabrena/setup-cli architecture

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

- Interactive diagram: https://gitdiagram.com/jabrena/setup-cli
- Repository: https://github.com/jabrena/setup-cli

## Overview

##### Project Type and Purpose
- This is a Java-based command-line application (“Setup CLI”) built with Maven and PicoCLI.
- Its sole purpose is to scaffold developer environment artifacts (devcontainers, editorconfigs, SDKMAN settings, GitHub Actions workflows, cursor rules, etc.) into a target repository by copying templates from its own `templates` folder.

##### High-Level Architecture and Main Components
a. CLI Engine
- Entry point: `java -jar setup-*.jar` launches PicoCLI.
- Parses global options (`--help`, version) and subcommands (e.g. `init`).
b. InitCommand Subcommand
- Implements the `init` logic (in `src/main/java/info/jab/cli/InitCommand.java`).
- Delegates to one or more Behavior modules based on flags (`--devcontainer`, `--cursor`, `--maven`, etc.).
c. Behavior Modules (Plugin-like)
- Each lives under `src/main/java/info/jab/cli/behaviours/…` (e.g. `DevContainer`, `EditorConfig`, `GithubAction`, `Cursor`, `Maven`, `Sdkman`, `SpringCli`, `QuarkusCli`).
- Implements a common interface: examine CLI options, fetch associated templates, and invoke IO.
d. IO/Template Service
- `CopyFiles` and related IO classes handle file system operations: copy, overwrite, patch.
- Read templates from `templates/…` on the classpath or filesystem.
e. Template Repository
- Static resources under `templates/<template-name>`.
- Each template folder mirrors the directory structure to be injected into the user’s project.
f. Build & Test Pipeline
- Maven wrapper (`mvnw`) and `pom.xml` configure compilation, testing (JUnit), code coverage (JaCoCo), and site reports (Surefire).
- GitHub Actions workflow (`.github/workflows/maven.yaml`) drives CI.

##### Component Interactions and Data Flow
- User invokes `setup init --flags` → PicoCLI parser routes to `InitCommand`.
- `InitCommand` reads requested flags and instantiates corresponding Behavior modules.
- Each Behavior requests templates from `Template Repository` via `CopyFiles`.
- `CopyFiles` writes/updates files in the target project directory.
- On completion, CLI prints success/failure status.

##### Architectural Patterns & Design Principles
- Command Pattern: PicoCLI’s subcommands decouple parsing from execution.
- Strategy/Plugin Pattern: Each Behavior module implements the same interface, making it easy to add new scaffolding types.
- Single Responsibility: CLI parsing, command logic, behavior implementations, and IO are separated into distinct packages.
- Immutable Templates: The `templates` directory is the single source of truth for scaffolding artifacts.

##### Technologies & Frameworks
- Java 17+ (configured in `.sdkmanrc` & `.mvn/jvm.config`)
- PicoCLI for command parsing
- Maven for build, test, coverage, site generation
- JBang for optional distribution (`setup@jabrena`)
- Ant-based UML doc generation under `docs/` (using `build.xml` and `umlgraph`)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Input
    User["User Terminal"]:::external
    User -->|"invokes setup init"| CLI

    %% Core Runtime Components
    CLI["Setup CLI Engine\n(PicoCLI)"]:::core
    click CLI "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/Setup.java"
    CLI -->|"parses global options"| Options
    CLI -->|"routes to InitCommand"| Init

    Options["Global CLI Options Parser"]:::core
    click Options "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/CursorOptions.java"

    Init["InitCommand"]:::core
    click Init "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/InitCommand.java"
    Init -->|"reads flags\ninstantiates behaviors"| DevContainer
    Init --> EditorConfig
    Init --> GithubAction
    Init --> Cursor
    Init --> Maven
    Init --> Sdkman
    Init --> SpringCli
    Init --> QuarkusCli

    GitPrinter["GitInfoPrinter"]:::core
    click GitPrinter "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/GitInfoPrinter.java"

    %% Behavior Modules
    subgraph "Behavior Modules"
        direction TB
        DevContainer["DevContainer"]:::behaviors
        click DevContainer "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/behaviours/DevContainer.java"
        EditorConfig["EditorConfig"]:::behaviors
        click EditorConfig "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/behaviours/EditorConfig.java"
        GithubAction["GitHub Action"]:::behaviors
        click GithubAction "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/behaviours/GithubAction.java"
        Cursor["Cursor Rules"]:::behaviors
        click Cursor "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/behaviours/Cursor.java"
        Maven["Maven"]:::behaviors
        click Maven "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/behaviours/Maven.java"
        Sdkman["SDKMAN"]:::behaviors
        click Sdkman "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/behaviours/Sdkman.java"
        SpringCli["Spring CLI"]:::behaviors
        click SpringCli "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/behaviours/SpringCli.java"
        QuarkusCli["Quarkus CLI"]:::behaviors
        click QuarkusCli "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/behaviours/QuarkusCli.java"
    end

    %% IO Service
    IO["IO Service\nCopyFiles"]:::core
    click IO "https://github.com/jabrena/setup-cli/blob/main/src/main/java/info/jab/cli/io/CopyFiles.java"
    DevContainer -->|"loads template\ncalls IO"| IO
    EditorConfig --> IO
    GithubAction --> IO
    Cursor --> IO
    Maven --> IO
    Sdkman --> IO
    SpringCli --> IO
    QuarkusCli --> IO

    %% Template Repository
    subgraph "Templates Repository"
        direction TB
        CursorAgile["Cursor Rules - Agile"]:::templates
        click CursorAgile "https://github.com/jabrena/setup-cli/tree/main/templates/cursor-rules-agile"
        CursorJava["Cursor Rules - Java"]:::templates
        click CursorJava "https://github.com/jabrena/setup-cli/tree/main/templates/cursor-rules-java"
        CursorTasks["Cursor Rules - Tasks"]:::templates
        click CursorTasks "https://github.com/jabrena/setup-cli/tree/main/templates/cursor-rules-tasks"
        DevContainerTpl["DevContainer Template"]:::templates
        click DevContainerTpl "https://github.com/jabrena/setup-cli/tree/main/templates/devcontainer-template"
        EditorConfigTpl["EditorConfig Template"]:::templates
        click EditorConfigTpl "https://github.com/jabrena/setup-cli/tree/main/templates/editorconfig-template"
        GitHubActionTpl["GitHub Action Template"]:::templates
        click GitHubActionTpl "https://github.com/jabrena/setup-cli/tree/main/templates/github-action-template"
        SdkmanTpl["SDKMAN Template"]:::templates
        click SdkmanTpl "https://github.com/jabrena/setup-cli/tree/main/templates/sdkman-template"
    end

    IO -->|"reads template"| CursorAgile
    IO --> CursorJava
    IO --> CursorTasks
    IO --> DevContainerTpl
    IO --> EditorConfigTpl
    IO --> GitHubActionTpl
    IO --> SdkmanTpl
    IO -->|"writes files"| FS

    %% Target File System
    FS["Target Project File System"]:::external

    %% Build & CI Pipeline
    subgraph "Build & CI Pipeline"
        direction TB
        POM["Maven POM\n(pom.xml)"]:::external
        click POM "https://github.com/jabrena/setup-cli/blob/main/pom.xml"
        Wrapper["Maven Wrapper\n(mvnw, .mvn/)"]:::external
        click Wrapper "https://github.com/jabrena/setup-cli/tree/main/mvnw"
        CI["GitHub Actions CI"]:::external
        click CI "https://github.com/jabrena/setup-cli/blob/main/.github/workflows/maven.yaml"
        POM -->|"configures build"| Wrapper
        Wrapper -->|"runs tests & package"| CI
    end

    %% Styles
    classDef core fill:#D6EFFF,stroke:#333,stroke-width:1px
    classDef behaviors fill:#DFFFE0,stroke:#333,stroke-width:1px
    classDef templates fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
```
