Spring Boot Project using Kafka and R2DBC (Part II)
Now we already have our project set up, so we are able to start coding.
The packages will be organized as the following image:

Some ideas were inspired by this excellent book: Get Your Hands Dirty on Clean Architecture
Domain Classes
The Person class:
The Gender enum:
The Measurement class:
The MeasurementType enum:
The MeasurementClassification enum:
Customized Annotations (Optional)
In order to become the code more expressive we can create the following annotations instead of standard Spring annotations (such as @Service, @Component and others):
For Messaging Adapters:
For Persistence Adapters:
For Use Cases:
For Web Adapters:
So Spring will inject components for us and we can use custom annotations.
UseCases, Ports and Business Logic
Finally, let’s create the in/out ports and business logic for the application.
About Person resource:
Port In (UseCase):
And the implementation:
Port Out (To Be Implemented):
About Measurement resource:
Port In (UseCase):
And the implementation:
Port Out (To Be Implemented):
We will need to process the collected measurement, so let’s create a use case for that:
And the implementation:
You can see more details on GitHub: https://github.com/gabrielsmartins/health-service