aw-spec-cli 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/.appweaver/ORCH-DIALECT.md +17 -5
- package/assets/.appweaver/orchestrator/README.md +1 -1
- package/assets/.appweaver/orchestrator/adapters/claude_agent_sdk.py +2 -2
- package/assets/.appweaver/orchestrator/adapters/google_antigravity.py +28 -6
- package/assets/.appweaver/orchestrator/modules/delta-spec.orch.yaml +13 -1
- package/assets/.appweaver/orchestrator/orchestrator.py +126 -39
- package/assets/.appweaver/orchestrator/workflows/aw-spec-adopt.orch.yaml +5 -0
- package/assets/.appweaver/orchestrator/workflows/aw-spec-characterize.orch.yaml +1 -0
- package/assets/.appweaver/orchestrator/workflows/aw-spec-onboard.orch.yaml +1 -0
- package/assets/.appweaver/orchestrator/workflows/aw-spec-specify.orch.yaml +888 -141
- package/assets/.appweaver/scripts/bash/aw-spec-actions.sh +826 -16
- package/assets/.appweaver/scripts/powershell/aw-spec-actions.ps1 +780 -12
- package/assets/.appweaver/stack-profiles/java-spring.json +3 -3
- package/assets/.appweaver/templates/spec-template.md +73 -62
- package/assets/.appweaver/templates/story-template.md +107 -0
- package/assets/guardrails/technology/java-spring/ai-rules.md +505 -0
- package/assets/guardrails/technology/java-spring/api-versioning.md +782 -0
- package/assets/guardrails/technology/java-spring/authorization.md +618 -0
- package/assets/guardrails/technology/java-spring/clean-architecture.md +960 -0
- package/assets/guardrails/technology/java-spring/coding-standards.md +821 -0
- package/assets/guardrails/technology/java-spring/dependency-policy.md +91 -0
- package/assets/guardrails/technology/java-spring/domain-driven-design.md +467 -0
- package/assets/guardrails/technology/java-spring/domain_abstraction.md +424 -0
- package/assets/guardrails/technology/java-spring/folder-structure.md +1537 -0
- package/assets/guardrails/technology/java-spring/global_exception_handler.md +247 -0
- package/assets/guardrails/technology/java-spring/logging.md +215 -0
- package/assets/guardrails/technology/java-spring/modular-monolith.md +77 -0
- package/assets/guardrails/technology/java-spring/persistence.md +316 -0
- package/assets/guardrails/technology/java-spring/problem_details.md +98 -0
- package/assets/guardrails/technology/java-spring/result_mapping.md +48 -0
- package/assets/guardrails/technology/java-spring/technology-constitution.md +168 -0
- package/assets/guardrails/technology/java-spring/testing.md +601 -0
- package/assets/guardrails/technology/java-spring/zero-trust.md +210 -0
- package/dist/index.js +0 -0
- package/dist/utils/config.d.ts +22 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +76 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/copy-assets.d.ts.map +1 -1
- package/dist/utils/copy-assets.js +4 -11
- package/dist/utils/copy-assets.js.map +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +11 -7
- package/dist/utils/paths.js.map +1 -1
- package/package.json +2 -1
- package/assets/guardrails/technology/java-spring/README.md +0 -62
- package/dist/commands/update.d.ts +0 -3
- package/dist/commands/update.d.ts.map +0 -1
- package/dist/commands/update.js +0 -142
- package/dist/commands/update.js.map +0 -1
- package/dist/utils/manifest.d.ts +0 -31
- package/dist/utils/manifest.d.ts.map +0 -1
- package/dist/utils/manifest.js +0 -91
- package/dist/utils/manifest.js.map +0 -1
- package/dist/utils/update-engine.d.ts +0 -52
- package/dist/utils/update-engine.d.ts.map +0 -1
- package/dist/utils/update-engine.js +0 -203
- package/dist/utils/update-engine.js.map +0 -1
|
@@ -0,0 +1,960 @@
|
|
|
1
|
+
# Backend Clean Architecture Guidelines
|
|
2
|
+
|
|
3
|
+
> Common technology guardrail for AppWeaver Java/Spring applications.
|
|
4
|
+
>
|
|
5
|
+
> AppWeaver Java applications use Hexagonal Architecture (Ports and Adapters) within a Modular Monolith.
|
|
6
|
+
>
|
|
7
|
+
> This document defines architectural boundaries and dependency rules. It does not define domain-specific business behavior, module-specific business rules, or database-specific implementation standards.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1. Architecture Pattern
|
|
12
|
+
|
|
13
|
+
AppWeaver Java applications MUST follow **Hexagonal Architecture (Ports and Adapters)**.
|
|
14
|
+
|
|
15
|
+
The application MAY be organized as a **Modular Monolith**, where multiple cohesive modules exist within a single deployable application.
|
|
16
|
+
|
|
17
|
+
Hexagonal Architecture defines dependency direction.
|
|
18
|
+
|
|
19
|
+
Modular Monolith defines module ownership and module boundaries.
|
|
20
|
+
|
|
21
|
+
Both MUST be applied together.
|
|
22
|
+
|
|
23
|
+
The architecture MUST prevent business logic from becoming coupled to:
|
|
24
|
+
|
|
25
|
+
- Spring MVC
|
|
26
|
+
- Spring Security
|
|
27
|
+
- JPA
|
|
28
|
+
- Hibernate
|
|
29
|
+
- JDBC
|
|
30
|
+
- database implementations
|
|
31
|
+
- external service SDKs
|
|
32
|
+
- messaging frameworks
|
|
33
|
+
- HTTP-specific types
|
|
34
|
+
- servlet APIs
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 2. AppWeaver Java Foundation Structure
|
|
39
|
+
|
|
40
|
+
All production Java code MUST follow the predefined AppWeaver Java foundation.
|
|
41
|
+
|
|
42
|
+
The mandatory production source root is:
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
backend/src/main/java/io/appweaver/
|
|
46
|
+
````
|
|
47
|
+
|
|
48
|
+
The established architectural structure is:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
backend/src/main/java/io/appweaver/
|
|
52
|
+
├── adapter/
|
|
53
|
+
├── application/
|
|
54
|
+
├── domain/
|
|
55
|
+
└── infrastructure/
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
These four architectural areas MUST remain the primary structure of the application.
|
|
59
|
+
|
|
60
|
+
AI agents MUST NOT introduce alternative top-level architectural structures such as:
|
|
61
|
+
|
|
62
|
+
```text
|
|
63
|
+
controller/
|
|
64
|
+
service/
|
|
65
|
+
repository/
|
|
66
|
+
feature/
|
|
67
|
+
features/
|
|
68
|
+
verticalslice/
|
|
69
|
+
usecase/
|
|
70
|
+
persistence/
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
directly under:
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
backend/src/main/java/io/appweaver/
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
New packages MUST be created within the established foundation structure.
|
|
80
|
+
|
|
81
|
+
The exact subpackage structure MUST follow the active AppWeaver Java foundation and existing project conventions.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 3. Architectural Layers
|
|
86
|
+
|
|
87
|
+
### 3.1 Domain
|
|
88
|
+
|
|
89
|
+
The domain layer contains business concepts, rules, and invariants.
|
|
90
|
+
|
|
91
|
+
The domain MAY contain:
|
|
92
|
+
|
|
93
|
+
* entities;
|
|
94
|
+
* aggregates;
|
|
95
|
+
* value objects;
|
|
96
|
+
* domain services;
|
|
97
|
+
* domain events;
|
|
98
|
+
* domain policies;
|
|
99
|
+
* domain-specific exceptions;
|
|
100
|
+
* domain abstractions required by genuine domain rules.
|
|
101
|
+
|
|
102
|
+
The domain MUST remain independent of infrastructure and delivery frameworks.
|
|
103
|
+
|
|
104
|
+
The domain MUST NOT directly depend on:
|
|
105
|
+
|
|
106
|
+
* Spring;
|
|
107
|
+
* Spring Boot;
|
|
108
|
+
* Spring MVC;
|
|
109
|
+
* Spring Security;
|
|
110
|
+
* JPA;
|
|
111
|
+
* Hibernate;
|
|
112
|
+
* JDBC;
|
|
113
|
+
* Servlet APIs;
|
|
114
|
+
* HTTP types;
|
|
115
|
+
* database-specific APIs;
|
|
116
|
+
* external SDKs.
|
|
117
|
+
|
|
118
|
+
Domain objects MUST enforce applicable business invariants.
|
|
119
|
+
|
|
120
|
+
Value objects SHOULD be immutable.
|
|
121
|
+
|
|
122
|
+
Domain events SHOULD remain framework-independent.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## 4. Application Layer
|
|
127
|
+
|
|
128
|
+
The application layer coordinates application use cases.
|
|
129
|
+
|
|
130
|
+
It MAY contain:
|
|
131
|
+
|
|
132
|
+
* input ports;
|
|
133
|
+
* output ports;
|
|
134
|
+
* use-case implementations;
|
|
135
|
+
* application services;
|
|
136
|
+
* commands;
|
|
137
|
+
* queries;
|
|
138
|
+
* application results;
|
|
139
|
+
* application-level policies;
|
|
140
|
+
* application-specific exceptions;
|
|
141
|
+
* transaction boundaries.
|
|
142
|
+
|
|
143
|
+
The application layer MUST depend inward toward the domain.
|
|
144
|
+
|
|
145
|
+
The application layer MUST NOT depend on concrete adapters or infrastructure implementations.
|
|
146
|
+
|
|
147
|
+
Application use cases SHOULD be represented through explicit input ports.
|
|
148
|
+
|
|
149
|
+
Example:
|
|
150
|
+
|
|
151
|
+
```java
|
|
152
|
+
public interface CreateProjectUseCase {
|
|
153
|
+
|
|
154
|
+
ProjectResult create(CreateProjectCommand command);
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
An application service MAY implement the input port:
|
|
159
|
+
|
|
160
|
+
```java
|
|
161
|
+
public class CreateProjectService implements CreateProjectUseCase {
|
|
162
|
+
|
|
163
|
+
private final LoadProjectPort loadProjectPort;
|
|
164
|
+
private final SaveProjectPort saveProjectPort;
|
|
165
|
+
|
|
166
|
+
// ...
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
The application layer MUST depend on output port interfaces rather than concrete persistence or external-system implementations.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 5. Input Ports
|
|
175
|
+
|
|
176
|
+
Input ports represent application capabilities exposed to inbound adapters.
|
|
177
|
+
|
|
178
|
+
Example:
|
|
179
|
+
|
|
180
|
+
```java
|
|
181
|
+
public interface CreateProjectUseCase {
|
|
182
|
+
|
|
183
|
+
ProjectResult create(CreateProjectCommand command);
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Input ports SHOULD:
|
|
188
|
+
|
|
189
|
+
* represent meaningful application capabilities;
|
|
190
|
+
* use application-level input and output models;
|
|
191
|
+
* remain independent of HTTP;
|
|
192
|
+
* remain independent of Spring MVC;
|
|
193
|
+
* remain independent of persistence implementation.
|
|
194
|
+
|
|
195
|
+
Input ports MUST NOT expose:
|
|
196
|
+
|
|
197
|
+
* HTTP request objects;
|
|
198
|
+
* HTTP response objects;
|
|
199
|
+
* JPA entities;
|
|
200
|
+
* Hibernate objects;
|
|
201
|
+
* Servlet objects;
|
|
202
|
+
* Spring Security objects;
|
|
203
|
+
|
|
204
|
+
as part of their application contract.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## 6. Output Ports
|
|
209
|
+
|
|
210
|
+
Output ports define dependencies required by the application from external systems.
|
|
211
|
+
|
|
212
|
+
Examples include:
|
|
213
|
+
|
|
214
|
+
```text
|
|
215
|
+
LoadProjectPort
|
|
216
|
+
SaveProjectPort
|
|
217
|
+
PublishDomainEventPort
|
|
218
|
+
PaymentGatewayPort
|
|
219
|
+
NotificationPort
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Example:
|
|
223
|
+
|
|
224
|
+
```java
|
|
225
|
+
public interface LoadProjectPort {
|
|
226
|
+
|
|
227
|
+
Optional<Project> loadById(ProjectId projectId);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Output ports MUST be interfaces owned by the application side of the architecture.
|
|
232
|
+
|
|
233
|
+
Concrete implementations MUST reside in the appropriate outbound adapter or infrastructure area.
|
|
234
|
+
|
|
235
|
+
The application MUST NOT depend on concrete:
|
|
236
|
+
|
|
237
|
+
* JPA repositories;
|
|
238
|
+
* JDBC implementations;
|
|
239
|
+
* REST clients;
|
|
240
|
+
* external SDKs;
|
|
241
|
+
* messaging clients.
|
|
242
|
+
|
|
243
|
+
---
|
|
244
|
+
|
|
245
|
+
## 7. Inbound Adapters
|
|
246
|
+
|
|
247
|
+
Inbound adapters translate external requests into application calls.
|
|
248
|
+
|
|
249
|
+
Examples include:
|
|
250
|
+
|
|
251
|
+
* REST controllers;
|
|
252
|
+
* messaging consumers;
|
|
253
|
+
* scheduled-job adapters;
|
|
254
|
+
* CLI adapters;
|
|
255
|
+
* other external entry points.
|
|
256
|
+
|
|
257
|
+
For REST APIs, controllers MUST:
|
|
258
|
+
|
|
259
|
+
* receive HTTP requests;
|
|
260
|
+
* perform appropriate boundary validation;
|
|
261
|
+
* map API contracts to application inputs;
|
|
262
|
+
* invoke application input ports;
|
|
263
|
+
* map application results to API responses.
|
|
264
|
+
|
|
265
|
+
Controllers MUST remain thin.
|
|
266
|
+
|
|
267
|
+
Controllers MUST NOT contain domain business logic.
|
|
268
|
+
|
|
269
|
+
Controllers MUST NOT directly access:
|
|
270
|
+
|
|
271
|
+
* JPA repositories;
|
|
272
|
+
* EntityManager;
|
|
273
|
+
* Hibernate;
|
|
274
|
+
* JDBC;
|
|
275
|
+
* database connections;
|
|
276
|
+
* persistence entities;
|
|
277
|
+
* external SDKs;
|
|
278
|
+
* outbound persistence implementations.
|
|
279
|
+
|
|
280
|
+
The preferred flow is:
|
|
281
|
+
|
|
282
|
+
```text
|
|
283
|
+
HTTP Request
|
|
284
|
+
↓
|
|
285
|
+
Inbound Adapter
|
|
286
|
+
↓
|
|
287
|
+
Application Input Port
|
|
288
|
+
↓
|
|
289
|
+
Application Use Case
|
|
290
|
+
↓
|
|
291
|
+
Domain
|
|
292
|
+
↓
|
|
293
|
+
Application Result
|
|
294
|
+
↓
|
|
295
|
+
Inbound Adapter
|
|
296
|
+
↓
|
|
297
|
+
HTTP Response
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
---
|
|
301
|
+
|
|
302
|
+
## 8. Outbound Adapters
|
|
303
|
+
|
|
304
|
+
Outbound adapters implement application output ports.
|
|
305
|
+
|
|
306
|
+
Examples include:
|
|
307
|
+
|
|
308
|
+
* JPA persistence adapters;
|
|
309
|
+
* REST clients;
|
|
310
|
+
* messaging adapters;
|
|
311
|
+
* file-system adapters;
|
|
312
|
+
* external service integrations.
|
|
313
|
+
|
|
314
|
+
Outbound adapters MAY depend on:
|
|
315
|
+
|
|
316
|
+
* Spring;
|
|
317
|
+
* JPA;
|
|
318
|
+
* Hibernate;
|
|
319
|
+
* JDBC;
|
|
320
|
+
* external SDKs;
|
|
321
|
+
* infrastructure-specific libraries.
|
|
322
|
+
|
|
323
|
+
These technology dependencies MUST NOT leak into the domain.
|
|
324
|
+
|
|
325
|
+
Example:
|
|
326
|
+
|
|
327
|
+
```text
|
|
328
|
+
Application Output Port
|
|
329
|
+
↑
|
|
330
|
+
│ implements
|
|
331
|
+
│
|
|
332
|
+
Outbound Adapter
|
|
333
|
+
↓
|
|
334
|
+
Technology
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
For persistence:
|
|
338
|
+
|
|
339
|
+
```text
|
|
340
|
+
Application Output Port
|
|
341
|
+
↑
|
|
342
|
+
│
|
|
343
|
+
JPA Persistence Adapter
|
|
344
|
+
↓
|
|
345
|
+
JPA / Hibernate
|
|
346
|
+
↓
|
|
347
|
+
Database
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## 9. Infrastructure
|
|
353
|
+
|
|
354
|
+
Infrastructure contains technology-specific implementations and configuration.
|
|
355
|
+
|
|
356
|
+
Infrastructure MAY contain:
|
|
357
|
+
|
|
358
|
+
* Spring configuration;
|
|
359
|
+
* persistence configuration;
|
|
360
|
+
* datasource configuration;
|
|
361
|
+
* security configuration;
|
|
362
|
+
* messaging configuration;
|
|
363
|
+
* external client configuration;
|
|
364
|
+
* framework integration;
|
|
365
|
+
* infrastructure-specific beans.
|
|
366
|
+
|
|
367
|
+
Infrastructure MAY depend on framework and technology APIs.
|
|
368
|
+
|
|
369
|
+
Domain code MUST NOT depend on infrastructure.
|
|
370
|
+
|
|
371
|
+
Application code MUST NOT depend on concrete infrastructure implementations.
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## 10. Persistence Boundary
|
|
376
|
+
|
|
377
|
+
Persistence implementation MUST remain outside the domain model.
|
|
378
|
+
|
|
379
|
+
JPA entities MUST NOT automatically be treated as domain entities.
|
|
380
|
+
|
|
381
|
+
Where separate persistence and domain models are used:
|
|
382
|
+
|
|
383
|
+
```text
|
|
384
|
+
Domain Model
|
|
385
|
+
↑
|
|
386
|
+
Mapping
|
|
387
|
+
↑
|
|
388
|
+
Persistence Model
|
|
389
|
+
↑
|
|
390
|
+
JPA / Hibernate
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Persistence entities MUST NOT be exposed directly through:
|
|
394
|
+
|
|
395
|
+
* REST APIs;
|
|
396
|
+
* application contracts;
|
|
397
|
+
* domain APIs.
|
|
398
|
+
|
|
399
|
+
Persistence mapping MUST remain within the appropriate outbound adapter/infrastructure boundary.
|
|
400
|
+
|
|
401
|
+
The persistence technology MUST NOT dictate the domain model.
|
|
402
|
+
|
|
403
|
+
Database-specific implementation rules MUST be defined by the applicable persistence/database guardrails rather than this document.
|
|
404
|
+
|
|
405
|
+
---
|
|
406
|
+
|
|
407
|
+
## 11. Dependency Rule
|
|
408
|
+
|
|
409
|
+
Dependencies MUST point toward the application/domain core.
|
|
410
|
+
|
|
411
|
+
The preferred dependency direction is:
|
|
412
|
+
|
|
413
|
+
```text
|
|
414
|
+
Inbound Adapter
|
|
415
|
+
↓
|
|
416
|
+
Application Input Port
|
|
417
|
+
↓
|
|
418
|
+
Application
|
|
419
|
+
↓
|
|
420
|
+
Domain
|
|
421
|
+
|
|
422
|
+
Application
|
|
423
|
+
↓
|
|
424
|
+
Output Port
|
|
425
|
+
↑
|
|
426
|
+
Outbound Adapter
|
|
427
|
+
↓
|
|
428
|
+
Infrastructure / External Technology
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
The domain MUST NOT depend on:
|
|
432
|
+
|
|
433
|
+
* application;
|
|
434
|
+
* adapter;
|
|
435
|
+
* infrastructure.
|
|
436
|
+
|
|
437
|
+
The application MUST NOT depend on:
|
|
438
|
+
|
|
439
|
+
* inbound adapters;
|
|
440
|
+
* outbound adapters;
|
|
441
|
+
* infrastructure implementations.
|
|
442
|
+
|
|
443
|
+
Adapters and infrastructure depend inward through application contracts and ports.
|
|
444
|
+
|
|
445
|
+
---
|
|
446
|
+
|
|
447
|
+
## 12. Dependency Inversion
|
|
448
|
+
|
|
449
|
+
The application core MUST own the interfaces required to communicate with external systems.
|
|
450
|
+
|
|
451
|
+
Example:
|
|
452
|
+
|
|
453
|
+
```text
|
|
454
|
+
Application
|
|
455
|
+
|
|
|
456
|
+
| owns
|
|
457
|
+
↓
|
|
458
|
+
SaveProjectPort
|
|
459
|
+
↑
|
|
460
|
+
| implements
|
|
461
|
+
|
|
|
462
|
+
JpaProjectAdapter
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
This prevents:
|
|
466
|
+
|
|
467
|
+
* persistence;
|
|
468
|
+
* messaging;
|
|
469
|
+
* HTTP clients;
|
|
470
|
+
* external SDKs;
|
|
471
|
+
|
|
472
|
+
from becoming direct dependencies of the application core.
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## 13. Application Services
|
|
477
|
+
|
|
478
|
+
Application services implement or coordinate application use cases.
|
|
479
|
+
|
|
480
|
+
They SHOULD:
|
|
481
|
+
|
|
482
|
+
* coordinate application operations;
|
|
483
|
+
* invoke domain behavior;
|
|
484
|
+
* use output ports;
|
|
485
|
+
* enforce application-level policies;
|
|
486
|
+
* define appropriate transaction boundaries;
|
|
487
|
+
* return application-level results.
|
|
488
|
+
|
|
489
|
+
Application services MUST NOT contain HTTP-specific behavior.
|
|
490
|
+
|
|
491
|
+
Application services MUST NOT depend directly on:
|
|
492
|
+
|
|
493
|
+
* controllers;
|
|
494
|
+
* HTTP request/response objects;
|
|
495
|
+
* JPA repositories;
|
|
496
|
+
* EntityManager;
|
|
497
|
+
* Hibernate;
|
|
498
|
+
* external SDK implementations.
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
## 14. Transaction Boundaries
|
|
503
|
+
|
|
504
|
+
Transaction boundaries SHOULD normally be established at the application use-case boundary.
|
|
505
|
+
|
|
506
|
+
Spring transaction management MAY be used to implement application transaction boundaries.
|
|
507
|
+
|
|
508
|
+
Example:
|
|
509
|
+
|
|
510
|
+
```java
|
|
511
|
+
@Transactional
|
|
512
|
+
public ProjectResult create(CreateProjectCommand command) {
|
|
513
|
+
...
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
Transaction configuration MUST NOT introduce persistence implementation details into the domain.
|
|
518
|
+
|
|
519
|
+
Transactions SHOULD represent a coherent application operation.
|
|
520
|
+
|
|
521
|
+
Cross-module transactions MUST NOT be introduced merely to simplify module interaction.
|
|
522
|
+
|
|
523
|
+
When cross-module consistency is required, the application SHOULD use an explicitly approved consistency mechanism such as:
|
|
524
|
+
|
|
525
|
+
* domain events;
|
|
526
|
+
* application events;
|
|
527
|
+
* messaging;
|
|
528
|
+
* transactional outbox;
|
|
529
|
+
* compensating actions.
|
|
530
|
+
|
|
531
|
+
The selected mechanism MUST follow the application's architecture and consistency requirements.
|
|
532
|
+
|
|
533
|
+
---
|
|
534
|
+
|
|
535
|
+
## 15. Modular Monolith Boundaries
|
|
536
|
+
|
|
537
|
+
The application MAY contain multiple modules within the same deployable application.
|
|
538
|
+
|
|
539
|
+
Each module SHOULD own its:
|
|
540
|
+
|
|
541
|
+
* domain model;
|
|
542
|
+
* application use cases;
|
|
543
|
+
* persistence implementation;
|
|
544
|
+
* external integrations;
|
|
545
|
+
* public module contracts.
|
|
546
|
+
|
|
547
|
+
Modules MUST NOT access another module's internal implementation directly.
|
|
548
|
+
|
|
549
|
+
Forbidden examples include:
|
|
550
|
+
|
|
551
|
+
```text
|
|
552
|
+
Module A → Module B Repository
|
|
553
|
+
|
|
554
|
+
Module A → Module B JPA Entity
|
|
555
|
+
|
|
556
|
+
Module A → Module B Persistence Adapter
|
|
557
|
+
|
|
558
|
+
Module A → Module B Infrastructure Configuration
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
Modules MAY interact through explicitly exposed contracts or application capabilities.
|
|
562
|
+
|
|
563
|
+
Cross-module dependencies MUST be intentional and MUST NOT bypass module boundaries.
|
|
564
|
+
|
|
565
|
+
A module MUST NOT access another module's database tables or persistence internals merely because they exist in the same physical database.
|
|
566
|
+
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
## 16. Domain Model Independence
|
|
570
|
+
|
|
571
|
+
Domain objects MUST represent business concepts rather than persistence or transport concerns.
|
|
572
|
+
|
|
573
|
+
Avoid:
|
|
574
|
+
|
|
575
|
+
```text
|
|
576
|
+
Domain Entity
|
|
577
|
+
↓
|
|
578
|
+
JPA Mapping
|
|
579
|
+
↓
|
|
580
|
+
Database
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
as an architectural dependency direction.
|
|
584
|
+
|
|
585
|
+
Prefer:
|
|
586
|
+
|
|
587
|
+
```text
|
|
588
|
+
Domain Model
|
|
589
|
+
↑
|
|
590
|
+
Mapping
|
|
591
|
+
↑
|
|
592
|
+
Persistence Model
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
Similarly, API contracts MUST remain separate:
|
|
596
|
+
|
|
597
|
+
```text
|
|
598
|
+
API Contract
|
|
599
|
+
↓
|
|
600
|
+
Application
|
|
601
|
+
↓
|
|
602
|
+
Domain
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
The domain model MUST NOT become an API DTO or persistence entity merely to reduce mapping code.
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
## 17. API Boundary
|
|
610
|
+
|
|
611
|
+
REST API contracts MUST remain at the inbound adapter boundary.
|
|
612
|
+
|
|
613
|
+
API request and response DTOs/records MUST NOT become domain entities.
|
|
614
|
+
|
|
615
|
+
The preferred flow is:
|
|
616
|
+
|
|
617
|
+
```text
|
|
618
|
+
HTTP Request
|
|
619
|
+
↓
|
|
620
|
+
API Request DTO / Record
|
|
621
|
+
↓
|
|
622
|
+
Input Port
|
|
623
|
+
↓
|
|
624
|
+
Application
|
|
625
|
+
↓
|
|
626
|
+
Domain
|
|
627
|
+
↓
|
|
628
|
+
Application Result
|
|
629
|
+
↓
|
|
630
|
+
API Response DTO / Record
|
|
631
|
+
↓
|
|
632
|
+
HTTP Response
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
API versioning MUST follow:
|
|
636
|
+
|
|
637
|
+
```text
|
|
638
|
+
api-versioning.md
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
Global exception handling MUST follow:
|
|
642
|
+
|
|
643
|
+
```text
|
|
644
|
+
global_exception_handler.md
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
Problem Details representation MUST follow:
|
|
648
|
+
|
|
649
|
+
```text
|
|
650
|
+
problem_details.md
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
Result-to-HTTP mapping MUST follow:
|
|
654
|
+
|
|
655
|
+
```text
|
|
656
|
+
result_mapping.md
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
This document MUST NOT redefine those concerns.
|
|
660
|
+
|
|
661
|
+
---
|
|
662
|
+
|
|
663
|
+
## 18. Cross-Cutting Concerns
|
|
664
|
+
|
|
665
|
+
Cross-cutting concerns are implemented when required by the application.
|
|
666
|
+
|
|
667
|
+
They are NOT automatically mandatory for every application.
|
|
668
|
+
|
|
669
|
+
When a cross-cutting concern is required, its dedicated AppWeaver technology guardrail MUST be followed.
|
|
670
|
+
|
|
671
|
+
Applicable Java/Spring guardrails include:
|
|
672
|
+
|
|
673
|
+
```text
|
|
674
|
+
authorization.md
|
|
675
|
+
domain_abstraction.md
|
|
676
|
+
global_exception_handler.md
|
|
677
|
+
logging.md
|
|
678
|
+
problem_details.md
|
|
679
|
+
result_mapping.md
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
This document MUST NOT redefine the implementation rules of those concerns.
|
|
683
|
+
|
|
684
|
+
---
|
|
685
|
+
|
|
686
|
+
## 19. Architecture Validation
|
|
687
|
+
|
|
688
|
+
Projects SHOULD use automated architecture tests to enforce the architectural boundaries.
|
|
689
|
+
|
|
690
|
+
ArchUnit MAY be used for this purpose.
|
|
691
|
+
|
|
692
|
+
The project MAY use another approved architecture-validation mechanism.
|
|
693
|
+
|
|
694
|
+
Recommended rules include:
|
|
695
|
+
|
|
696
|
+
### Domain independence
|
|
697
|
+
|
|
698
|
+
```text
|
|
699
|
+
Domain classes MUST NOT depend on Spring.
|
|
700
|
+
|
|
701
|
+
Domain classes MUST NOT depend on JPA.
|
|
702
|
+
|
|
703
|
+
Domain classes MUST NOT depend on Hibernate.
|
|
704
|
+
|
|
705
|
+
Domain classes MUST NOT depend on HTTP.
|
|
706
|
+
|
|
707
|
+
Domain classes MUST NOT depend on Servlet APIs.
|
|
708
|
+
|
|
709
|
+
Domain classes MUST NOT depend on infrastructure.
|
|
710
|
+
|
|
711
|
+
Domain classes MUST NOT depend on inbound adapters.
|
|
712
|
+
|
|
713
|
+
Domain classes MUST NOT depend on outbound adapters.
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### Application independence
|
|
717
|
+
|
|
718
|
+
```text
|
|
719
|
+
Application classes MUST NOT depend on concrete adapters.
|
|
720
|
+
|
|
721
|
+
Application classes MUST NOT depend on infrastructure implementations.
|
|
722
|
+
|
|
723
|
+
Application classes MUST use output ports for external dependencies.
|
|
724
|
+
```
|
|
725
|
+
|
|
726
|
+
### Inbound adapter rules
|
|
727
|
+
|
|
728
|
+
```text
|
|
729
|
+
Inbound adapters MUST use application input ports.
|
|
730
|
+
|
|
731
|
+
Inbound adapters MUST NOT directly access persistence implementations.
|
|
732
|
+
|
|
733
|
+
Inbound adapters MUST NOT directly access outbound adapters.
|
|
734
|
+
```
|
|
735
|
+
|
|
736
|
+
### Module rules
|
|
737
|
+
|
|
738
|
+
```text
|
|
739
|
+
A module MUST NOT access another module's internal persistence.
|
|
740
|
+
|
|
741
|
+
A module MUST NOT access another module's internal adapters.
|
|
742
|
+
|
|
743
|
+
A module MUST NOT access another module's infrastructure implementation.
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
The exact architecture tests MUST follow the actual package structure of the application.
|
|
747
|
+
|
|
748
|
+
This document MUST NOT assume that a specific class such as `ArchitectureTest.java` exists.
|
|
749
|
+
|
|
750
|
+
---
|
|
751
|
+
|
|
752
|
+
## 20. Testing Strategy
|
|
753
|
+
|
|
754
|
+
Testing MUST respect architectural boundaries.
|
|
755
|
+
|
|
756
|
+
Recommended baseline:
|
|
757
|
+
|
|
758
|
+
| Layer | Recommended Test Type | Typical Tools |
|
|
759
|
+
| -------------------- | -------------------------- | ---------------------------------- |
|
|
760
|
+
| Domain | Unit tests | JUnit 5 |
|
|
761
|
+
| Application | Unit tests | JUnit 5, Mockito where appropriate |
|
|
762
|
+
| Inbound REST Adapter | Integration/slice tests | Spring Boot Test, MockMvc |
|
|
763
|
+
| Persistence Adapter | Integration tests | Spring Boot Test, Testcontainers |
|
|
764
|
+
| External Adapter | Integration/contract tests | Appropriate adapter/test tooling |
|
|
765
|
+
| Full Application | Integration tests | Spring Boot Test, Testcontainers |
|
|
766
|
+
| Architecture | Architecture tests | ArchUnit |
|
|
767
|
+
|
|
768
|
+
The exact testing tools MAY be defined by the active project constitution.
|
|
769
|
+
|
|
770
|
+
Domain tests SHOULD remain framework-independent.
|
|
771
|
+
|
|
772
|
+
Integration tests SHOULD use real infrastructure when behavior depends on database or external-system integration.
|
|
773
|
+
|
|
774
|
+
Testcontainers SHOULD be preferred for integration tests that require real infrastructure compatibility, where practical.
|
|
775
|
+
|
|
776
|
+
---
|
|
777
|
+
|
|
778
|
+
## 21. Test Isolation
|
|
779
|
+
|
|
780
|
+
Tests MUST NOT require production infrastructure.
|
|
781
|
+
|
|
782
|
+
Integration tests MUST use isolated test resources.
|
|
783
|
+
|
|
784
|
+
Tests MUST NOT:
|
|
785
|
+
|
|
786
|
+
* connect to production databases;
|
|
787
|
+
* use production credentials;
|
|
788
|
+
* modify shared production data;
|
|
789
|
+
* depend on developer-specific local configuration.
|
|
790
|
+
|
|
791
|
+
Test configuration MUST remain separate from production configuration.
|
|
792
|
+
|
|
793
|
+
---
|
|
794
|
+
|
|
795
|
+
## 22. AI / AW-Spec Rules
|
|
796
|
+
|
|
797
|
+
AI-generated code MUST:
|
|
798
|
+
|
|
799
|
+
* inspect the existing AppWeaver Java foundation before creating files;
|
|
800
|
+
* inspect the owning module before modifying code;
|
|
801
|
+
* follow the established `adapter`, `application`, `domain`, and `infrastructure` structure;
|
|
802
|
+
* identify the correct architectural layer before creating a class;
|
|
803
|
+
* reuse existing ports and application capabilities where appropriate;
|
|
804
|
+
* preserve dependency direction;
|
|
805
|
+
* keep domain code framework-independent;
|
|
806
|
+
* keep persistence implementations outside the domain;
|
|
807
|
+
* keep API contracts outside the domain;
|
|
808
|
+
* respect Modular Monolith module boundaries;
|
|
809
|
+
* use existing cross-cutting implementations when applicable;
|
|
810
|
+
* add or update appropriate tests.
|
|
811
|
+
|
|
812
|
+
AI agents MUST NOT:
|
|
813
|
+
|
|
814
|
+
* introduce Vertical Slice Architecture;
|
|
815
|
+
* introduce a competing architecture;
|
|
816
|
+
* create a new top-level architectural package;
|
|
817
|
+
* create speculative abstractions;
|
|
818
|
+
* make controllers directly access persistence;
|
|
819
|
+
* expose persistence entities as API contracts;
|
|
820
|
+
* access another module's internal implementation;
|
|
821
|
+
* move framework-specific logic into the domain;
|
|
822
|
+
* introduce cross-module transactions without explicit approval;
|
|
823
|
+
* duplicate application or domain logic merely to support different adapters;
|
|
824
|
+
* introduce technology-specific persistence rules into the domain layer.
|
|
825
|
+
|
|
826
|
+
---
|
|
827
|
+
|
|
828
|
+
## 23. Forbidden Patterns
|
|
829
|
+
|
|
830
|
+
The following patterns are forbidden:
|
|
831
|
+
|
|
832
|
+
```text
|
|
833
|
+
Controller → JPA Repository
|
|
834
|
+
|
|
835
|
+
Controller → EntityManager
|
|
836
|
+
|
|
837
|
+
Controller → Hibernate
|
|
838
|
+
|
|
839
|
+
Controller → JDBC
|
|
840
|
+
|
|
841
|
+
Controller → Database Connection
|
|
842
|
+
|
|
843
|
+
Controller → Persistence Entity
|
|
844
|
+
|
|
845
|
+
Controller → External SDK
|
|
846
|
+
|
|
847
|
+
Domain → Spring
|
|
848
|
+
|
|
849
|
+
Domain → JPA
|
|
850
|
+
|
|
851
|
+
Domain → Hibernate
|
|
852
|
+
|
|
853
|
+
Domain → HTTP
|
|
854
|
+
|
|
855
|
+
Domain → Servlet API
|
|
856
|
+
|
|
857
|
+
Domain → Spring Security
|
|
858
|
+
|
|
859
|
+
Application → Concrete Persistence Adapter
|
|
860
|
+
|
|
861
|
+
Application → Concrete External SDK
|
|
862
|
+
|
|
863
|
+
Application → Infrastructure Implementation
|
|
864
|
+
|
|
865
|
+
Module A → Module B Internal Repository
|
|
866
|
+
|
|
867
|
+
Module A → Module B Internal JPA Entity
|
|
868
|
+
|
|
869
|
+
Module A → Module B Infrastructure
|
|
870
|
+
|
|
871
|
+
API DTO → Persistence Entity Exposure
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
---
|
|
875
|
+
|
|
876
|
+
## 24. Foundation Package Placement
|
|
877
|
+
|
|
878
|
+
All production Java code MUST remain under:
|
|
879
|
+
|
|
880
|
+
```text
|
|
881
|
+
backend/src/main/java/io/appweaver/
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
The established architectural areas are:
|
|
885
|
+
|
|
886
|
+
```text
|
|
887
|
+
backend/src/main/java/io/appweaver/
|
|
888
|
+
├── adapter/
|
|
889
|
+
├── application/
|
|
890
|
+
├── domain/
|
|
891
|
+
└── infrastructure/
|
|
892
|
+
```
|
|
893
|
+
|
|
894
|
+
Responsibility MUST determine package placement.
|
|
895
|
+
|
|
896
|
+
General responsibilities are:
|
|
897
|
+
|
|
898
|
+
```text
|
|
899
|
+
adapter/
|
|
900
|
+
External entry points and technology-facing adapters.
|
|
901
|
+
|
|
902
|
+
application/
|
|
903
|
+
Use cases, application contracts, ports, and application orchestration.
|
|
904
|
+
|
|
905
|
+
domain/
|
|
906
|
+
Business model, business rules, invariants, and domain behavior.
|
|
907
|
+
|
|
908
|
+
infrastructure/
|
|
909
|
+
Technology-specific configuration and infrastructure implementations.
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
The exact subpackage structure MUST follow the active AppWeaver Java foundation and existing project conventions.
|
|
913
|
+
|
|
914
|
+
AI agents MUST NOT invent a competing folder structure.
|
|
915
|
+
|
|
916
|
+
---
|
|
917
|
+
|
|
918
|
+
## 25. Governance
|
|
919
|
+
|
|
920
|
+
Clean Architecture changes MUST comply with:
|
|
921
|
+
|
|
922
|
+
* the active AppWeaver constitution;
|
|
923
|
+
* the predefined AppWeaver Java foundation;
|
|
924
|
+
* Modular Monolith architecture;
|
|
925
|
+
* Hexagonal Architecture principles;
|
|
926
|
+
* applicable technology guardrails;
|
|
927
|
+
* module-specific specifications;
|
|
928
|
+
* generated AW-Spec design artifacts.
|
|
929
|
+
|
|
930
|
+
Project-specific architectural decisions MUST be defined in the project's architecture and design artifacts rather than embedded into this generic technology guardrail.
|
|
931
|
+
|
|
932
|
+
Changes to this document MUST follow the applicable governance and constitution amendment process.
|
|
933
|
+
|
|
934
|
+
---
|
|
935
|
+
|
|
936
|
+
## 26. Summary of Required Standards
|
|
937
|
+
|
|
938
|
+
AppWeaver Java applications MUST follow these principles:
|
|
939
|
+
|
|
940
|
+
* Hexagonal Architecture is the primary architectural pattern.
|
|
941
|
+
* The application MAY be organized as a Modular Monolith.
|
|
942
|
+
* Production code MUST follow the predefined AppWeaver Java foundation.
|
|
943
|
+
* The primary architectural areas are `adapter`, `application`, `domain`, and `infrastructure`.
|
|
944
|
+
* The domain MUST remain framework-independent.
|
|
945
|
+
* Application logic MUST depend on ports rather than concrete infrastructure.
|
|
946
|
+
* Inbound adapters MUST use application input ports.
|
|
947
|
+
* Outbound adapters MUST implement application output ports.
|
|
948
|
+
* Persistence implementations MUST remain outside the domain.
|
|
949
|
+
* API contracts MUST remain at the API boundary.
|
|
950
|
+
* Modules MUST NOT bypass each other's internal implementation.
|
|
951
|
+
* Transaction boundaries SHOULD normally be established at the application use-case boundary.
|
|
952
|
+
* Cross-cutting concerns MUST follow their dedicated technology guardrails when applicable.
|
|
953
|
+
* Architecture rules SHOULD be enforced through automated architecture tests.
|
|
954
|
+
* Tests MUST respect architectural boundaries.
|
|
955
|
+
* AI-generated code MUST follow the existing Java foundation.
|
|
956
|
+
* AI agents MUST NOT introduce Vertical Slice Architecture or another competing package structure.
|
|
957
|
+
* All production Java code MUST remain within the predefined AppWeaver foundation.
|
|
958
|
+
* Database-specific implementation rules MUST be maintained separately from the Clean Architecture guardrail.
|
|
959
|
+
|
|
960
|
+
|