Spring Boot Project using Kafka and R2DBC (Part II)

Gabriel Martins
1 min readApr 23, 2021

Now we already have our project set up, so we are able to start coding.

The packages will be organized as the following image:

Project Structure

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

Related Links

Previous Tutorial: Tutorial Part I

Next Tutorial: Tutorial Part III

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Gabriel Martins
Gabriel Martins

Written by Gabriel Martins

Just a brazilian guy who loves technology and wants to share the experiences he has learned

No responses yet

Write a response