ASP.NET Core Web API with Clean Architecture, CQRS, Mediatr, FluentValidation, and JWT Authentication
Description
This is a robust ASP.NET Core Web API project implementing Clean Architecture, CQRS (Command Query Responsibility Segregation), Mediatr, FluentValidation, Entity Framework Core, Auto Migration, JWT Authentication, Authorization, and Refresh Tokens. The solution is structured to promote separation of concerns, maintainability, and scalability.
- Clean Architecture: Organized project structure with separation of concerns.
- CQRS: Command and Query models for better handling of requests.
- Mediatr: Simplified communication between components.
- FluentValidation: For input validation on requests.
- Entity Framework Core: ORM for database interaction.
- Auto Migration: Automatic database migration on application startup.
- JWT Authentication: Secure user authentication with token-based system.
- Authorization: Role-based authorization for API access control.
- Refresh Tokens: Implementation of refresh tokens for continuous authentication without re-login.
- xUnit Test: Sample mplementation xUnit test for the Auth Controller.
- ASP.NET Core 8 Web API
- Clean Architecture
- Mediatr
- FluentValidation
- Entity Framework Core
- JWT Authentication
- Refresh Tokens
- xUnit
- SQL Server (or any preferred database)
- .NET SDK 8.0
- SQL Server or any database system you plan to use.
- Postman (or any API testing tool)
- Clone the repository:
[git clone https://github.com/ip33haa/API-Template.git] - Navigate to the project directory:
cd API-Template - Create a appsettings.json file (if not included) in the root directory of the API and add your database connection string:
{ "ConnectionStrings": { "DefaultConnection": "YourDatabaseConnectionString" }, "JwtSettings": { "SecretKey": "YourSecretKey", "Issuer": "YourIssuer", "Audience": "YourAudience", "ExpirationInMinutes": 30 } } - Database migrations will automatically run:
- Start the application:
dotnet run - Your API will be available at https://localhost:5001 (or http://localhost:5000 for non-SSL).