This project is an example of Modular Monolith with Onion Architecture. Communication between the modules is implemented with events and Event Bus. Onion Architecture is based on 3 layers:
- domain - bussines requirement
- application - frameworks, services, technology specific code
- infrastructure - other systems like DB, JMS, REST API
Check Jeffrey Palermo's blog to learn more about Onion Architecture!
Check also Robert C. Martin's blog post about clean architecture!
Domain is in the heart of software and with this approach we can achieve loosely coupling between modules. If the business is mature then the domain module will stay unchanged. So when the framework became rusty and the team decide to change technology it will have no impact on business code. The same perfomance/integration changes.
The first step to deliver distributed system should be Modular Monolith, since Microservices requires much more infrastructure effort. Additionaly business domain must be stable because changes between the modules are difficult to implement.
Event Bus is a subset of Publish-Subscribe patterns. It's a combination of Observer and Mediator pattern. It's implementation can vary in other languages and frameworks, here's my Java example.
Event Bus is an architectural pattern it's used in distributed asynchronous architecture to create highly scalable reactive applications. It provides loosely coupling between different components.
The domain is based on restaurant which serves eggs.
The project contains only InMemory Repository since it is used only for learning purposes.
├─┬ eggrestaurant
│ ├── commons
│ ├── cooking
│ ├── restaurant
│ └── wash
Domain is based on 3 subdomains since egg means something else for different actors.
- for customer egg means something to eat.
- for cook it means an ingredient to make a meal.
- for dishwasher it means nothing else but ugly slush to wash...
Inspiration based on Wade Waldron's talk: "Domain Driven Design and Onion Architecture in Scala" on Scala Days 2016