An open API service indexing awesome lists of open source software.

https://github.com/omatheusribeiro/clean-architecture-template-dotnet

This repository has a Clean Architecture template using .NET Core 8. It applies the Code First pattern with Migrations to create a SQL Server database. The goal is to guide developers in learning and applying Clean Architecture principles in .NET applications. ๐Ÿš€
https://github.com/omatheusribeiro/clean-architecture-template-dotnet

architecture auto-mapper automapper clean-architecture code-first codefirst dotnet dotnet-core dotnet-core-8 entity-framework entity-framework-core jwt jwt-authentication jwt-token migration sql sql-server viewmodel xunit

Last synced: 3 months ago
JSON representation

This repository has a Clean Architecture template using .NET Core 8. It applies the Code First pattern with Migrations to create a SQL Server database. The goal is to guide developers in learning and applying Clean Architecture principles in .NET applications. ๐Ÿš€

Awesome Lists containing this project

README

        

# ๐Ÿ“Œ Clean Architecture .NET 8 API

## ๐Ÿ“š Overview
The **Clean Architecture .NET 8 API** is a structured and well-organized example of implementing Clean Architecture using **.NET Core 8**. This project serves as a learning reference for developers who want to understand and implement Clean Architecture using best practices and modern development patterns. ๐Ÿš€

This repository demonstrates:

๐Ÿ‘‰ **Separation of Concerns (SoC) through Clean Architecture** ๐Ÿฐ
๐Ÿ‘‰ **Implementation of Code First with Migrations** ๐Ÿ›‚
๐Ÿ‘‰ **Usage of Repository Pattern and Unit of Work** ๐Ÿ”„
๐Ÿ‘‰ **Automated Testing with xUnit** ๐Ÿงช
๐Ÿ‘‰ **Authentication and Authorization with JWT** ๐Ÿ”‘

## ๐Ÿฐ Project Structure
```
clean-architecture-dotnet.Api
โ”œโ”€โ”€ Config # Configuration files, such as AutoMapper settings
โ”‚ โ”œโ”€โ”€ MappingConfig # Mapping profiles for AutoMapper
โ”œโ”€โ”€ Controllers # API controllers handling HTTP requests
โ”‚ โ”œโ”€โ”€ V1 # Versioned API controllers
โ”œโ”€โ”€ Middlewares # Custom middleware components
โ”œโ”€โ”€ Properties # Metadata and project properties

clean-architecture-dotnet.Application
โ”œโ”€โ”€ Mappings # AutoMapper configuration for domain-to-view model mappings
โ”œโ”€โ”€ Models # Application-level data models
โ”‚ โ”œโ”€โ”€ Http # HTTP request/response models
โ”œโ”€โ”€ Services # Business logic and service layer
โ”‚ โ”œโ”€โ”€ Login # Authentication and authorization logic
โ”‚ โ”‚ โ”œโ”€โ”€ Interfaces # Interfaces for login services
โ”‚ โ”œโ”€โ”€ Products # Product-related business logic
โ”‚ โ”‚ โ”œโ”€โ”€ Interfaces # Interfaces for product services
โ”‚ โ”œโ”€โ”€ Sales # Sales-related business logic
โ”‚ โ”‚ โ”œโ”€โ”€ Interfaces # Interfaces for sales services
โ”‚ โ”œโ”€โ”€ Users # User-related business logic
โ”‚ โ”‚ โ”œโ”€โ”€ Interfaces # Interfaces for user services
โ”œโ”€โ”€ ViewModels # View models for API responses
โ”‚ โ”œโ”€โ”€ Products # Product-related view models
โ”‚ โ”œโ”€โ”€ Sales # Sales-related view models
โ”‚ โ”œโ”€โ”€ Users # User-related view models

clean-architecture-dotnet.Domain
โ”œโ”€โ”€ Entities # Core domain entities
โ”‚ โ”œโ”€โ”€ Base # Base classes for domain entities
โ”‚ โ”œโ”€โ”€ Products # Product entity definitions
โ”‚ โ”œโ”€โ”€ Sales # Sales entity definitions
โ”‚ โ”œโ”€โ”€ Users # User entity definitions
โ”œโ”€โ”€ Enums # Enumeration types for the domain layer

clean-architecture-dotnet.Infrastructure
โ”œโ”€โ”€ Authentication # Authentication implementation (JWT, token management)
โ”œโ”€โ”€ Context # Database context configuration (Entity Framework Core)
โ”œโ”€โ”€ EntitiesConfiguration # Database table configurations (EF Core Fluent API)
โ”‚ โ”œโ”€โ”€ Products # Product table configurations
โ”‚ โ”œโ”€โ”€ Sales # Sales table configurations
โ”‚ โ”œโ”€โ”€ Users # User table configurations
โ”œโ”€โ”€ Repositories # Data access layer
โ”‚ โ”œโ”€โ”€ Products # Product repository implementations
โ”‚ โ”‚ โ”œโ”€โ”€ Interfaces # Repository interfaces
โ”‚ โ”œโ”€โ”€ Sales # Sales repository implementations
โ”‚ โ”‚ โ”œโ”€โ”€ Interfaces # Repository interfaces
โ”‚ โ”œโ”€โ”€ Users # User repository implementations
โ”‚ โ”‚ โ”œโ”€โ”€ Interfaces # Repository interfaces

clean-architecture-dotnet.Tests
โ”œโ”€โ”€ Application # Application layer testing
โ”‚ โ”œโ”€โ”€ Products # Product tests implementations
โ”‚ โ”œโ”€โ”€ Sales # Sales tests implementations
โ”‚ โ”œโ”€โ”€ Users # User tests implementations
```

