Git Product home page Git Product logo

quarkus-hexagonal's Introduction

👋 About

Maven Multi-module project to illustrate how to structure a project based on an hexagonal architecture.

⚙️ Technologies

Common

Technology Purpose
Hexagonal architecture I tried to follow an hexagonal clean architecture when creating this simple example. You can take a look into the project modules to see how the code was divided into application, domain and infrastructure layers. You can also take a look into the interfaces I'm using as "ports" to avoid layer couplings. I think that it could be interesting to understand the difference between the Loan entity at domain level (I will try to complete this example with some DDD concepts), and the LoanEntity at the infrastructure layer.
Lombok Helper to create builders, setters, getters, etc
MapStruct Helper to create mappers to pass objects between the different layers
Quarkus Quarkus is a full-stack, Kubernetes-native Java framework made for Java virtual machines (JVMs) and native compilation, optimizing Java specifically for containers and enabling it to become an effective platform for serverless, cloud, and Kubernetes environments.
JUnit 5 Unit tests creation
Mockito Adds mockito framework for testing purposes

PostgreSQL adapter

Technology Purpose
Hibernate panache Database access
Flyway To load database at start

DynamoDB adapter

Technology Purpose
Dynamodb enhanced Dynamodb enhanced library based on AWS SDK for Java 2.0, compatible with native image and quarkus.

REST adapter

Technology Purpose
Resteasy Annotation based Rest controllers with JSON serialization / desearialization
rest-assured Testing and validating REST services
smallrye-openapi Add OpenAPI spec to the project and helps with the generation of both schema and Swagger UI
OpenAPI The OpenAPI Specification, previously known as the Swagger Specification, is a specification for a machine-readable interface definition language for describing, producing, consuming and visualizing RESTful web services.
openapi-generator-maven-plugin A Maven plugin to support the OpenAPI generator project.

Kafka adapter

Technology Purpose
TBC TBC

🚀 How to execute the application

🛠️ DEV mode

Compile, test, package and install the different artifacts in your local maven repository.

mvn clean install

After creating all artifacts you can run the project in dev mode (hotreload enabled + dev services).

mvn quarkus:dev -pl bootloader

Bootloader module is the providing the quarkus startup point. If you want to switch the db adapter and use adapter-postgresql, you have to comment the adapter-dynamodb dependency in the pom.xml file and uncomment the adapter-postgresql.

This project is using dev services to provide the external services like DB, Event broker, Identity Manager, etc.

In order to use Dev Services you will generally need a working Docker environment (remote environments are supported). If you don’t have Docker installed you will need to configure your services normally.

📦 PROD mode

You will need to package the bootloader module:

mvn clean package -pl bootloader

It produces several outputs in ./bootloader/target:

  • getting-started-1.0.0-SNAPSHOT.jar - containing just the classes and resources of the projects, it’s the regular artifact produced by the Maven build - it is not the runnable jar;

  • the quarkus-app directory which contains the quarkus-run.jar jar file - being an executable jar. Be aware that it’s not an über-jar as the dependencies are copied into subdirectories of quarkus-app/lib/.

You can run the application using: java -jar ./bootloader/target/quarkus-app/quarkus-run.jar

If you want to deploy your application somewhere (typically in a container), you need to deploy the whole quarkus-app directory. Before running the application, don’t forget to stop the hot reload mode (hit CTRL+C), or you will have a port conflict.

For more information about running Quarkus applications (dev, test, prod, native) please take a look at Quarkus - getting started # running-the-application.

quarkus-hexagonal's People

Contributors

fredofm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.