All Projects → splaw88 → onion-architecture

splaw88 / onion-architecture

Licence: other
My Java implementation example of onion architecture

Programming Languages

java
68154 projects - #9 most used programming language
typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to onion-architecture

frontend-clean-architecture
React + TypeScript app built using the clean architecture principles in a more functional way · 🧼 🏛 🍪
Stars: ✭ 1,816 (+3392.31%)
Mutual labels:  clean-architecture, onion-architecture
Domain Driven Hexagon
Guide on Domain-Driven Design, software architecture, design patterns, best practices etc.
Stars: ✭ 4,417 (+8394.23%)
Mutual labels:  clean-architecture, onion-architecture
OnionArchitecture
The onion architecture, introduced by Jeffrey Palermo, overcomes the issues of the layered architecture with great ease. With Onion Architecture, the game-changer is that the Domain Layer (Entities and Validation Rules that are common to the business case ) is at the Core of the Entire Application. This means higher flexibility and lesser coupli…
Stars: ✭ 314 (+503.85%)
Mutual labels:  clean-architecture, onion-architecture
Clean Architecture Manga
🌀 Clean Architecture with .NET6, C#10 and React+Redux. Use cases as central organizing structure, completely testable, decoupled from frameworks
Stars: ✭ 3,104 (+5869.23%)
Mutual labels:  clean-architecture, onion-architecture
archunit-junit5-kotlin
Generic Architecture Tests written in Kotlin using ArchUnit and Junit5
Stars: ✭ 22 (-57.69%)
Mutual labels:  clean-architecture, onion-architecture
awesome-software-architecture
A curated list of awesome articles, videos, and other resources to learn and practice software architecture, patterns, and principles.
Stars: ✭ 1,594 (+2965.38%)
Mutual labels:  clean-architecture, onion-architecture
android
🌦 Vädret
Stars: ✭ 17 (-67.31%)
Mutual labels:  clean-architecture
go-monolith-example
Example Go monolith with embedded microservices and The Clean Architecture
Stars: ✭ 186 (+257.69%)
Mutual labels:  clean-architecture
simple-wallet
This is a simple wallet REST api that is capable of acount deposits and withdrawals, checking for account balance and providing a ministatement. It follows domain driven design practices. The project uses the DDD architecture approach.
Stars: ✭ 32 (-38.46%)
Mutual labels:  clean-architecture
bancher
Flutter Login/Register sample using clean architecture
Stars: ✭ 20 (-61.54%)
Mutual labels:  clean-architecture
redux-clean-architecture
📐 A clean architecture framwork
Stars: ✭ 40 (-23.08%)
Mutual labels:  clean-architecture
Go-Clean-Architecture-REST-API
Golang Clean Architecture REST API example
Stars: ✭ 376 (+623.08%)
Mutual labels:  clean-architecture
EcommerceDDD
Experimental full-stack application using Domain-Driven Design, CQRS, and Event Sourcing.
Stars: ✭ 178 (+242.31%)
Mutual labels:  clean-architecture
ITL
Sample Web API implementation with .NET Core and DDD using Clean Architecture.
Stars: ✭ 29 (-44.23%)
Mutual labels:  clean-architecture
Games
The Games app has two features which are listing and showing detail of games.
Stars: ✭ 15 (-71.15%)
Mutual labels:  clean-architecture
roove
Dating app based on firebase services and facebook login. MVVM-Kotlin-RxJava-Dagger-Databinding
Stars: ✭ 55 (+5.77%)
Mutual labels:  clean-architecture
clean-code-javascript-ko
🛁 Clean Code concepts adapted for JavaScript - 한글 번역판 🇰🇷
Stars: ✭ 1,767 (+3298.08%)
Mutual labels:  clean-architecture
Kata-Dagger2-Android
Kata to practice Dependency injection using Dagger 2.
Stars: ✭ 21 (-59.62%)
Mutual labels:  clean-architecture
Android-Clean-Architecture
This is a sample movie list Android application built to demonstrate use of Clean Architecture tools. Dedicated to all Android Developers - (Kotlin, MVVM, Clean Architecture, Rx-Java, Dagger, OkHttp, Unit Testing, SOLID principles, Code Coverage)
Stars: ✭ 268 (+415.38%)
Mutual labels:  clean-architecture
Reddnet
🎭 Minimal Reddit clone
Stars: ✭ 125 (+140.38%)
Mutual labels:  clean-architecture

Onion architecture

This is the example of Onion Architecture described by Jeffrey Palermo implemented in Java.

What's going on?

I'll try to explain some basics.

Commonly used architecture is Layered Architecture and pretty often (too often as I saw it) is poorly implemented as layers overlaps each other, creating stiff monolith (for example entity object running all the way from database to web UI).

Layer diagram

This architecture basically cut application most commonly to 3 layers: UI, business logic and data storage. Frameworks and other infrastructure elements are mixed in all layers. So what's wrong with that? Basically app is built on data store which often is strictly coupled to the way it's stored and infrastructure standing behind it. Also building app strongly coupled to frameworks makes app strong dependent to it. This is NOT GOOD. Why? Well if app is going to live for just couple years it probably won't be a problem but in long term apps you have to be aware that 3 party dependencies keep changing, they sometimes 'die' or there are released better alternatives. And it's all happening without our control. If you build your app on fundamentals like for example some database vendor and it loose support you will have to rewrite very big portion of your app to adapt it to new solution (or even entire app). This is very expensive and it may be cheaper to write new app abandoning current one.

So lets look at the Onion architecture.

Onion diagram

It basic concept is to entirely decouple our application from everything that is beyond our control like database vendors, IoC container, framework etc. It's keeping our business model in the center (not database model!) then some domain services and on top of it is business logic. Everything else is kept outside of our core application making it more like plugins or exchangeable modules. This approach allow us to focus on WHAT our application DO not HOW it is DONE. So as you can see if 3 party dependencies changes is more like detach a module and connect new one without painful rewriting of business logic. This allows even to have multiple versions of environments for the same business purposes: for example you can have one implementation for fat jar in embedded spring tomcat, other for Jboss server, another as library for others to implement their environment.

To read more visit Jeffrey's blog where he described it in more detail

Onion Architecture part 1

Onion Architecture part 2

Onion Architecture part 3

Onion Architecture part 4

This project

In this project I tried to implement some simple app to log work time. I tried to make it not too complex so it's behaviour is not perfect but should be good example from architectural point.

Currently there are 2 infrastructural implementations:

  1. based on spring boot, h2 in memory database, embedded Tomcat, Rest services and Angular2 web UI.
  2. simple runable console application with no DI containers, and simple inmemory repositories

In the future ill write other infrastructure stack to prove point of strong decoupling.

Building and running

App is build using maven. Simple type in root folder

mvn install

It will download npm to get angular and other web dependencies. Standard maven clean won't clean frontend dependencies so if you wont to clean them as well simply run clean with profile 'node_clean' like this

mvn clean -Pnode_clean

To run Spring Boot web app simply run from spring-based-app module generated jar file, like

java -jar infrastructure/spring-based-app/spring-application/target/spring-application-1.0-SNAPSHOT.jar

it will run Tomcat on address local host:8080

To run console app also just run generated jar, like

java -jar infrastructure/console-based-app/console-application/target/console-application-1.0-SNAPSHOT.jar
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].