Skip to content

Commit f0a323b

Browse files
committed
Improve architecture.md
Signed-off-by: Federico Busetti <[email protected]>
1 parent 0b8e471 commit f0a323b

File tree

1 file changed

+53
-14
lines changed

1 file changed

+53
-14
lines changed

docs/architecture.md

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,65 @@ In this way our components are loosely coupled and the application logic
88
(the domains package) is completely independent of the chosen framework
99
and the persistence layer.
1010

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:
1412

1513
* `alembic` (database migration manager)
1614
* `celery_worker` (async tasks runner)
1715
* `common` (some common boilerplate initialisation shared by all applications )
1816
* `http_app` (http presentation layer)
1917
* `gateways` (database connection manager, repository implementation, event emitter, etc.)
20-
21-
------
22-
2318
* `domains` (services, repository interfaces)
2419

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
2821
it is usually composed by at least 2 layers:
2922

3023
* Boundary layer (domain logic, DTO, data access interfaces): This layer is the only one that
3124
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)
3326
* Entity layer (domain models): No one except the domain should ever use directly the domain models.
3427

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+
3566
## Class dependency schema
3667

68+
A more detailed view showing the class dependencies and the absence of cyclical dependencies.
69+
3770
```mermaid
3871
flowchart TD
3972
celery_worker
@@ -45,8 +78,11 @@ flowchart TD
4578
4679
subgraph domains
4780
subgraph books
81+
subgraph domain_boundary
82+
BookService
83+
end
4884
subgraph domain_logic
49-
BookService-->BookTask
85+
BookTask
5086
end
5187
subgraph dto
5288
Book
@@ -63,13 +99,16 @@ flowchart TD
6399
end
64100
end
65101
66-
celery_worker-->domain_logic
102+
celery_worker-->domain_boundary
67103
celery_worker-->dto
68-
http_app-->domain_logic
104+
http_app-->domain_boundary
69105
http_app-->dto
106+
domain_boundary-->domain_logic
107+
domain_boundary-->dto
108+
domain_boundary-->data_access_interfaces
70109
domain_logic-->entities
71110
domain_logic-->dto
72111
domain_logic-->data_access_interfaces
73-
gateways-..->|Implement| data_access_interfaces
112+
gateways-...->|Implement| data_access_interfaces
74113
data_access_interfaces-->entities
75114
```

0 commit comments

Comments
 (0)