## ๐ŸŽผ Screenshots


Screenshot 1



Architecture Diagram



Screenshot 2

## ๐Ÿš€ Getting Started

### ๐Ÿ“ Prerequisites
Make sure you have the following installed:
- [.NET Core 8 SDK](https://dotnet.microsoft.com/download/dotnet/8.0)
- [SQL Server](https://www.microsoft.com/en-us/sql-server/sql-server-downloads)
- [Postman](https://www.postman.com/) (optional, for API testing)

### ๐Ÿ”ง Installation
```bash
# Clone the repository
git clone https://github.com/your-repo/clean-architecture-dotnet.git
cd clean-architecture-template-dotnet
```

### โš™๏ธ Configuration
Before running the application, configure the **database connection string** in:
- `appsettings.json`
- `appsettings.Development.json`

Example:
```json
"ConnectionStrings": {
"DefaultConnection": "Data Source=localhost;Initial Catalog=clean-architecture-dotnet;Integrated Security=True;TrustServerCertificate=True"
}
```

### โ–ถ๏ธ Running the Application
```bash
# Start the API
dotnet run --project clean-architecture-dotnet.Api
```
The application will automatically check if the database and tables exist. If not, they will be created upon execution.

## ๐Ÿ”‘ Authentication & Initial Token Usage
To generate an authentication token, use the following credentials in the **login endpoint**:
- **Email:** `[email protected]`

## ๐Ÿ› ๏ธ Features & Modules
This application includes:

๐Ÿ‘‰ **User Registration (With Address & Contact Info)** ๐Ÿ‘ค
๐Ÿ‘‰ **Product Management (With Product Types)** ๐Ÿ›‚
๐Ÿ‘‰ **Sales Registration (With Business Rules Applied)** ๐Ÿ’ฐ

## ๐Ÿ› ๏ธ Technologies Used
- **.NET Core 8** ๐Ÿš€
- **Entity Framework Core (Code First + Migrations)** ๐Ÿฐ
- **SQL Server** ๐Ÿ“‚
- **AutoMapper** ๐Ÿ”„
- **xUnit (Unit Testing)** ๐Ÿงช
- **JWT Authentication** ๐Ÿ”‘
- **Repository & Service Layer Pattern** ๐Ÿ“š

## ๐Ÿ“„ License
This project is licensed under the GPL-2.0 License.