In this episode, Jeffrey is going to cap off the basic Onion Architecture implementation on .NET 6 by adding to the application a Blazor user interface in the simplest way, to can see how the core of our Onion Architecture structure is created and then add interfaces. First, with an interface to a database. Second, with an interface to a person.
Code Sample: https://github.com/jeffreypalermo/onion-architecture-dotnet-6/tree/issue-4-test-host-dependency-resolution
Interfaces are added in the same manner, but the user interface is typically added last because the rest of the structure needs to get up and running first and then wire it in. Interestingly, in .NET UI projects, typically the UI project also has responsibility for starting up the application, which is a very, explicit responsibility.
It is important to be aware of two responsibilities here. When adding a project to visual studio, the first responsibility is to start up the application, regardless of what it does. The second responsibility is to have an interface for a user, where a human being is actually bringing up a screen, looking at some things that interact, typing in some text boxes, and hitting some buttons. You’re responsible for starting up the application and letting the user interact with it. The same thing with a web service API application or even a backend job that just listens for messages coming on a queue. That’s the way visual studio tooling is always used and the way the dominant framework works. In Onion Architecture, those are treated differently. You’re going to see how to do it and how to make sure not to muddle user interface responsibilities with startup responsibilities.