Skip to content

Commit af42c05

Browse files
Merge branch 'feature/Refactor' into develop
2 parents 29d2b38 + 7a791c7 commit af42c05

File tree

139 files changed

+2284
-5171
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+2284
-5171
lines changed

.github/workflows/github-cicd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
with:
3030
dotnet-version: "8.0.406"
3131
cache: true
32-
cache-dependency-path: "src/**/packages.lock.json"
32+
cache-dependency-path: "**/packages.lock.json"
3333
- name: Install dependencies
3434
run: dotnet restore --locked-mode
3535
- name: Build

README-VIETNAMESE.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,49 @@
44

55
#
66

7+
![Visual Studio Code](https://img.shields.io/badge/Visual%20Studio%20Code-0078d7.svg?style=for-the-badge&logo=visual-studio-code&logoColor=white)
8+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](LICENSE) ![GitHub Release](https://img.shields.io/github/v/release/minhsangdotcom/Clean-Architecture_The-Template?style=for-the-badge&color=orange)
9+
![GitHub Org's stars](https://img.shields.io/github/stars/minhsangdotcom%2FClean-Architecture_The-Template?style=for-the-badge&color=pink)
10+
![GitHub forks](https://img.shields.io/github/forks/minhsangdotcom/Clean-Architecture_The-Template?style=for-the-badge&color=%23f61d9c)
11+
12+
# Bảng nội dung
13+
14+
- [Ngôn ngữ](#)
15+
- [Nhãn](#)
16+
- [Bảng nội dung](#Bảng-nội-dung)
17+
- [Mô Hình Kiến Trúc Sạch (Clean Architecture)](#mô-hình-kiến-trúc-sạch-clean-architecture)
18+
- [Cho mình 1 ⭐ nhé](#cho-minh-1sao-nhe)
19+
- [Định Nghĩa](#định-nghĩa)
20+
- [Lợi ích](#lợi-ích)
21+
- [Nhược điểm](#nhược-điểm)
22+
- [Tính năng :rocket:](#tinh-nang)
23+
- [Nhá hàng cho các tính năng :fire:](#nha-hang-cho-cac-tinh-nang)
24+
- [Authentication](#authentication)
25+
- [Dynamic search and sort](#dynamic-search-and-sort)
26+
- [Cross-cutting concerns](#cross-cutting-concerns)
27+
- [Lưu trử file media bằng Minio](#lưu-trử-file-media-bằng-minio)
28+
- [Tự động dịch message](#tự-động-dịch-message)
29+
- [Sơ lượt về Cấu trúc :mag_right:](#so-luot-ve-cau-truc)
30+
- [Bắt đầu thôi nào](#bắt-đầu-thôi-nào)
31+
- [Cách để chạy ứng dụng](#cách-để-chạy-ứng-dụng)
32+
- [Hướng dẫn sử dụng](#hướng-dẫn-sử-dụng)
33+
- [Authorize](#authorize)
34+
- [Thêm một quyền mới vào ứng dụng](#thêm-một-quyền-mới-vào-ứng-dụng)
35+
- [Bộ lọc](#bộ-lọc)
36+
- [Phân trang](#phân-trang)
37+
- [Công nghệ](#công-nghệ)
38+
- [Hỗ trợ](#hỗ-trợ)
39+
- [Lời cảm ơn](#lời-cảm-ơn)
40+
- [Cấp phép](#cấp-phép)
41+
742
# Mô Hình Kiến Trúc Sạch (Clean Architecture)
843

944
Template này được thiết kế dành cho các bạn backend làm việc với ASP.NET Core. Nó cung cấp một cách hiệu quả để xây dựng các ứng dụng enterprise một cách đơn giản bằng cách tận dụng lợi thế từ kiến trúc Clean Architecture và .NET Core framework.
1045

1146
Với template này, bạn sẽ có được zero configuration, không cần quan tâm đến cấu trúc, cài đặt, môi trường hoặc các thông lệ tốt nhất cho web API, vì tất cả đã được thiết lập :smiley:.
1247

48+
<div id='cho-minh-1sao-nhe'/>
49+
1350
# Cho mình 1 ⭐ nhé
1451

1552
Nếu bạn thấy template này hữu ích và học được điều gì đó từ nó, hãy cân nhắc cho mình một :star:.
@@ -43,7 +80,9 @@ Quy tắc phụ thuộc nói rằng các thành phần phụ thuộc hướng t
4380
- **_Nguy cơ về cấu trúc quá phức tạp_**: Đối với các ứng dụng nhỏ, các tầng bổ sung có thể không cần thiết và dẫn đến sự phức tạp hóa.
4481
- **_Hiệu năng bị suy giảm_**: Sự trích dẫn và trừa tượng(interface) giữa các tầng có thể giảm hiệu năng, tuy nhiên thường là không đáng kể.
4582

46-
# Features :rocket:
83+
<div id='tinh-nang'/>
84+
85+
# Tính năng :rocket:
4786

4887
Có gì đặc biệt khiến cho template này trở nên khác biệt so với những template khác có trên Github?
4988

@@ -69,6 +108,8 @@ Nào hãy cùng mình khám phá nha :
69108
1. [Tự động dịch message](src/Contracts/Common/Messages/)
70109
1. [Mã nguồn mở và Cấp phép MIT](#license)
71110

111+
<div id= 'nha-hang-cho-cac-tinh-nang'/>
112+
72113
# Nhá hàng cho các tính năng :fire:
73114

74115
### Authentication
@@ -147,6 +188,8 @@ http://localhost:8080/api/Users?PageSize=2&Search.Keyword=N%E1%BA%B5ng&Search.Ta
147188
}
148189
```
149190

191+
<div id='so-luot-ve-cau-truc'/>
192+
150193
# Sơ lượt về Cấu trúc :mag_right:
151194

152195
**_Domain_**: Tầng Domain đóng vai trò như phần trung tâm trong Clean Architecture, các thành phần bao gồm:
@@ -556,7 +599,7 @@ Các bạn có thể tìm hiểu thêm ỏ một số link sau đây
556599
557600
Mình thiết kế input đầu vào da trên [Strapi filter](https://docs.strapi.io/dev-docs/api/rest/filters-locale-publication)
558601
559-
Mình đã nhúng sn filter tự động vào tt ccác hàm ly danh sách lp Repository
602+
Mình đã nhúng sn filter tự động vào tt ccác hàm ly danh sáchlp Repository
560603

561604
```csharp
562605
await unitOfWork
@@ -566,6 +609,7 @@ Mình đã nhúng sẳn filter tự động vào tất cả các hàm lấy danh
566609
query.ValidateQuery().ValidateFilter(typeof(ListUserResponse))
567610
);
568611
```
612+
569613
<div id='pagination'/>
570614

571615
### Phân trang
@@ -681,9 +725,12 @@ Offset and cursor pagination được tích hợp sẳn trong template.
681725
- Medator
682726
- XUnit, FluentAssertion, Respawn
683727
- OpenTelemetry
728+
- PostgreSQL
684729
- Redis
685730
- ElasticSearch
686731
- Serilog
732+
- Docker
733+
- Github Workflow
687734

688735
# Hỗ trợ
689736

README.md

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,55 @@
33
[English](README.md) | [Vietnamese](README-VIETNAMESE.md)
44

55
#
6-
7-
# .NET Core Clean Architecture The Template Introduction
6+
![Visual Studio Code](https://img.shields.io/badge/Visual%20Studio%20Code-0078d7.svg?style=for-the-badge&logo=visual-studio-code&logoColor=white)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](LICENSE) ![GitHub Release](https://img.shields.io/github/v/release/minhsangdotcom/Clean-Architecture_The-Template?style=for-the-badge&color=orange)
8+
![GitHub Org's stars](https://img.shields.io/github/stars/minhsangdotcom%2FClean-Architecture_The-Template?style=for-the-badge&color=pink)
9+
![GitHub forks](https://img.shields.io/github/forks/minhsangdotcom/Clean-Architecture_The-Template?style=for-the-badge&color=%23f61d9c)
10+
11+
# Table of Contents
12+
- [1. Language](#1-languages)
13+
- [2. Badges](#2-badge)
14+
- [3. Table of Contents](#3-table-of-contents)
15+
- [2. .NET Core Clean Architecture The Template Introduction](#2-net-core-clean-architecture-the-template-introduction)
16+
- [3. Give a Star! ⭐](#3-give-a-star-)
17+
- [4. What is Clean Architecture?](#4-what-is-clean-architecture)
18+
- [4.0.1 Advandtage](#401-advandtage)
19+
- [4.0.2. Disadvandtage](402-disadvandtage)
20+
- [5. Features :rocket:](#5-features-rocket)
21+
- [6. Demo :fire:](#6-demo-fire)
22+
- [6.0.1. Authentication](#601-authentication)
23+
- [6.0.2. Dynamic search and sort](#602-dynamic-search-and-sort)
24+
- [6.0.3. Cross-cutting concerns](#603-cross-cutting-concerns)
25+
- [6.0.4. AWS S3 by Minio](#604-aws-s3-by-minio)
26+
- [6.0.5. Automatic Translatable Message](#605-automatic-translatable-message)
27+
- [7. Structure Overview :mag\_right:](#7-structure-overview-mag_right)
28+
- [8. Getting started](#8-getting-started)
29+
- [8.1. Run .NET Core Clean Architecture Project](#81-run-net-core-clean-architecture-project)
30+
- [8.2. Basic Usage](#82-basic-usage)
31+
- [8.2.1. Authorize](#821-authorize)
32+
- [8.2.2. Create role with permissions:](#822-create-role-with-permissions)
33+
- [8.2.3. How to add new permissions in your app](#823-how-to-add-new-permissions-in-your-app)
34+
- [8.2.4. Filtering](#824-filtering)
35+
- [8.2.5. Pagination](#825-pagination)
36+
- [9. Technology](#9-technology)
37+
- [10. Support](#10-support)
38+
- [11. Credits](#11-credits)
39+
- [12. Licence](#12-licence)
40+
41+
42+
# 2. .NET Core Clean Architecture The Template Introduction
843

944
This template is designed for backend developer working with ASP.NET Core. It provides you an efficient way to build enterprise applications effortlessly by leveraging advantages of clean architecture structre and .NET Core framework.
1045

1146
With this template, You'll benefit from zero configuration, and don't need to worry about struture, settings, environments or best practices for web APIs, because everything is already set up :smiley:.
1247

13-
# Give a Star! ⭐
48+
# 3. Give a Star! ⭐
1449

1550
If you find this template helpful and learn something from it, please consider giving it a :star:.
1651

1752
Your support motivates me to deliver even better features and improvements in future versions.
1853

19-
# What is Clean Architecture?
54+
# 4. What is Clean Architecture?
2055

2156
Clean Architecture is a software design philosophy introduced by Robert C. Martin (Uncle Bob). It emphasizes the separation of concerns and promotes the organization of code into layers, each with distinct responsibilities. The architecture's primary goal is to create systems that are independent of frameworks, UI, databases, and external agencies, allowing flexibility, scalability, and testability.
2257

@@ -26,7 +61,7 @@ At its core, Clean Architecture organizes code into concentric circles, with eac
2661

2762
The dependency rule states that code dependencies should only point inward, ensuring that inner layers remain isolated from external layers.
2863

29-
### Advandtage
64+
### 4.0.1 Advandtage
3065

3166
- **_Seperation of Concerns_**: Each layer is responsible for a specific aspect of the application, making the code easier to understand and maintain.
3267
- **_Testability_**: Since business logic is decoupled from frameworks and UI, unit testing becomes simpler and more reliable.
@@ -35,15 +70,15 @@ The dependency rule states that code dependencies should only point inward, ensu
3570
- **_Scalability_**: The clear structure supports growth and the addition of new features without significant refactoring.
3671
- **_Framework Independence_**: Avoids being locked into a specific framework, making it easier to migrate to newer technologies.
3772

38-
### Disadvandtage
73+
### 4.0.2. Disadvandtage
3974

4075
- **_Complexity_**: The layered structure can add complexity, especially for smaller projects where simpler architectures might suffice.
4176
- **_Initial Overhead_**: Setting up Clean Architecture requires additional effort to organize layers and follow strict design principles.
4277
- **_Learning Curve_**: Developers unfamiliar with the principles may take time to grasp the structure and its benefits.
4378
- **_Over-Engineering Risk_**: For small-scale applications, the additional layers might be unnecessary and lead to over-complication.
4479
- **_Performance Overhead_**: The abstraction and indirection between layers can introduce slight performance trade-offs, though typically negligible.
4580

46-
# Features :rocket:
81+
# 5. Features :rocket:
4782

4883
What makes this Clean Architecture template stand out from the rest?
4984

@@ -69,9 +104,9 @@ Let's explore the features:
69104
1. [Automactic translatable message](src/Contracts/Common/Messages/)
70105
1. [Open source and MIT license](#licence)
71106

72-
# Demo :fire:
107+
# 6. Demo :fire:
73108

74-
### Authentication
109+
### 6.0.1. Authentication
75110

76111
```json
77112
{
@@ -106,23 +141,23 @@ Let's explore the features:
106141
}
107142
```
108143

109-
### Dynamic search and sort
144+
### 6.0.2. Dynamic search and sort
110145

111146
```
112147
http://localhost:8080/api/Users?PageSize=2&Search.Keyword=N%E1%BA%B5ng&Search.Targets=province.name&Sort=dayOfBirth
113148
```
114149

115150
![search and sort feature](Screenshots/search-sort.png)
116151

117-
### Cross-cutting concerns
152+
### 6.0.3. Cross-cutting concerns
118153

119154
![Cross-cutting Concerns feature](Screenshots/crosscutting-concern.png)
120155

121-
### AWS S3 by Minio
156+
### 6.0.4. AWS S3 by Minio
122157

123158
![AWS s3 feature](Screenshots/AWS_S3_Feature.png)
124159

125-
### Automatic Translatable Message
160+
### 6.0.5. Automatic Translatable Message
126161

127162
```json
128163
{
@@ -147,7 +182,7 @@ http://localhost:8080/api/Users?PageSize=2&Search.Keyword=N%E1%BA%B5ng&Search.Ta
147182
}
148183
```
149184

150-
# Structure Overview :mag_right:
185+
# 7. Structure Overview :mag_right:
151186

152187
**_Domain_**: Domain layer serves as the core of clean architecture application and contains key elements such as:
153188

@@ -261,9 +296,9 @@ _It depends on Application and Infrastructure layer_
261296

262297
**_Contract_** : Contains shared components for Application, Infrastructure and API layer.
263298

264-
# Getting started
299+
# 8. Getting started
265300

266-
## Run .NET Core Clean Architecture Project
301+
## 8.1. Run .NET Core Clean Architecture Project
267302

268303
The following prerequisites are required to build and run the solution:
269304

@@ -362,9 +397,9 @@ dotnet run
362397

363398
Congrat! you are all set up :tada: :tada: :tada: :clap:
364399

365-
## Basic Usage
400+
## 8.2. Basic Usage
366401

367-
### Authorize:
402+
### 8.2.1. Authorize
368403

369404
To Achieve this, let's add AuthorizeBy attribute on controller
370405

@@ -382,7 +417,7 @@ To Achieve this, let's add AuthorizeBy attribute on controller
382417
}
383418
```
384419

385-
### Create role with permissions:
420+
### 8.2.2. Create role with permissions:
386421

387422
Json payload is like
388423

@@ -403,7 +438,7 @@ Json payload is like
403438
}
404439
```
405440

406-
### How to add new permissions in your app
441+
### 8.2.3. How to add new permissions in your app
407442

408443
To get this, let's navigate to constants folder in Infrastructure layer, then open Credential.cs file and pay your attention on PermissionGroups Dictionary
409444

@@ -467,7 +502,7 @@ public static class ObjectPermission
467502

468503
Define your new one, then push it into PermissionGroups dictionary, and restart application.
469504

470-
### Filtering
505+
### 8.2.4. Filtering
471506

472507
To do filter in this template, we use LHS Brackets.
473508

@@ -567,7 +602,7 @@ To Apply dynamic filter, you just call any list method at Repository class
567602
);
568603
```
569604

570-
### Pagination
605+
### 8.2.5. Pagination
571606

572607
This template supports offset pagination and cursor pagination.
573608

@@ -672,7 +707,7 @@ To Enable cursor pagination just add this line
672707
```
673708

674709

675-
# Technology
710+
# 9. Technology
676711

677712
- .NET 8
678713
- EntityFramework core 8
@@ -681,15 +716,18 @@ To Enable cursor pagination just add this line
681716
- Medator
682717
- XUnit, FluentAssertion, Respawn
683718
- OpenTelemetry
719+
- PostgreSQL
684720
- Redis
685721
- ElasticSearch
686722
- Serilog
723+
- Docker
724+
- Github Workflow
687725

688-
# Support
726+
# 10. Support
689727

690728
If you are having problems, please let me know by issue section.
691729

692-
# Credits
730+
# 11. Credits
693731

694732
:heart: Thank you guys so much :heart: :pray:.
695733

@@ -711,6 +749,6 @@ If you are having problems, please let me know by issue section.
711749
- [Clean testing by Jayson Taylor](https://github.com/jasontaylordev/CleanArchitecture/tree/main/tests)\
712750
An inspiring repository of testing best practices, showcasing how to write robust and meaningful tests to ensure the reliability of clean architecture-based projects.
713751

714-
# Licence
752+
# 12. Licence
715753

716754
This project is licensed with the [MIT license](LICENSE).

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ services:
33
image: ghcr.io/${GITHUB_USER_NAME}/${IMAGE_NAME}:latest
44
environment:
55
- ASPNETCORE_ENVIRONMENT=Production
6+
- urls=http://0.0.0.0:8080
67
expose:
78
- "8080"
89
networks:

src/Api/Api.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.11.2" />
3333
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.11.1" />
3434
<PackageReference Include="OpenTelemetry.Instrumentation.EntityFrameworkCore" Version="1.11.0-beta.2" />
35-
3635
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.3.1" />
3736
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.3.1" />
37+
<PackageReference Include="Ardalis.Result.AspNetCore" Version="8.0.0" />
3838
</ItemGroup>
3939

4040
<PropertyGroup>

0 commit comments

Comments
 (0)