The Onion Architecture
The Onion Architecture makes a clear distinction between domain-specific code and the technical code that handles the UI, storage interaction, and hardware resources. This keeps the domain-specific code completely independent of technical tools, such as the operating system, web technology, database, and database interaction tools.
The whole application is organized into layers, with the outermost layer having the sole purpose of providing all the necessary infrastructure (i.e., drivers), UI, and test suites, as shown in the following figure:

Figure 3.1: Basic Onion Architecture
In turn, the application-specific code is organized into several more nested layers. All layers must satisfy the following constraint:
Each layer may reference only inner layers. The way this constraint is implemented depends on the underlying language and stack. For instance, layers can be implemented as packages, namespaces, or libraries. We will implement...