Skip to content

ip33haa/My.API.Template

Repository files navigation

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.

Features:

  • 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.

Technologies Used

  • ASP.NET Core 8 Web API
  • Clean Architecture
  • Mediatr
  • FluentValidation
  • Entity Framework Core
  • JWT Authentication
  • Refresh Tokens
  • xUnit
  • SQL Server (or any preferred database)

Getting Started

Prerequisites

Installation

  1. Clone the repository:
    [git clone https://github.com/ip33haa/API-Template.git]
  2. Navigate to the project directory:
    cd API-Template
  3. 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
      }
    }
                
  4. Database migrations will automatically run:
  5. Start the application:
    dotnet run
  6. Your API will be available at https://localhost:5001 (or http://localhost:5000 for non-SSL).

Packages

 
 
 

Contributors

Languages