# aldrinm/micronaut-retryable-sample architecture

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

- Interactive diagram: https://gitdiagram.com/aldrinm/micronaut-retryable-sample
- Repository: https://github.com/aldrinm/micronaut-retryable-sample

## Overview

##### Project type and purpose
- This is a small Micronaut‐based backend service written in Java.
- It exposes HTTP endpoints (HelloController) and includes a declarative HTTP client (HelloClient) to call other services.
- Build, testing, and packaging are handled by Gradle (with Shadow plugin and optional GraalVM native image support).

##### File structure
- Top‐level build files: build.gradle.kts, gradle.properties, settings.gradle.kts, wrapper under gradle/wrapper, plus Micronaut CLI config.
- src/main/java/aldrinm:
- Application.java – boots the Micronaut context and HTTP server
- HelloController.java – defines REST endpoints
- HelloClient.java – a declarative HTTP client interface
- src/main/resources: configuration files (application.properties, logback.xml)
- src/test/java/aldrinm: HelloClientSpec.java – unit tests for the client

##### README for additional insights
- It points to Micronaut documentation and features: Jackson serialization, AOT, Shadow jar, GraalVM.
- No external database or frontend mentioned, so this is purely a backend microservice.

##### Main components
a. HTTP Client (external caller)
b. API Gateway / Micronaut HTTP Server
- HelloController
- Micronaut Core (IoC container, routing, serialization)
c. HelloClient (declarative HTTP client that calls downstream service)
d. Downstream External Service (could be another microservice or 3rd‐party API)
e. Configuration layer (application.properties)
f. Logging (Logback)
g. Build/Deployment Pipeline (Gradle → Shadow JAR → [optional GraalVM native image])

##### Relationships and interactions
- External client → HTTP → HelloController
- HelloController → in‐process call to HelloClient
- HelloClient → HTTP → Downstream External Service
- All components read configuration from application.properties
- Logging flows from controllers/clients to Logback sinks
- At build time: Gradle compiles code, packages with Shadow plugin, optionally builds native image via GraalVM plugin

##### Architectural patterns and design principles
- Microservice pattern: single‐responsibility service exposing HTTP API
- Dependency injection / Inversion of control (Micronaut IoC)
- Declarative HTTP client pattern (HelloClient)
- Twelve‐factor app principles: externalized config, structured logging

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Systems
    ExternalClient["External Client"]:::external
    DownstreamService["Downstream External Service"]:::external

    %% Micronaut Service
    subgraph "Micronaut Service"
        direction TB
        App["Micronaut HTTP Server\n(Application.java)"]:::inprocess
        subgraph "Micronaut Core"
            direction TB
            IoC["IoC Container"]:::inprocess
            Netty["Netty HTTP Server"]:::inprocess
            Jackson["Jackson Serialization"]:::inprocess
        end
        HelloCtrl["HelloController\n(REST endpoints)"]:::inprocess
        HelloClientComp["HelloClient\n(Declarative HTTP client)"]:::inprocess
        Config["Configuration\n(application.properties)"]:::config
        Log["Logging\n(logback.xml)"]:::config
    end

    %% Build & Deployment Pipeline
    subgraph "Build & Deployment"
        direction TB
        GradleBuild["Gradle Build Script\n(build.gradle.kts)"]:::build
        ShadowJar["Shadow JAR Packaging"]:::build
        GraalVM["GraalVM Native Image (optional)"]:::build
        Settings["Gradle Settings\n(settings.gradle.kts)"]:::build
        Props["Gradle Properties\n(gradle.properties)"]:::build
        subgraph "Gradle Wrapper"
            direction TB
            WrapperJar["gradle-wrapper.jar"]:::build
            WrapperProps["gradle-wrapper.properties"]:::build
        end
        CLIConfig["Micronaut CLI Config\n(micronaut-cli.yml)"]:::build
    end

    %% Tests
    Tests["HelloClientSpec\n(src/test/java/aldrinm/HelloClientSpec.java)"]:::test

    %% Connections
    ExternalClient -->|HTTP| HelloCtrl
    HelloCtrl -->|calls| HelloClientComp
    HelloClientComp -->|HTTP| DownstreamService
    App --> IoC
    App --> Netty
    App --> Jackson
    HelloCtrl --> App
    HelloClientComp --> App
    App --> Config
    App --> Log
    HelloCtrl --> Log
    HelloClientComp --> Log

    GradleBuild --> ShadowJar --> GraalVM
    Settings --> GradleBuild
    Props --> GradleBuild
    WrapperJar --> GradleBuild
    WrapperProps --> GradleBuild
    CLIConfig --> GradleBuild

    GradleBuild -.-> App
    ShadowJar -.-> App
    GraalVM -.-> App

    Tests -.-> HelloClientComp

    %% Click Events
    click App "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/src/main/java/aldrinm/Application.java"
    click HelloCtrl "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/src/main/java/aldrinm/HelloController.java"
    click HelloClientComp "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/src/main/java/aldrinm/HelloClient.java"
    click Config "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/src/main/resources/application.properties"
    click Log "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/src/main/resources/logback.xml"
    click GradleBuild "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/build.gradle.kts"
    click Settings "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/settings.gradle.kts"
    click Props "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/gradle.properties"
    click WrapperJar "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/gradle/wrapper/gradle-wrapper.jar"
    click WrapperProps "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/gradle/wrapper/gradle-wrapper.properties"
    click CLIConfig "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/micronaut-cli.yml"
    click Tests "https://github.com/aldrinm/micronaut-retryable-sample/blob/main/src/test/java/aldrinm/HelloClientSpec.java"

    %% Styles
    classDef inprocess fill:#D0E8FF,stroke:#0066CC,stroke-width:1px
    classDef external fill:#E0FFD8,stroke:#228B22,stroke-width:1px
    classDef config fill:#F0F0F0,stroke:#999999,stroke-width:1px
    classDef build fill:#FFF2CC,stroke:#CC9900,stroke-width:1px
    classDef test fill:#FFE0E0,stroke:#CC0000,stroke-width:1px
```
