You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dependencies flow from data layer through repositories and services to controllers. External dependencies (AutoMapper, FluentValidation, Serilog, Swashbuckle) integrate at their respective layers.
98
+
Layered architecture with dependency injection via constructors and interface-based contracts.
99
99
100
100
```mermaid
101
101
@@ -112,11 +112,19 @@ Dependencies flow from data layer through repositories and services to controlle
112
112
113
113
graph RL
114
114
115
-
Models[Models]
115
+
Tests[Tests]
116
116
117
-
subgraph Layer4[" "]
118
-
Data[Data]
119
-
Repositories[Repositories]
117
+
subgraph Layer1[" "]
118
+
Program[Program]
119
+
Serilog[Serilog]
120
+
Swashbuckle[Swashbuckle]
121
+
end
122
+
123
+
subgraph Layer2[" "]
124
+
Controllers[Controllers]
125
+
Validators[Validators]
126
+
FluentValidation[FluentValidation]
127
+
AspNetCore[ASP.NET Core]
120
128
end
121
129
122
130
subgraph Layer3[" "]
@@ -126,44 +134,43 @@ graph RL
126
134
MemoryCache[MemoryCache]
127
135
end
128
136
129
-
subgraph Layer2[" "]
130
-
Controllers[Controllers]
131
-
Validators[Validators]
132
-
FluentValidation[FluentValidation]
133
-
Swashbuckle[Swashbuckle]
137
+
subgraph Layer4[" "]
138
+
Repositories[Repositories]
139
+
Data[Data]
140
+
EFCore[EF Core]
134
141
end
135
142
136
-
subgraph Layer1[" "]
137
-
Program[Program]
138
-
Configurations[Configurations]
139
-
Serilog[Serilog]
140
-
end
143
+
Models[Models]
141
144
142
-
Tests[Tests]
145
+
%% Strong dependencies
143
146
144
-
%% Application flow
145
-
Data --> Models
146
-
Models --> Repositories
147
-
Repositories --> Services
148
-
Services --> Controllers
147
+
%% Layer 1
149
148
Controllers --> Program
149
+
Serilog --> Program
150
+
Swashbuckle --> Program
150
151
151
-
%% Layer connections
152
-
Models --> Mappings
152
+
%% Layer 2
153
+
Services --> Controllers
153
154
Validators --> Controllers
154
-
Mappings --> Services
155
-
156
-
%% External Dependencies connections
157
-
AutoMapper --> Mappings
158
155
FluentValidation --> Validators
159
-
Serilog --> Program
160
-
Swashbuckle --> Controllers
156
+
AspNetCore --> Controllers
161
157
162
-
%% Supporting Features connections
163
-
Configurations --> Program
158
+
%% Layer 3
159
+
Repositories --> Services
164
160
MemoryCache --> Services
161
+
Mappings --> Services
162
+
AutoMapper --> Mappings
163
+
Models --> Mappings
164
+
165
+
%% Layer 4
166
+
Models --> Repositories
167
+
Models --> Data
168
+
Data --> Repositories
169
+
EFCore --> Data
170
+
EFCore -.-> Repositories
171
+
172
+
%% Soft dependencies
165
173
166
-
%% Tests connections
167
174
Services -.-> Tests
168
175
Controllers -.-> Tests
169
176
@@ -176,10 +183,30 @@ graph RL
176
183
class Data,Models,Repositories,Services,Controllers,Program,Validators,Mappings core;
177
184
class AutoMapper,FluentValidation,Serilog,Swashbuckle deps;
178
185
class Tests test;
179
-
class Configurations,MemoryCache feat;
186
+
class AspNetCore,EFCore,MemoryCache feat;
180
187
```
181
188
182
-
*Layered architecture: Core application flow (blue), supporting features (yellow), external dependencies (red), and test coverage (green). Not all dependencies are shown.*
189
+
### Arrow Semantics
190
+
191
+
Arrows point from a dependency toward its consumer. Solid arrows (`-->`) denote **strong (functional) dependencies**: the consumer actively invokes behavior — registering types with the IoC container, executing queries, applying mappings, or handling HTTP requests. Dotted arrows (`-.->`) denote **soft (structural) dependencies**: the consumer only references types or interfaces without invoking runtime behavior. This distinction follows UML's `«use»` dependency notation and classical coupling theory (Myers, 1978): strong arrows approximate *control or stamp coupling*, while soft arrows approximate *data coupling*, where only shared data structures cross the boundary.
192
+
193
+
### Composition Root Pattern
194
+
195
+
The `Program` module acts as the composition root — it is the sole site where dependencies are registered with the IoC container, wired via interfaces, and resolved at runtime by the ASP.NET Core host. Rather than explicit object construction, .NET relies on built-in dependency injection: `Program` registers services, repositories, DbContext, mappers, validators, and middleware, and the framework instantiates them on demand. This pattern enables dependency injection, improves testability, and ensures no other module bears responsibility for type registration or lifecycle management.
196
+
197
+
### Layered Architecture
198
+
199
+
The codebase is organized into four conceptual layers: Initialization (`Program`), HTTP (`Controllers`, `Validators`), Business (`Services`, `Mappings`), and Data (`Repositories`, `Data`).
200
+
201
+
Framework packages and third-party dependencies are co-resident within the layer that consumes them: `Serilog` and `Swashbuckle` inside Initialization, `ASP.NET Core` and `FluentValidation` inside HTTP, `AutoMapper` inside Business, and `EF Core` inside Data. `ASP.NET Core`, `EF Core`, and `MemoryCache` are Microsoft platform packages (yellow); `AutoMapper`, `FluentValidation`, `Serilog`, and `Swashbuckle` are third-party packages (red).
202
+
203
+
The `Models` package is a **cross-cutting type concern** — it defines shared entities and DTOs consumed across multiple layers via strong dependencies, without containing logic or behavior of its own. Dependencies always flow from consumers toward their lower-level types: each layer depends on (consumes) the layers below it, and no layer invokes behavior in a layer above it.
204
+
205
+
### Color Coding
206
+
207
+
Core packages (blue) implement the application logic, supporting features (yellow) are Microsoft platform packages, third-party dependencies (red) are community packages, and tests (green) ensure code quality.
208
+
209
+
*Simplified, conceptual view — not all components or dependencies are shown.*
0 commit comments