@@ -8,32 +8,65 @@ In this way our components are loosely coupled and the application logic
8
8
(the domains package) is completely independent of the chosen framework
9
9
and the persistence layer.
10
10
11
- Packages are ordered from the highest level to the lowest one.
12
-
13
- ------
11
+ This is a high level list of the packages in this application template:
14
12
15
13
* ` alembic ` (database migration manager)
16
14
* ` celery_worker ` (async tasks runner)
17
15
* ` common ` (some common boilerplate initialisation shared by all applications )
18
16
* ` http_app ` (http presentation layer)
19
17
* ` gateways ` (database connection manager, repository implementation, event emitter, etc.)
20
-
21
- ------
22
-
23
18
* ` domains ` (services, repository interfaces)
24
19
25
- ------
26
-
27
- Each domain inside the ` domain ` packages has its own layers, depending on the complexity but
20
+ Each domain inside the ` domains ` packages has its own layers, depending on the complexity but
28
21
it is usually composed by at least 2 layers:
29
22
30
23
* Boundary layer (domain logic, DTO, data access interfaces): This layer is the only one that
31
24
should be ever used directly by actors not belonging to the domain (i.e. HTTP routes, other domains)
32
- * ... (domain logic can have multiple layers, depending on the complexity)
25
+ * Domain Logic (this can be multiple layers, depending on the complexity)
33
26
* Entity layer (domain models): No one except the domain should ever use directly the domain models.
34
27
28
+ This is a high level representation of the nested layers in the application:
29
+
30
+ ``` mermaid
31
+ flowchart TD
32
+ subgraph "Framework & Drivers + Interface Adapters"
33
+ alembic
34
+ celery_worker
35
+ http_app
36
+ gateways
37
+ subgraph domains.books["Use Cases"]
38
+ subgraph boundary["Domain Boundary (domains.books)"]
39
+ BookRepositoryInterface
40
+ Book
41
+ BookService
42
+ subgraph tasks["Domain logic"]
43
+ BookTask
44
+ subgraph entities["Books Entities"]
45
+ direction LR
46
+ BookModel
47
+ BookCreatedV1
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ alembic ~~~ domains.books
55
+ celery_worker ~~~ domains.books
56
+ http_app ~~~ domains.books
57
+ gateways ~~~ domains.books
58
+
59
+
60
+ BookCreatedV1 ~~~ BookModel
61
+ Book ~~~ tasks
62
+ BookService ~~~ tasks
63
+ BookRepositoryInterface ~~~ tasks
64
+ ```
65
+
35
66
## Class dependency schema
36
67
68
+ A more detailed view showing the class dependencies and the absence of cyclical dependencies.
69
+
37
70
``` mermaid
38
71
flowchart TD
39
72
celery_worker
@@ -45,8 +78,11 @@ flowchart TD
45
78
46
79
subgraph domains
47
80
subgraph books
81
+ subgraph domain_boundary
82
+ BookService
83
+ end
48
84
subgraph domain_logic
49
- BookService--> BookTask
85
+ BookTask
50
86
end
51
87
subgraph dto
52
88
Book
@@ -63,13 +99,16 @@ flowchart TD
63
99
end
64
100
end
65
101
66
- celery_worker-->domain_logic
102
+ celery_worker-->domain_boundary
67
103
celery_worker-->dto
68
- http_app-->domain_logic
104
+ http_app-->domain_boundary
69
105
http_app-->dto
106
+ domain_boundary-->domain_logic
107
+ domain_boundary-->dto
108
+ domain_boundary-->data_access_interfaces
70
109
domain_logic-->entities
71
110
domain_logic-->dto
72
111
domain_logic-->data_access_interfaces
73
- gateways-..->|Implement| data_access_interfaces
112
+ gateways-... ->|Implement| data_access_interfaces
74
113
data_access_interfaces-->entities
75
114
```
0 commit comments