Skip to content

Quarkus Domain Driven Design Boilerplate with multi-module structure with Gradle

Notifications You must be signed in to change notification settings

dolap-tech/quarkus-ddd-boilerplate

Repository files navigation

Quarkus Domain Driven Design Boilerplate

A sample project following Domain Driven Design based on Quarkus Framework.

Table of Contents

Introduction

The project is structured with Gradle in a multi-module way to split up the code base into smaller modules that has their own dependencies. Hence, we keep the context of modules isolated in terms of dependencies.

It has three sub-modules;

  • domain -> business logic without any dependency, entities, services and repository interfaces etc.
  • application -> controller interfaces, application messages and validators, converters etc.
  • infrastructure -> 3rd party dependencies, framework integrations, controller and repository implementations etc.

DDD Module Diagram

It provides a CRUD sample which has the following operations; list, create, update and delete.

You can inspect the postman collection in the root folder!

We hope this boilerplate can help the developers to focus on their business part.

Prerequisites

  • JDK11
  • GraalVM
  • Docker

Features

  • Gradle (multi-module)
  • Quarkus
  • RestEASY
  • Hibernate ORM with Panache
  • Flyway for db migration
  • PostgreSQL
  • Groovy Spock Framework for testing

If you want to learn more about Quarkus, please visit its website: https://quarkus.io/

Highlights

Groovy Spock Test Framework

Spock Framework has many great features that makes testing more fun! Also, it provides a great developer experience when it comes to Data Driven Testing.

You can check out the links below;

Groovy Spock All in One (Official Doc)

Testing with Groovy Spock by Yeliz from our team (Turkish Article)

Panache

We used Panache's repository pattern to avoid to include Panache dependency to domain module. Using the active record pattern requires adding the Panache dependency to the domain module which is an anti-pattern for our case.

You can check out the link below;

Quarkus Hibernate ORM with Panache

Flyway

Easy to version and handle db migration scripts.

You can check out the link below;

Flyway with Quarkus

Running the application in dev mode

You can run Postgres in your local using our docker-compose.yml file in the root folder. See env/local-database.env file for an additional config.

docker-compose up

You can run your application in dev mode that enables live coding using:

./gradlew quarkusDev

Packaging and running the application

The application can be packaged using:

./gradlew build

It produces the quarkus-ddd-1.0.0.jar file in the /build directory. Be aware that it’s not an über-jar as the dependencies are copied into the build/lib directory.

If you want to build an über-jar, execute the following command:

./gradlew build -Dquarkus.package.type=uber-jar

The application is now runnable using java -jar build/quarkus-ddd-1.0.0.jar.

Creating a native executable

You can create a native executable using:

./gradlew build -Dquarkus.package.type=native

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:

./gradlew build -Dquarkus.package.type=native -Dquarkus.native.container-build=true

You can then execute your native executable with: ./build/quarkus-ddd-1.0.0

If you want to learn more about building native executables, please consult https://quarkus.io/guides/gradle-tooling.

About

Quarkus Domain Driven Design Boilerplate with multi-module structure with Gradle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published