This repository contains a sample API project built using the Clean Architecture principles, Onion Architecture, MediatR, and Entity Framework. The project also includes unit tests for all layers and integration tests using xUnit and Nsubstitute.
The purpose of this project is to create a clean boilerplate for an API and to show how to implement specific features.
The project follows the Onion Architecture, which means that the codebase is organized into layers, with the domain model at the center and the outer layers dependent on the inner layers.
The project has the following structure:
The project uses the following dependencies:
To run the project, follow these steps:
dotnet run --project CleanArchitecture.Api
command)https://localhost:<port>/api/<controller>
where <port>
is the port number specified in the project properties and <controller>
is the name of the API controller.dotnet run --project CleanArchitecture.AppHost
in the root directory of the project.Requirements
This is only needed if running the API locally or only the docker image
docker run --name sqlserver -d -p 1433:1433 -e ACCEPT_EULA=Y -e SA_PASSWORD='Password123!#' mcr.microsoft.com/mssql/server
docker run --name rabbitmq -d -p 5672:5672 -p 15672:15672 rabbitmq:4-management
docker run --name redis -d -p 6379:6379 -e ALLOW_EMPTY_PASSWORD=yes redis:latest
options.ConfigurationOptions = new ConfigurationOptions { AbortOnConnectFail = false, EndPoints = { "localhost", "6379" } };
Running the container
docker build -t clean-architecture .
docker run --name clean-architecture -d -p 80:80 -p 8080:8080 clean-architecture
docker build -t clean-architecture .
docker-compose up -d
(Delete: docker-compose down
)k8s-deployment.yml
to your own)kubectl apply -f k8s-deployment.yml
(Delete: kubectl delete -f k8s-deployment.yml
)To run the tests, follow these steps:
This project uses GitHub Actions to build and test the project on every commit to the main branch. The workflow consists of several steps, including restoring packages, building the project and running tests.
This project is a sample implementation of the Clean Architecture principles, Onion Architecture, MediatR, and Entity Framework. It demonstrates how to organize a .NET 9 API project into layers, how to use the MediatR library to implement the mediator pattern, and how to use Entity Framework to access data. It also includes unit tests for all layers and integration tests using xUnit.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4