Code Monkey home page Code Monkey logo

clean-architecture-example's Introduction

Clean architecture example

Build Status Codacy Badge Coverage Status

The basic purpose of clean architecture is to make clear the intention of what the application does and how it does it.

That is why these two things need to be separated.

Alt text

The what

Package Intent
core Should only need to look inside this package to know what the system does. Has no dependencies to any framework (e.g. Spring, hibernate, play, drop wizard…)
core > domain Entities and value objects
core > usecase The use cases (or application services)
core > boundary The only way into and out of the core. Contains only interfaces.
core > boundary > enter Interfaces that the core > usecase implements. These are used in the adapter (can also be used in the periphery).
core > boundary > exit Interfaces used by the core > usecase. These are implemented in the periphery (e.g. repositories).

The how

Module Intent
adapter Converts the domain objects returned by the uses cases into the appropriate format (e.g. DTO’s) for use in the periphery
periphery Anything framework related (e.g. repositories, controllers)
configuration How the application is glued together (e.g. spring @Configuration classes)

Building and running the app

Enable Annotation Processing

Note: This example app uses Immutables, hence the need to enable annotation processing

In IntelliJ:

  1. File > Settings > Build > Compiler > Annotation Processors
  2. Tick Enable Annotation Processing and select Module content root
  3. Build the project via Build > Build Project
  4. In application > core module right click on generated folder and Mark directory as > Generated Sources Root

Run the application

On the command line in the clean-architecture-example folder type gradlew bootRun

Application URL: http://localhost:13001

REST documentation

URL: http://localhost:13001/swagger-ui.html

To see the Swagger documentation in read-only mode run the application with production profile
On windows: gradlew bootRun -Dspring.profiles.active=production
On linux: SPRING_PROFILES_ACTIVE=production ./gradlew bootRun

clean-architecture-example's People

Contributors

mahanhz avatar

Watchers

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