• Stars
    star
    227
  • Rank 175,900 (Top 4 %)
  • Language
    Java
  • Created over 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CleanArchitecture Example

Sampler for Clean Architecture/Onion-Architecture Build Status

Author: Mark Paluch
Technologies: CDI, JSF, JPA, EJB, JPA, JAX-RS
Summary: Example Application built using an Onion-Architecture that incorporates multiple technologies
Source: https://github.com/mp911de/CleanArchitecture

More Information:

What is it?

This simple application consists of a few use cases. The purpose of the application is to show how to apply clean architecture patterns in a Multi-Module Maven/Java environment.

It all starts with the data structures/entities/application model. These models are independent of business logic and delivery mechanisms. The models are specific to your domain, but not necessary specific to your application. They live within the application-model module. Business rules and use cases, the specific things your application does, reside within the use-cases module. They depend on the application-model and perhaps on external things that are represented by boundaries, located in contracts. Those boundaries are an agreement between the use case and the other side that provides a specific implementation. The contracts depend only on the application-model. No ORM entities or external-specific API/entities. ORM, caching implementations, clients to external services implement a contract that is located in external and its sub-modules.

All parts are tied together by the delivery mechanism that integrates the externals and connects the use cases by supplying dependencies to come the system to life.

If you need a different implementation for any external, so you can easily change that specific part without affecting other parts of the system.

These patterns are verified by real life projects.

A word on Clean Architecture

As soon as you dig into the code, you'll notice comments on the one or other class. Subject of these comments is to help to understand the structure and the different styles, which are possible.

You'll notice soon, there are many different styles and ways to approach the Clean Architecture style. There are use cases which are built much more simple, e. g. without input/output boundaries and direct usage of dependency injection and there are use-cases which implement input boundaries and use output boundaries.

In the end it's up to you, how much you're willing to invest in your architecture. This is, however, only a variety of examples to give you an impression, how to express Clean Architecture with Java.

What does it?

The use cases are:

  • CreateOrUpdateItem
  • CreateOrUpdateUser
  • ListItems
  • ListOrders
  • PlaceOrder
  • PlaceOrderValidator

and a few business entities:

  • User
  • OrderItem
  • Order
  • Item

These use cases can be accessed by REST or Web UI (JSF) and are persisted using JPA within an in-memory H2 Database (everything you need is included).

Requirements to run the App

All you need to build this project is Java 6.0 (Java SDK 1.6) or better, Maven 3.0 or better.

The application this project produces is designed to be run on JBoss AS7, WildFly 8 or better. You could easily change the delivery mechanism to a console application with only providing a new delivery mechanism and a different approach how to wire the dependencies.

Build and Deploy the Quickstart

NOTE: The following build command assumes you have configured your Maven user settings. If you have not, you must include Maven setting arguments on the command line.

  1. Open a command line and navigate to the root directory of this project.

  2. Type this command to build and deploy the archive:

     mvn clean package wildfly:run
    
  3. This will start a WildFly 10 instance and deploy target/clean-architecture.war to the newly started instance.

Access the application

The application will be running at the following URL: http://localhost:8080/clean-architecture/.

More Repositories

1

logstash-gelf

Graylog Extended Log Format (GELF) implementation in Java for all major logging frameworks: log4j, log4j2, java.util.logging, logback, JBossAS7 and WildFly 8-12
Java
415
star
2

spring-boot-virtual-threads-experiment

Project Loom Experiment using Spring Boot, Spring WebMVC, and Postgres
Java
110
star
3

spring-cloud-vault-config-samples

Examples for Spring Vault and Spring Cloud Vault Config
Java
93
star
4

microbenchmark-runner

JUnit extensions to launch JMH benchmarks from your IDE during development
Java
80
star
5

testing-with-spring-boot

Repository that explains how to test applications with Spring Boot
Java
52
star
6

reactive-spring

Project Reactor 3.3, Spring Framework 5.2, Spring Data 2.2
Java
48
star
7

spinach

Scalable Java Disque client
Java
34
star
8

redis-stream-demo

Demo for Redis Streams
Java
33
star
9

atsoundtrack

IntelliJ IDEA Plugin providing @soundtrack
Java
33
star
10

r2dbc-postgres-notification-example

Example application to produce and listen to Postgres notifications
Java
21
star
11

iot-distancemeter

Transmit sonic sensor data using RaspberryPi/Logstash/MQTT/Python
Python
21
star
12

rest-api-test

Demo for how to test a REST API with JUnit and RESTEasy 3.0
Java
13
star
13

enigma4j

Enigma βš™οΈβš™οΈβš™οΈ Emulator for Java β˜•
Java
12
star
14

reactive-tx-masterclass

Repository explaining Imperative and Reactive Transactions
Java
8
star
15

my-little-keller

App to manage grocery stock πŸπŸ‡πŸ₯«πŸ¬
Python
7
star
16

r2dbc-examples

Examples for using R2DBC and R2DBC with Spring
Java
7
star
17

Public

Public Git Repo
Java
6
star
18

loom-playground

Project Loom Playground Repository
Java
6
star
19

rename-to-main

Renames the master branch of GitHub repositories to main
Ruby
6
star
20

reactive-coding-workshop

JavaLand 2017 Reactive Coding Workshop with Spring Boot
HTML
5
star
21

under-the-hood-reactive

Reactive Drivers Showcase
Java
4
star
22

heckenlights

Java
4
star
23

remote-mocking

Remote mocking framework for integration testing
Java
4
star
24

reusing-gzip-streams

Java
4
star
25

configurator-maven-plugin

Home of the configurator-maven-plugin.
Java
3
star
26

spring-boot-r2dbc

Moved to https://github.com/spring-projects-experimental/spring-boot-r2dbc
Java
3
star
27

jee-commons

Java
3
star
28

mongo-shardgen

Shell
2
star
29

debuggable-selenide

Debuggable Selenide test sampler
Java
2
star
30

akka-actor-statistics

Pulls statistics (mailbox sizes/processing times) from Akka Actors
Java
2
star
31

reactive-vs-imperative

Java
2
star
32

redis-intro

Introduction to Java Redis Clients
Java
2
star
33

distributed-web-sessions

Example of distributed Java Web Sessions backed by MongoDB (without adding custom classes to Tomcat)
Scala
2
star
34

VoxxedDaysBucharest2017

Repository containing the code of my Reactive Spring Data talk https://speakerdeck.com/mp911de/going-reactive-with-spring-data
Shell
2
star
35

central-logging-tracking-example

Example code for tracking requests in a distributed environment
Java
2
star
36

CCD

Clean Code Examples
Java
2
star
37

logcapture

Capture your Java application logs during integration test
Java
1
star
38

spring-data-examples-runner

Runner for Spring Data Examples
Shell
1
star
39

visualizr

simple graph visualizer
JavaScript
1
star
40

pixl

Display and notification device operating system
Java
1
star
41

devoxxpl-reactive-meets-data-access

Shell
1
star
42

java8-training

Code examples using Java 8
Java
1
star
43

midi-relay

Controlling ETHRLY16 via Midi
Java
1
star
44

cdi-2.0

This repository explains CDI 2.0 features using Weld 3.0.
Java
1
star
45

majug-spring-data-mongodb-deep-dive

Repository explaining Spring Data MongoDB patterns and use cases
Java
1
star
46

logstash-gelf-subsystem

Java
1
star
47

scare-os-halloween-iot

Halloween Scary Eyes Thingy
Arduino
1
star