GithubHelp home page GithubHelp logo

cleanarchitecture's Introduction

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/.

cleanarchitecture's People

Contributors

mp911de avatar schanne avatar

Watchers

James Cloos 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.