# jmantillap/taxes-demo-webflux architecture

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

- Interactive diagram: https://gitdiagram.com/jmantillap/taxes-demo-webflux
- Repository: https://github.com/jmantillap/taxes-demo-webflux

## Overview

##### Project Type and Purpose
- The project is a Spring Boot reactive application that implements a tax-related demo (as indicated by the package names and the TaxesDemoApplication). It follows a Hexagonal (ports-and-adapters) or Clean Architecture style because of the clear separation among the domain, application, and infrastructure layers.
- Its core functionality appears to handle tax configurations, holiday-related business rules, message processing, and integration with external systems via REST consumers, messaging (RabbitMQ), and data persistence (using both MongoDB and R2DBC for SQL databases).

##### Analyzing the File Structure
- Top-Level Directories and Files:
- Build and configuration files (build.gradle, settings.gradle, gradle wrapper scripts) show it uses Gradle and Spring Boot.
- The README offers references to Spring Boot Reactive Web, R2DBC, RabbitMQ, and other technologies.
- The src/main directory is organized into {application, domain, infrastructure} packages.
- Domain Layer:
- Contains models for tax configuration, events, holidays, messages, and exceptions.
- Holds the core business use cases (e.g., holiday use case, configuration tax use case, process message use case); these represent the "pure domain logic" of the application.
- Application (or service) Layer:
- Found in src/main/java/.../aplication/config holding configurations for ObjectMapper and use cases.
- Infrastructure Layer:
- Divided into inbound (“in”) and outbound (“out”) adapters.
▪ Inbound: Includes web routes for REST endpoints (ApiMessage, Holiday) as well as event handlers which listen to RabbitMQ messaging.
▪ Outbound: Includes MongoDB adapters, R2DBC connections for relational databases (MySQL), RabbitMQ configuration and event publishing, and REST consumer integrations.
- Documentation:
- The “doc” folder contains environment configuration and deployment examples for MongoDB and RabbitMQ, plus a Postman collection – reinforcing external service integrations.

##### Key Components
- Client/API Layer (Frontend Interaction not part of the code, but the REST ingress is clear):
- API endpoints for “apimessage” and “holiday” in the Inbound Web modules.
- Global exception handling for API errors.
- Event Processing Layer:
- Event subscription configuration and event handlers for RabbitMQ, including both synchronous and reactive flows.
- Domain/Use Case Layer:
- Core business logic for handling tax configurations, holiday rules, and processing messages.
- Persistence and Data Storage:
- MongoDB adapter (infrastructure/out/mongo) for document storage.
- R2DBC layer (infrastructure/out/r2dbc) likely connecting to a relational (MySQL) database.
- External Integrations:
- REST consumer for external calendar API calls.
- Messaging systems interface for RabbitMQ both for inbound events (consumers) and outbound events (publishers).

##### Relationships and Interactions
- Inbound adapters (web controllers and event handlers) receive requests or events and forward them to the corresponding use cases in the domain layer.
- The domain layer encapsulates the core business rules and interacts with external systems (via ports) abstracted in the infrastructure outbound adapters.
- Outbound adapters make calls to data sources (MongoDB, R2DBC) and external services (via REST or messaging with RabbitMQ).
- Configuration components in the application layer set up beans and dependency injection so that the various layers integrate cleanly.

##### Architectural Patterns and Technologies
- Hexagonal / Ports-and-Adapters Architecture is clearly in use, with separate “in” and “out” sides.
- Reactive programming is enabled by Spring Boot Reactive Web.
- Messaging integration is provided with RabbitMQ.
- Database interactions use Spring Data R2DBC for relational data (likely MySQL as noted in R2dbcConfigMysql) and Mongo for document persistence.
- External REST integration via a dedicated restconsumer module.
- The use of use case and port interfaces enforces a clean separation of concerns.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Inbound Adapters"
        APIM["API Layer - apimessage"]:::inbound
        HOLIDAY["API Layer - holiday"]:::inbound
        MQC["RabbitMQ Consumer"]:::inbound
    end

    subgraph "Core Layer"
        DOMAIN["Domain/Use Case Layer"]:::domain
        CONFIG["Application Configuration"]:::config
    end

    subgraph "Outbound Adapters"
        MONGO["MongoDB Adapter"]:::outbound
        R2DBC["R2DBC Adapter (MySQL)"]:::outbound
        REST["REST Calendar Consumer"]:::outbound
        MQQ["RabbitMQ Publisher"]:::outbound
    end

    APIM -->|"calls"| DOMAIN
    HOLIDAY -->|"calls"| DOMAIN
    MQC -->|"triggers"| DOMAIN

    CONFIG -->|"configures"| DOMAIN

    DOMAIN -->|"savesTo"| MONGO
    DOMAIN -->|"savesTo"| R2DBC
    DOMAIN -->|"calls"| REST
    DOMAIN -->|"publishes"| MQQ

    classDef inbound fill:#AEDFF7,stroke:#036,stroke-width:2px;
    classDef domain fill:#C2F0C2,stroke:#008000,stroke-width:2px;
    classDef outbound fill:#F9D0A1,stroke:#A52A2A,stroke-width:2px;
    classDef config fill:#F7D6D6,stroke:#C00,stroke-width:2px;

    click APIM "https://github.com/jmantillap/taxes-demo-webflux/tree/main/src/main/java/work/javiermantilla/tax/infrastructure/in/web/apimessage"
    click HOLIDAY "https://github.com/jmantillap/taxes-demo-webflux/tree/main/src/main/java/work/javiermantilla/tax/infrastructure/in/web/holiday"
    click MQC "https://github.com/jmantillap/taxes-demo-webflux/tree/main/src/main/java/work/javiermantilla/tax/infrastructure/in/event"
    click DOMAIN "https://github.com/jmantillap/taxes-demo-webflux/tree/main/src/main/java/work/javiermantilla/tax/domain"
    click MONGO "https://github.com/jmantillap/taxes-demo-webflux/tree/main/src/main/java/work/javiermantilla/tax/infrastructure/out/mongo"
    click R2DBC "https://github.com/jmantillap/taxes-demo-webflux/tree/main/src/main/java/work/javiermantilla/tax/infrastructure/out/r2dbc"
    click REST "https://github.com/jmantillap/taxes-demo-webflux/tree/main/src/main/java/work/javiermantilla/tax/infrastructure/out/restconsumer/apicalendar"
    click MQQ "https://github.com/jmantillap/taxes-demo-webflux/tree/main/src/main/java/work/javiermantilla/tax/infrastructure/out/mq/events"
    click CONFIG "https://github.com/jmantillap/taxes-demo-webflux/tree/main/src/main/java/work/javiermantilla/tax/aplication/config"
```
