Hexagonal Architecture Web API
A simple solution template with ports and adapters.
Objective
The main objective of this template is to give an example of the use of interfaces instead of concretes to decouple the domain project.
Use of:
- .netCore
- Entity Framework.
- Api Versioning.
Recommended improvements:
Due to it is a simple example, it lacks of class that could help.
- ErrorHandler middleware. So, {YourProjectName}.Domain/product/ProductService.cs #21 will be handled in a good way.
- Test project(s). I'm planning to add a test to assert the Exception -> {YourProjectName}.Domain/product/ProductService.cs #21.
- [If needed] Create a database seed.
Requirement:
- This project use PosgreSQL (tested v14), so you can install it or use the docker-compose ({YourProjectName}.App/docker)
Template usage:
Give it a name:
Use the project:
Run the project & test it by swagger:
- It will create a database called "hexagonal_db". Take a look at {YourProjectName}.App/Program.cs #55 & appsettings.json
- Insert some records into the DB/Products
And, that's it!
Hi, I'm Diego 👋
How to reach me: Twitter: @dlplenin / linkedin / YouTube
Money can’t buy happiness, but it can buy beer 🍻. Paypal
| |