How jmantillap/taxes-demo-webflux works
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.