# rrajesh1979/ref-java-cli architecture

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

- Interactive diagram: https://gitdiagram.com/rrajesh1979/ref-java-cli
- Repository: https://github.com/rrajesh1979/ref-java-cli

## Overview

##### Project type and purpose
- This is a reference Java command‑line interface (CLI) application called “mychecksum.”
- Purpose: compute file checksums (MD5 by default, or other algorithms like SHA‑1/SHA‑256) and print results to STDOUT.
- Built with Java, Maven, Picocli for CLI parsing, GraalVM native-image packaging via JReleaser, and automated CI/CD via GitHub Actions.

##### File structure
- Top‑level files & directories:
- pom.xml, mvnw/mvnw.cmd, .mvn/wrapper → Maven build setup
- src/main/java/org/rrajesh1979/demo/MyCheckSum.java → core CLI entry point & checksum logic
- src/test/java/org/rrajesh1979/demo/MyCheckSumTest.java → unit tests (JUnit/Spock)
- src/main/assembly/assembly.xml → assembly descriptor for packaging
- jreleaser.yml → configuration for native-image builds and artifact release
- .github/workflows/*.yml → CI pipelines for code‑quality checks and release
- .gitpod.yml, .gitpod.Dockerfile → cloud IDE dev environment
- No frontend or external microservices—single-binary CLI tool.

##### README for additional insights
- Key features list technologies (Java, Maven, JReleaser, Picocli, GitHub Actions).
- Usage examples show how Picocli parses parameters and how native binary gets installed via Homebrew.
- Configuration section calls out necessary secrets and tokens for CI/CD and release.

a. User & CLI interface
- User invokes “mychecksum” command in a shell.
- Picocli parses arguments, validates input.
b. Core checksum service
- MyCheckSum.java:
- Reads file via Java I/O
- Applies selected MessageDigest algorithm
- Produces hex digest string
c. Packaging & distribution
- Maven build: compiles, runs tests, produces JAR.
- JReleaser + GraalVM native‑image: produces platform‑specific executables.
- GitHub Actions release workflow:
- Triggers on tag → uses jreleaser.yml → publishes binaries to GitHub Releases & Homebrew tap.
d. Continuous integration
- GitHub Actions code‑quality checks workflow: runs static analysis (SpotBugs/Checkstyle), unit tests, coverage (Codecov), and SonarCloud quality gate.
e. Development environment
- Gitpod: automated dev environment using .gitpod.Dockerfile & .gitpod.yml.

##### Architectural patterns & design principles
- Single-responsibility: CLI parsing (Picocli) isolated from business logic (checksum).
- Modular packaging: clear separation of build (Maven), release (JReleaser), and runtime (native-image).
- Automated CI/CD pipeline: infrastructure-as-code via GitHub workflows.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interaction"
        U["User Shell"]:::external
    end

    subgraph "Runtime Components"
        Parser["CLI Parser (Picocli)"]:::runtime
        Checksum["Checksum Service"]:::runtime
        IO["Java Runtime / File I/O"]:::runtime
        Output["STDOUT"]:::runtime
    end

    U -->|"invoke 'mychecksum'"| Parser
    Parser -->|"parse args"| Checksum
    Checksum -->|"read file"| IO
    IO -->|"compute digest"| Checksum
    Checksum -->|"print result"| Output

    subgraph "Build & Packaging"
        Maven["Maven Build System"]:::build
        Tests["Unit Tests"]:::build
        Assembly["Assembly Descriptor"]:::build
        Native["Native-Image & Release Config"]:::build
        Artifacts["Artifacts (JAR & native)"]:::build
    end

    Checksum --> Maven
    Maven --> Tests
    Maven --> Assembly
    Assembly --> Native
    Native -->|"produces binaries"| Artifacts

    subgraph "CI/CD Pipeline"
        Git["Git Tag/Commit"]:::external
        CodeQuality["Code Quality Checks"]:::ci
        Sonar["SonarCloud"]:::ci
        Codecov["Codecov"]:::ci
        ReleaseWF["Release Workflow"]:::ci
        GHReleases["GitHub Releases & Homebrew"]:::ci
    end

    Git --> CodeQuality
    CodeQuality --> Sonar
    CodeQuality --> Codecov
    CodeQuality --> ReleaseWF
    ReleaseWF --> GHReleases

    subgraph "Dev Environment"
        GitpodYml[".gitpod.yml"]:::dev
        GitpodDocker[".gitpod.Dockerfile"]:::dev
    end

    Dev["Developer"]:::external --> GitpodYml
    Dev --> GitpodDocker

    subgraph "Project Docs & Config"
        README["README.md"]:::docs
        Contrib["CONTRIBUTING.md"]:::docs
        CoC["CODE_OF_CONDUCT.md"]:::docs
        License["LICENSE"]:::docs
        Formatter["eclipse-formatter-config.xml"]:::docs
    end

    classDef runtime fill:#ccffcc,stroke:#333,stroke-width:1px;
    classDef build fill:#cce0ff,stroke:#333,stroke-width:1px;
    classDef ci fill:#ffddcc,stroke:#333,stroke-width:1px;
    classDef external fill:#eeeeee,stroke:#333,stroke-width:1px;
    classDef dev fill:#ffffcc,stroke:#333,stroke-width:1px;
    classDef docs fill:#f2f2f2,stroke:#333,stroke-width:1px;

    click Checksum "https://github.com/rrajesh1979/ref-java-cli/blob/master/src/main/java/org/rrajesh1979/demo/MyCheckSum.java"
    click Tests "https://github.com/rrajesh1979/ref-java-cli/blob/master/src/test/java/org/rrajesh1979/demo/MyCheckSumTest.java"
    click Maven "https://github.com/rrajesh1979/ref-java-cli/blob/master/pom.xml"
    click Maven "https://github.com/rrajesh1979/ref-java-cli/tree/master/mvnw"
    click Maven "https://github.com/rrajesh1979/ref-java-cli/blob/master/mvnw.cmd"
    click Maven "https://github.com/rrajesh1979/ref-java-cli/tree/master/.mvn/wrapper/"
    click Assembly "https://github.com/rrajesh1979/ref-java-cli/blob/master/src/main/assembly/assembly.xml"
    click Native "https://github.com/rrajesh1979/ref-java-cli/blob/master/jreleaser.yml"
    click CodeQuality "https://github.com/rrajesh1979/ref-java-cli/blob/master/.github/workflows/code-quality-checks.yml"
    click ReleaseWF "https://github.com/rrajesh1979/ref-java-cli/blob/master/.github/workflows/release.yml"
    click GitpodYml "https://github.com/rrajesh1979/ref-java-cli/blob/master/.gitpod.yml"
    click GitpodDocker "https://github.com/rrajesh1979/ref-java-cli/blob/master/.gitpod.Dockerfile"
    click Formatter "https://github.com/rrajesh1979/ref-java-cli/blob/master/etc/eclipse-formatter-config.xml"
    click README "https://github.com/rrajesh1979/ref-java-cli/blob/master/README.md"
    click Contrib "https://github.com/rrajesh1979/ref-java-cli/blob/master/CONTRIBUTING.md"
    click CoC "https://github.com/rrajesh1979/ref-java-cli/blob/master/CODE_OF_CONDUCT.md"
    click License "https://github.com/rrajesh1979/ref-java-cli/tree/master/LICENSE"
```
