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. ๐
- Host: GitHub
- URL: https://github.com/omatheusribeiro/clean-architecture-template-dotnet
- Owner: omatheusribeiro
- License: gpl-2.0
- Created: 2025-02-19T20:35:58.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2025-02-27T16:40:18.000Z (3 months ago)
- Last Synced: 2025-02-27T23:12:28.252Z (3 months ago)
- Topics: 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
- Language: C#
- Homepage:
- Size: 109 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 propertiesclean-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 modelsclean-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 layerclean-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 interfacesclean-architecture-dotnet.Tests
โโโ Application # Application layer testing
โ โโโ Products # Product tests implementations
โ โโโ Sales # Sales tests implementations
โ โโโ Users # User tests implementations
```## ๐ผ Screenshots
![]()
![]()
![]()
## ๐ 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.