# callicoder/spring-webclient-webtestclient-demo architecture

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

- Interactive diagram: https://gitdiagram.com/callicoder/spring-webclient-webtestclient-demo
- Repository: https://github.com/callicoder/spring-webclient-webtestclient-demo

## Overview

##### Main Components
- Spring Boot Application: Represented by the main class (WebclientDemoApplication.java), which bootstraps the application.
- Controller Layer: The GithubController.java exposes REST endpoints which clients of this application interact with.
- Client Layer: The GithubClient.java makes reactive HTTP calls to external Github APIs.
- Configuration: The AppProperties.java in the config package; this component loads application properties (such as the Github username and token) from application.properties.
- Payload/Model: Classes like GithubRepo.java and RepoRequest.java represent the data structures used for API communication.
- External Services: Specifically, the Github API which is being consumed by the application.

##### Diagramming the Relationships and Interactions
- The request is received by the GithubController, which then calls the GithubClient.
- The GithubClient interacts with the Github API (external system) using reactive WebClient.
- The configuration component (AppProperties) is used by the application to inject credentials and tokens required for those calls.
- Data flows from the external Github API back through the GithubClient, then to the controller, and finally as a response to the initial client request.

##### Architectural Patterns and Design Principles
- The application adopts an MVC-like (or layered) architecture, separating concerns between configuration, controller, client (service), and data/model.
- It leverages reactive programming principles with the use of Spring WebClient to handle non-blocking I/O and asynchronous operations.
- Dependency injection is utilized (as it’s a standard practice in Spring Boot) for linking components like AppProperties with the rest of the application.

##### Relevant Technologies, Frameworks, or Libraries
- Spring Boot for application configuration and management.
- Spring 5 Reactive WebClient for calling external APIs reactively.
- Spring WebTestClient for testing the reactive aspects of the REST endpoints.
- Maven for project build and dependency management.
- Java as the primary programming language.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    ClientRequest("Client Request"):::external
    GithubAPI("Github API"):::external
    WebTestClient("Testing: WebTestClient"):::testing

    %% Application Layer Subgraph
    subgraph "Spring Boot Application Layer"
        SpringApp("Spring Boot Application"):::internal
        Controller("Controller – GithubController"):::internal
        ClientLayer("Client – GithubClient"):::internal
        Config("Configuration – AppProperties"):::internal
        subgraph "Domain Models"
            GithubRepo("GithubRepo"):::model
            RepoRequest("RepoRequest"):::model
        end
    end

    %% Relationships
    ClientRequest -->|"calls"| Controller
    Controller -->|"delegates to"| ClientLayer
    ClientLayer -->|"calls"| GithubAPI
    ClientLayer -->|"uses"| Config
    SpringApp -->|"initializes"| Controller
    SpringApp -->|"initializes"| ClientLayer
    SpringApp -->|"loads"| Config
    Controller -->|"transfers data"| GithubRepo
    Controller -->|"transfers data"| RepoRequest
    WebTestClient -.->|"simulates requests"| Controller

    %% Click Events
    click SpringApp "https://github.com/callicoder/spring-webclient-webtestclient-demo/blob/master/src/main/java/com/example/webclientdemo/WebclientDemoApplication.java"
    click Controller "https://github.com/callicoder/spring-webclient-webtestclient-demo/blob/master/src/main/java/com/example/webclientdemo/GithubController.java"
    click ClientLayer "https://github.com/callicoder/spring-webclient-webtestclient-demo/blob/master/src/main/java/com/example/webclientdemo/GithubClient.java"
    click Config "https://github.com/callicoder/spring-webclient-webtestclient-demo/blob/master/src/main/java/com/example/webclientdemo/config/AppProperties.java"
    click GithubRepo "https://github.com/callicoder/spring-webclient-webtestclient-demo/blob/master/src/main/java/com/example/webclientdemo/payload/GithubRepo.java"
    click RepoRequest "https://github.com/callicoder/spring-webclient-webtestclient-demo/blob/master/src/main/java/com/example/webclientdemo/payload/RepoRequest.java"
    click WebTestClient "https://github.com/callicoder/spring-webclient-webtestclient-demo/blob/master/src/test/java/com/example/webclientdemo/WebclientDemoApplicationTests.java"

    %% Styles
    classDef internal fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef external fill:#ffcdd2,stroke:#b71c1c,stroke-width:2px;
    classDef model fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef testing fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
```
