# moderneinc/rewrite-recipe-starter architecture

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

- Interactive diagram: https://gitdiagram.com/moderneinc/rewrite-recipe-starter
- Repository: https://github.com/moderneinc/rewrite-recipe-starter

## Overview

##### Main Components
- Codebase / Recipe Modules:
- Core Recipe Implementations: Located under src/main/java – these include classes such as NoGuavaListsNewArrayList, SimplifyTernary, AssertEqualsToAssertThat, etc. They encapsulate individual transformation logic.
- YAML-based Recipes: Found under src/main/resources/META-INF/rewrite – these offer declarative recipes (for instance, stringutils.yml).
- Utility & Configuration Files: E.g., logback.xml and the META-INF configurations that support the OpenRewrite engine.
- Test Suite:
- Unit Tests for verifying each recipe. They reside in the src/test directory.
- Build & Dependency Management:
- Gradle and Maven Build Files: build.gradle.kts, pom.xml, settings.gradle.kts, and accompanying wrapper scripts (gradlew, mvnw) denote support for both build systems.
- CI/CD and Deployment:
- Github Workflows: Located under .github/workflows – these define CI pipelines for building, testing, and publishing snapshots/releases.
- Publishing Components: The configuration details in the README describe local publishing and integration with Moderne’s open artifact repository, along with instructions for Maven Central.

##### Relationships and Interactions
- Recipe Development Lifecycle:
- Developer edits recipe classes (core logic) and YAML files.
- Unit tests in src/test validate the transformation behavior.
- Build and Test Pipeline:
- The CI (GitHub Actions workflows) triggers the build scripts, which run tests via Gradle/Maven.
- Artifacts are created and published either to a local Maven repository or to Moderne’s repository.
- External Integration:
- The published recipe JAR is intended to be consumed by the OpenRewrite engine (via rewrite-maven-plugin or Gradle configuration) and eventually applied on app.moderne.io.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The code is clearly separated into implementation (src/main) and testing (src/test), as well as build/publishing configuration at the project root.
- Plugin/Recipe Based Architecture: Recipes are treated as modular, independently testable units which can be swapped in and out. This represents extensibility.
- Multi-tool Build Integration: Supports both Maven and Gradle tools, which indicates an architecture designed for flexibility in deployment and testing.
- CI/CD Automation: GitHub Actions scripts illustrate an automated pipeline from commit to artifact publication.

##### Relevant Technologies, Frameworks, and Libraries
- Java: The primary implementation language.
- OpenRewrite: The framework/concept behind building and executing recipes.
- Gradle and Maven Tools: For building and publishing the project.
- GitHub Actions: For running CI/CD pipelines.
- Logging (logback.xml): Used for logging throughout the execution.
- YAML Configuration: For declarative recipe definitions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Recipe Module"
        r1("Imperative Java Recipes"):::module
        r2("Declarative YAML Recipes"):::module
        r3("Utility & Configuration Files"):::config
    end

    subgraph "Test Suite"
        tests("Unit Tests"):::test
    end

    subgraph "Build & Dependency Management"
        gradle("Gradle Build System"):::build
        maven("Maven Build System"):::build
    end

    subgraph "CI/CD Pipeline"
        ci("GitHub Workflows"):::ci
    end

    subgraph "Publishing & External Integration"
        pub("Publish Artifacts"):::publish
        external("OpenRewrite on app.moderne.io"):::external
    end

    %% Relationships
    r1 -->|"validates"| tests
    r2 -->|"validates"| tests
    r3 -->|"supports"| tests
    tests -->|"triggers build"| gradle
    tests -->|"triggers build"| maven
    gradle -->|"automates"| ci
    maven -->|"automates"| ci
    ci -->|"deploys"| pub
    pub -->|"integrates with"| external

    %% Click Events
    click r1 "https://github.com/moderneinc/rewrite-recipe-starter/tree/main/src/main/java/com/yourorg"
    click r2 "https://github.com/moderneinc/rewrite-recipe-starter/tree/main/src/main/resources/META-INF/rewrite"
    click r3 "https://github.com/moderneinc/rewrite-recipe-starter/blob/main/src/main/resources/logback.xml"
    click tests "https://github.com/moderneinc/rewrite-recipe-starter/tree/main/src/test/java/com/yourorg"
    click gradle "https://github.com/moderneinc/rewrite-recipe-starter/blob/main/build.gradle.kts"
    click maven "https://github.com/moderneinc/rewrite-recipe-starter/blob/main/pom.xml"
    click ci "https://github.com/moderneinc/rewrite-recipe-starter/tree/main/.github/workflows"

    %% Styles
    classDef module fill:#f9f,stroke:#333,stroke-width:2px,color:#000;
    classDef config fill:#ccf,stroke:#333,stroke-width:2px,color:#000;
    classDef test fill:#eee,stroke:#333,stroke-width:2px,color:#000;
    classDef build fill:#cfc,stroke:#333,stroke-width:2px,color:#000;
    classDef ci fill:#fc9,stroke:#333,stroke-width:2px,color:#000;
    classDef publish fill:#cff,stroke:#333,stroke-width:2px,color:#000;
    classDef external fill:#fcc,stroke:#333,stroke-width:2px,color:#000;
```
