# dberna2/check-style architecture

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

- Interactive diagram: https://gitdiagram.com/dberna2/check-style
- Repository: https://github.com/dberna2/check-style

## Overview

##### Project type and purpose
- This is an open-source GitHub Action that wraps Checkstyle for Java & ReviewDog to automate static code analysis in a PR workflow.
- It’s a DevOps‐focused tool, not a full-stack app—its “system” lives entirely inside a CI runner and interfaces with GitHub’s APIs.

##### File structure
- action.yml – declares inputs, outputs, metadata for the GitHub Action.
- Dockerfile – builds the container image that bundles ReviewDog, Checkstyle, and your entrypoint script.
- entrypoint.sh – the shell script that runs inside the container: reads inputs, invokes Checkstyle via ReviewDog, processes results.
- .gitignore, README.md – documentation and ignore rules.

##### Key external dependencies (from README)
- ReviewDog CLI (for running checkstyle and posting results)
- Checkstyle (Java static analysis engine)
- GitHub Actions runner + GitHub API (to post annotations or checks)

##### Main components & their relationships
a. GitHub Actions Runner (host VM or container)
- Pulls your repo code (via actions/checkout)
- Reads workflow YAML to launch this Action
b. Action Container (built by Dockerfile)
- Entrypoint script (entrypoint.sh)
- ReviewDog binary (bundled in container)
- Checkstyle jar(s) & config file(s) (google_checks.xml or custom)
c. Inputs/Configs (in action.yml & workflow)
- github_token, reporter, level, checkstyle_config, use_custom_validations, custom_validations, excluded_paths, workdir, etc.
d. External Services
- GitHub API – for PR comments, check runs, review annotations
e. Code under test
- Java sources in user’s repo, scanned by Checkstyle

Data flow:
1. Runner starts job → checks out code
2. Runner pulls & runs your Action container → entrypoint.sh
3. entrypoint.sh reads inputs → builds ReviewDog command line
4. ReviewDog launches Checkstyle on the working directory (workdir)
5. Checkstyle produces XML/console output → ReviewDog parses it
6. ReviewDog uses github_token to POST annotations/checks back to the PR via GitHub API

##### Architectural patterns & design principles
- Single-container wrapper: isolates dependencies
- Declarative inputs (action.yml) → decouples configuration from code
- Script-based orchestration (entrypoint.sh) following the “one logical action per container” principle
- Pluggable rules: supports default vs custom Checkstyle config and custom validation JARs

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "GitHub Actions Runner"
        Runner["Runner (host VM/container)"]:::runner
    end
    Runner -->|"1. checkout code"| WorkspaceSub["Repo Workspace"]:::code

    subgraph "Repo Workspace"
        ActionYML["action.yml\n(inputs & outputs)"]:::code
        DockerfileNode["Dockerfile"]:::code
        EntrypointFS["entrypoint.sh"]:::code
        README["README.md"]:::code
        Gitignore[".gitignore"]:::code
    end
    WorkspaceSub --> ActionYML
    WorkspaceSub --> DockerfileNode
    WorkspaceSub --> EntrypointFS
    WorkspaceSub --> README
    WorkspaceSub --> Gitignore

    DockerfileNode -->|"2. build container"| Container["Action Container Image"]:::container

    subgraph "Action Container"
        Entrypoint["entrypoint.sh (runtime)"]:::container
        ReviewDog["ReviewDog CLI"]:::container
        Checkstyle["Checkstyle Engine"]:::container
        UserConfigs["Configs\n(checkstyle_config, custom_validations,\nexcluded_paths)"]:::code
    end
    Container --> Entrypoint
    Entrypoint -->|"3. invokes ReviewDog"| ReviewDog
    ReviewDog -->|"4. runs Checkstyle"| Checkstyle
    Checkstyle -->|"5. outputs results"| ReviewDog
    ReviewDog -->|"6. POST annotations"| GitHubAPI["GitHub API"]:::external

    click ActionYML "https://github.com/dberna2/check-style/blob/main/action.yml"
    click DockerfileNode "https://github.com/dberna2/check-style/tree/main/Dockerfile"
    click EntrypointFS "https://github.com/dberna2/check-style/blob/main/entrypoint.sh"
    click README "https://github.com/dberna2/check-style/blob/main/README.md"
    click Gitignore "https://github.com/dberna2/check-style/blob/main/.gitignore"

    classDef runner fill:#e0ffe0,stroke:#333,stroke-width:1px
    classDef container fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef code fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef external fill:#ffd2a6,stroke:#333,stroke-width:1px
```
