This repository contains a sample .NET Core application that uses Clean Architecture with Token JWT Authentication, Entity Framework Core, Docker SQL and several other frameworks.
This project follows the principles of Clean Architecture. It is organized into four main layers:
- Presentation Layer
- Application Layer
- Domain Layer
- Infrastructure Layer
Each layer has its own responsibilities, and the dependencies between the layers are always inwards.
The application uses Token JWT Authentication to secure the APIs. The token is generated during the login process and is used to authenticate and authorize requests.
Entity Framework Core is used to create the SQL database. It is responsible for generating the tables, relationships, and constraints based on the domain model.
- JWT (JSON Web Token) for authentication and authorization
- MediatR for implementing CQRS pattern
- FluentValidation for validating requests and responses
- ErrorOr for handling errors and returning results
- Mapster for mapping between entities and DTOs
- AutoFixture for generating test data
To get started with the application, follow these steps:
- Clone the repository.
- Configure the database connection in the appsettings.json file.
- Run the database migration using Entity Framework Core commands.
- Start the application.
In the appsettings.json file, update the connection string with your SQL Server instance information:
"ConnectionStrings": {
"DefaultConnection": "Server=<server>;Database=<database>;User=<username>;Password=<password>;Trusted_Connection=True;MultipleActiveResultSets=true"
}
In the Package Manager Console, run the following command to apply the migration and create the database:
Update-Database
In the command prompt, navigate to the project directory and run the following command:
dotnet run
The application has unit tests for the domain layer, application layer, and infrastructure layer. The tests are written using TDD principles and can be run using the command:
dotnet test
This project is licensed under the MIT License