Skip to content

Commit e40f4a3

Browse files
authored
Merge pull request #9 from thangchung/feature/net6
2 parents 82503fd + fb9b2d2 commit e40f4a3

File tree

259 files changed

+1783
-3936
lines changed

Some content is hidden

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

259 files changed

+1783
-3936
lines changed

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ README.md
2828
.devcontainer/certs
2929
.logs
3030
out/
31+
assets/
32+
rs/
33+
.github
34+
.config
35+
components
36+
src/Web
37+
nuget.config
38+
global.json

README.md

Lines changed: 49 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
# practical-clean-ddd
1+
# clean-architecture-dotnet
22

3-
The practical repository uses coolstore domain which is mainly borrowed from `https://github.com/zkavtaskin/Domain-Driven-Design-Example` to demonstrate how to apply Domain Driven Design seamlessly with Clean Architecture.
3+
"Everything should be made as simple as possible, but not simpler." - Albert Einstein
44

5-
[![Sparkline](https://stars.medv.io/thangchung/practical-clean-ddd.svg)](https://stars.medv.io/thangchung/practical-clean-ddd)
5+
"Mọi thứ đều nên đơn giản, càng đơn giản càng tốt, nhưng không nên đơn giản hơn bản chất của nó." - Vietnamese translated
6+
7+
We know that, and that's a reason we publish these libraries and samples. These are distillations with all best practices, tips, and tricks, and whatever made us spend a lot of time struggling to solve.
8+
9+
In the end of our journey, we would like to give these simplified and effortless libraries and samples as a reward for you. Enjoy the Minimal Clean Architecture, Domain-driven Design Lite, CQRS Lite, and just enough Cloud-native patterns!
10+
11+
[![Sparkline](https://stars.medv.io/thangchung/clean-architecture-dotnet.svg)](https://stars.medv.io/thangchung/clean-architecture-dotnet)
12+
13+
> Even we're trying to do the best, but make sure you stress test carefully if you want to use these libs in the production environment.
614
715
## Give a star ⭐
816

917
If you're using this repository for your samples, workshop, your project or whatever, please give a star ⭐. Thank you very much :+1:
1018

11-
> Plz, use this project with care because we're using this repository for brainstorming new ideas in .NET and containerization worlds!
12-
1319
# Give it a try!
1420

1521
- Prerequisite
16-
- .NET SDK: 5.0.200-preview.21079.7
17-
- Rust: v1.50.0
18-
- nodejs: v15.5.1
19-
- tye: 0.7.0-alpha.21070.7+eb3b50699b7a5f2d0997a5cc8c5185d056dde8ec
20-
- dapr: 1.0.0
22+
- [.NET SDK](https://dotnet.microsoft.com/download/dotnet/6.0): 6.0.100-preview.5.21271.2
23+
- [nodejs](https://nodejs.org/en/download): v15.5.1
24+
- [tye](https://github.com/dotnet/tye): 0.8.0-alpha.21301.1+0fed0b38e730cd07caf0a90287090638c110b77d
25+
- [dapr](https://dapr.io/): 1.2.0
26+
- Dev tools:
27+
- [vscode tye](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-tye) extension
28+
- [vscode REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension
2129

2230
- Starting the Api
2331

2432
```
2533
$ tye run
2634
```
2735

28-
- Starting the web application
29-
30-
```
31-
$ cd src\Web
32-
$ npm i
33-
$ npm run dev
34-
```
35-
3636
- Public Apis:
3737

3838
> Tye Dashboard: [http://localhost:8000](http://localhost:8000)
39-
>
39+
>
4040
> Play around at [restclient.http](restclient.http)
4141
4242
<table>
@@ -68,12 +68,7 @@ $ npm run dev
6868
</tr>
6969
<tr>
7070
<td>5</td>
71-
<td>audit (internal)</td>
72-
<td><a href="http://localhost:5010">http://localhost:5010</a></td>
73-
</tr>
74-
<tr>
75-
<td>6</td>
76-
<td>frontend</td>
71+
<td>frontend (not updated)</td>
7772
<td><a href="http://localhost:3000">http://localhost:3000</a></td>
7873
</tr>
7974
</tbody>
@@ -93,36 +88,42 @@ $ npm run dev
9388

9489
# Clean Domain Driven-design
9590

96-
Domain-driven Design demonstrates it can help the business tidy and organized in many years. But it is hard to approach and use, we need to make it easier to use in the real project when we get started.
91+
Domain-driven Design demonstrates it can help the business tidy and organized in many years. But it is hard to approach and use, we need to make it easier to use in the real project when we get started.
9792

9893
Clean Architecture helps the project structure easier to refactor and evolve in medium and big projects. Especially in the Microservice world, we always want to do and try with a lot of time in the project lifetime.
9994

10095
Clean Domain-driven Design is a collection of basic building blocks and project structure to help we get starting the project with less code boilerplate and effortless. We focus on the Microservice approach of how can we organize code, the project with the monorepo approach, and you can use it for modular monolith project as well.
10196

102-
![](assets/projects_structure.png)
97+
![](assets/DomainDrivenHexagon.png)
98+
Reference to https://github.com/Sairyss/domain-driven-hexagon
99+
100+
# Project structure
101+
102+
![](assets/productapp_minimal_template.png)
103+
104+
## Project dependencies
105+
106+
![](assets/projects_dependencies.png)
103107

104108
## Core project
105109
### Domain
106110

107-
TODO
108-
109-
### Repository
111+
This contains all things to get start the project. Almost there are DDD-lite components just like Entity, AggregateRoot, Specification, Repository.
110112

111-
TODO
113+
Assembly: N8T.Core.dll
112114

113115
## Infrastructure project
114116

115-
TODO
117+
This is where some of component for Clean Architecture resides such as drivers (Entity Framework for PostgresDB, Authentication, Dapr Bus, MVC, Logging, Service Invocation with Dapr, Service Status model, Swagger with SwashBuckle, Transactional Outbox with Dapr, Tye configuration, Validation Model, OpenTelemetry components)
116118

117-
## Application project
119+
Assemblies: N8T.Infrastructure.dll, N8T.Infrastructure.EfCore.dll, N8T.Infrastructure.OTel.dll
118120

119-
TODO
120-
121-
# Public CRUD interface
121+
# Additionals
122+
## Public CRUD interface
122123

123124
In medium and large software projects, we normally implement the CRUD actions over and over again. And it might take around 40-50% codebase just to do CRUD in the projects. The question is can we make standardized CRUD APIs, then we can use them in potential projects in the future? That is in my mind for a long time when I started and finished many projects, and I decide to take time to research and define the public interfaces for it as below
124125

125-
## Common
126+
### Common
126127

127128
```csharp
128129
public record ResultModel<T>(T Data, bool IsError = false, string? ErrorMessage = default);
@@ -136,7 +137,7 @@ public interface ICommand<T> : IRequest<ResultModel<T>> {}
136137
public interface IQuery<T> : IRequest<ResultModel<T>> {}
137138
```
138139

139-
## [R]etrieve
140+
### [R]etrieve
140141

141142
```csharp
142143
// input model for list query (normally using for the table UI control with paging, filtering and sorting)
@@ -163,7 +164,7 @@ public interface IItemQuery<TId, TResponse> : IQuery<TResponse>
163164
}
164165
```
165166

166-
## [C]reate
167+
### [C]reate
167168

168169
```csharp
169170
public interface ICreateCommand<TRequest, TResponse> : ICommand<TResponse>, ITxRequest
@@ -172,7 +173,7 @@ public interface ICreateCommand<TRequest, TResponse> : ICommand<TResponse>, ITxR
172173
}
173174
```
174175

175-
## [U]pdate
176+
### [U]pdate
176177

177178
```csharp
178179
public interface IUpdateCommand<TRequest, TResponse> : ICommand<TResponse>, ITxRequest
@@ -181,7 +182,7 @@ public interface IUpdateCommand<TRequest, TResponse> : ICommand<TResponse>, ITxR
181182
}
182183
```
183184

184-
## [D]elete
185+
### [D]elete
185186

186187
```csharp
187188
public interface IDeleteCommand<TId, TResponse> : ICommand<TResponse> where TId : struct
@@ -190,11 +191,12 @@ public interface IDeleteCommand<TId, TResponse> : ICommand<TResponse> where TId
190191
}
191192
```
192193

193-
# Service Invocation
194+
# Dapr components
195+
## Service Invocation
194196

195197
- RestEase with Dapr handler. More information is at https://dev.to/thangchung/how-to-make-dapr-client-works-well-with-refit-and-restease-40m
196198

197-
# Event Bus
199+
## Event Bus
198200

199201
```csharp
200202
public interface IEventBus
@@ -207,7 +209,7 @@ public interface IEventBus
207209

208210
- Dapr provider
209211

210-
# Transactional Outbox
212+
## Transactional Outbox
211213

212214
```csharp
213215
public class OutboxEntity
@@ -243,38 +245,14 @@ public class OutboxEntity
243245

244246
- Dapr provider
245247

246-
# Private `nuget` for NetCoreKit
247-
248-
Fork this repository!
249-
250-
Set global nuget for accessing in Visual Studio
251-
252-
```
253-
# edit C:\Users\<current user>\AppData\Roaming\NuGet\NuGet.Config
254-
255-
```
256-
257-
```xml
258-
<?xml version="1.0" encoding="utf-8"?>
259-
<configuration>
260-
<packageSources>
261-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
262-
<add key="github" value="https://nuget.pkg.github.com/thangchung/index.json" />
263-
</packageSources>
264-
<packageSourceCredentials>
265-
<github>
266-
<add key="Username" value="<your github username>" />
267-
<add key="ClearTextPassword" value="<Github Token>" />
268-
</github>
269-
</packageSourceCredentials>
270-
</configuration>
271-
```
272-
273248
# Sample pages
274249

250+
> We haven't have enough time to update the front-end API just yet :(
251+
275252
![](assets/products_screen.png)
276253

277254
# Refs
255+
- https://github.com/zkavtaskin/Domain-Driven-Design-Example
278256
- [Ant Design Components](https://ant.design/components/overview)
279257
- [C4 PlaintUML Model](https://github.com/plantuml-stdlib/C4-PlantUML/blob/master/samples/C4CoreDiagrams.md)
280258
- [Real world PlantUML](https://real-world-plantuml.com)

assets/DomainDrivenHexagon.png

976 KB
Loading
38.3 KB
Loading

assets/projects_dependencies.png

96.9 KB
Loading

0 commit comments

Comments
 (0)