aw-spec-cli 0.1.10 → 0.1.12

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.
Files changed (58) hide show
  1. package/assets/.appweaver/ORCH-DIALECT.md +17 -5
  2. package/assets/.appweaver/orchestrator/README.md +1 -1
  3. package/assets/.appweaver/orchestrator/adapters/claude_agent_sdk.py +2 -2
  4. package/assets/.appweaver/orchestrator/adapters/google_antigravity.py +28 -6
  5. package/assets/.appweaver/orchestrator/modules/delta-spec.orch.yaml +13 -1
  6. package/assets/.appweaver/orchestrator/orchestrator.py +126 -39
  7. package/assets/.appweaver/orchestrator/workflows/aw-spec-adopt.orch.yaml +5 -0
  8. package/assets/.appweaver/orchestrator/workflows/aw-spec-characterize.orch.yaml +1 -0
  9. package/assets/.appweaver/orchestrator/workflows/aw-spec-onboard.orch.yaml +1 -0
  10. package/assets/.appweaver/orchestrator/workflows/aw-spec-specify.orch.yaml +888 -141
  11. package/assets/.appweaver/scripts/bash/aw-spec-actions.sh +826 -16
  12. package/assets/.appweaver/scripts/powershell/aw-spec-actions.ps1 +780 -12
  13. package/assets/.appweaver/stack-profiles/java-spring.json +3 -3
  14. package/assets/.appweaver/templates/spec-template.md +73 -62
  15. package/assets/.appweaver/templates/story-template.md +107 -0
  16. package/assets/guardrails/technology/java-spring/ai-rules.md +505 -0
  17. package/assets/guardrails/technology/java-spring/api-versioning.md +782 -0
  18. package/assets/guardrails/technology/java-spring/authorization.md +618 -0
  19. package/assets/guardrails/technology/java-spring/clean-architecture.md +960 -0
  20. package/assets/guardrails/technology/java-spring/coding-standards.md +821 -0
  21. package/assets/guardrails/technology/java-spring/dependency-policy.md +91 -0
  22. package/assets/guardrails/technology/java-spring/domain-driven-design.md +467 -0
  23. package/assets/guardrails/technology/java-spring/domain_abstraction.md +424 -0
  24. package/assets/guardrails/technology/java-spring/folder-structure.md +1537 -0
  25. package/assets/guardrails/technology/java-spring/global_exception_handler.md +247 -0
  26. package/assets/guardrails/technology/java-spring/logging.md +215 -0
  27. package/assets/guardrails/technology/java-spring/modular-monolith.md +77 -0
  28. package/assets/guardrails/technology/java-spring/persistence.md +316 -0
  29. package/assets/guardrails/technology/java-spring/problem_details.md +98 -0
  30. package/assets/guardrails/technology/java-spring/result_mapping.md +48 -0
  31. package/assets/guardrails/technology/java-spring/technology-constitution.md +168 -0
  32. package/assets/guardrails/technology/java-spring/testing.md +601 -0
  33. package/assets/guardrails/technology/java-spring/zero-trust.md +210 -0
  34. package/dist/index.js +0 -0
  35. package/dist/utils/config.d.ts +22 -0
  36. package/dist/utils/config.d.ts.map +1 -0
  37. package/dist/utils/config.js +76 -0
  38. package/dist/utils/config.js.map +1 -0
  39. package/dist/utils/copy-assets.d.ts.map +1 -1
  40. package/dist/utils/copy-assets.js +4 -11
  41. package/dist/utils/copy-assets.js.map +1 -1
  42. package/dist/utils/paths.d.ts.map +1 -1
  43. package/dist/utils/paths.js +11 -7
  44. package/dist/utils/paths.js.map +1 -1
  45. package/package.json +2 -1
  46. package/assets/guardrails/technology/java-spring/README.md +0 -62
  47. package/dist/commands/update.d.ts +0 -3
  48. package/dist/commands/update.d.ts.map +0 -1
  49. package/dist/commands/update.js +0 -142
  50. package/dist/commands/update.js.map +0 -1
  51. package/dist/utils/manifest.d.ts +0 -31
  52. package/dist/utils/manifest.d.ts.map +0 -1
  53. package/dist/utils/manifest.js +0 -91
  54. package/dist/utils/manifest.js.map +0 -1
  55. package/dist/utils/update-engine.d.ts +0 -52
  56. package/dist/utils/update-engine.d.ts.map +0 -1
  57. package/dist/utils/update-engine.js +0 -203
  58. package/dist/utils/update-engine.js.map +0 -1
@@ -0,0 +1,1537 @@
1
+ # Java Hexagonal Architecture — Reusable Project Structure Standard
2
+
3
+ ## 1. Purpose
4
+
5
+ This document defines the standard project architecture and folder structure for Java applications generated through the AW-Spec spec-driven development pipeline.
6
+
7
+ This document is **project-agnostic** and MUST be reusable across Java projects regardless of the business domain.
8
+
9
+ Examples of projects that MAY use this standard:
10
+
11
+ * Flight Booking
12
+ * Library Management
13
+ * Project Allocation
14
+ * Healthcare
15
+ * Banking
16
+ * E-commerce
17
+ * Order Management
18
+ * Any other Java/Spring Boot application
19
+
20
+ The business domain MUST NOT determine the top-level architectural structure.
21
+
22
+ The project specification determines the business-specific classes, features, entities, use cases, and adapters that are created within this structure.
23
+
24
+ ---
25
+
26
+ # 2. Architectural Style
27
+
28
+ The default architecture is:
29
+
30
+ **Hexagonal Architecture (Ports and Adapters)**
31
+
32
+ with:
33
+
34
+ * Domain-driven design principles
35
+ * Application/use-case layer
36
+ * Inbound and outbound ports
37
+ * Infrastructure adapters
38
+ * Dependency inversion
39
+ * Technology isolation from the domain
40
+
41
+ The architecture MUST separate business rules from technical implementation details.
42
+
43
+ The primary architectural boundaries are:
44
+
45
+ ```text
46
+ adapter
47
+ ↓
48
+ application
49
+ ↓
50
+ domain
51
+
52
+ infrastructure
53
+ ↓
54
+ application ports
55
+ ↓
56
+ domain
57
+ ```
58
+
59
+ Infrastructure implements application-defined outbound contracts.
60
+
61
+ ---
62
+
63
+ # 3. Architecture Goals
64
+
65
+ The generated project MUST aim for:
66
+
67
+ * Clear separation of concerns
68
+ * Dependency inversion
69
+ * Domain independence
70
+ * Testability
71
+ * Replaceable infrastructure
72
+ * Explicit use cases
73
+ * Explicit external boundaries
74
+ * Consistent package organization
75
+ * Predictable code generation
76
+ * Maintainable project structure
77
+
78
+ The folder structure is an architectural contract and MUST NOT be treated merely as a naming convention.
79
+
80
+ ---
81
+
82
+ # 4. Standard Project Structure
83
+
84
+ Every project using this architecture SHOULD start with the following structure:
85
+
86
+ ```text
87
+ <project-root>/
88
+ │
89
+ ├── src/
90
+ │ ├── main/
91
+ │ │ ├── java/
92
+ │ │ │ └── <base-package>/
93
+ │ │ │ │
94
+ │ │ │ ├── adapter/
95
+ │ │ │ │
96
+ │ │ │ ├── application/
97
+ │ │ │ │
98
+ │ │ │ ├── domain/
99
+ │ │ │ │
100
+ │ │ │ ├── infrastructure/
101
+ │ │ │ │
102
+ │ │ │ └── Application.java
103
+ │ │ │
104
+ │ │ └── resources/
105
+ │ │
106
+ │ └── test/
107
+ │ └── java/
108
+ │ └── <base-package>/
109
+ │
110
+ ├── pom.xml
111
+ └── README.md
112
+ ```
113
+
114
+ The exact build tool MAY differ.
115
+
116
+ For Maven:
117
+
118
+ ```text
119
+ pom.xml
120
+ ```
121
+
122
+ For Gradle:
123
+
124
+ ```text
125
+ build.gradle
126
+ ```
127
+
128
+ or:
129
+
130
+ ```text
131
+ build.gradle.kts
132
+ ```
133
+
134
+ The architectural package structure MUST remain independent of the build tool.
135
+
136
+ ---
137
+
138
+ # 5. Base Package
139
+
140
+ All application code MUST reside below a single root Java package.
141
+
142
+ Example:
143
+
144
+ ```text
145
+ com.company.application
146
+ ```
147
+
148
+ or:
149
+
150
+ ```text
151
+ io.appweaver
152
+ ```
153
+
154
+ The base package MUST be determined by the project specification or foundation configuration.
155
+
156
+ The architecture document MUST NOT hard-code a specific organization or application package.
157
+
158
+ Example:
159
+
160
+ ```text
161
+ <base-package>/
162
+ ├── adapter/
163
+ ├── application/
164
+ ├── domain/
165
+ ├── infrastructure/
166
+ └── Application.java
167
+ ```
168
+
169
+ ---
170
+
171
+ # 6. Top-Level Architectural Packages
172
+
173
+ The standard top-level structure is:
174
+
175
+ ```text
176
+ <base-package>/
177
+ ├── adapter/
178
+ ├── application/
179
+ ├── domain/
180
+ ├── infrastructure/
181
+ └── Application.java
182
+ ```
183
+
184
+ Each package has a distinct responsibility.
185
+
186
+ | Package | Responsibility |
187
+ | ------------------ | --------------------------------------- |
188
+ | `adapter` | External entry and exit mechanisms |
189
+ | `application` | Use cases and application orchestration |
190
+ | `domain` | Business model and business rules |
191
+ | `infrastructure` | Technology-specific implementations |
192
+ | `Application.java` | Application bootstrap |
193
+
194
+ ---
195
+
196
+ # 7. Adapter Layer
197
+
198
+ ## Location
199
+
200
+ ```text
201
+ adapter/
202
+ ```
203
+
204
+ The adapter layer contains implementations that connect the application to external interfaces.
205
+
206
+ The adapter layer MAY contain:
207
+
208
+ ```text
209
+ adapter/
210
+ ├── in/
211
+ └── out/
212
+ ```
213
+
214
+ ---
215
+
216
+ # 8. Inbound Adapters
217
+
218
+ Inbound adapters represent external systems calling the application.
219
+
220
+ Standard structure:
221
+
222
+ ```text
223
+ adapter/
224
+ └── in/
225
+ ├── controller/
226
+ ├── messaging/
227
+ └── ...
228
+ ```
229
+
230
+ Only required adapter types SHOULD be created.
231
+
232
+ For a REST application:
233
+
234
+ ```text
235
+ adapter/
236
+ └── in/
237
+ └── controller/
238
+ ```
239
+
240
+ Example:
241
+
242
+ ```text
243
+ adapter/
244
+ └── in/
245
+ └── controller/
246
+ └── <Feature>Controller.java
247
+ ```
248
+
249
+ Examples of other inbound adapters:
250
+
251
+ ```text
252
+ adapter/in/
253
+ ├── controller/
254
+ ├── messaging/
255
+ ├── scheduler/
256
+ └── cli/
257
+ ```
258
+
259
+ These are optional and MUST only be created when required by the project.
260
+
261
+ ---
262
+
263
+ # 9. Inbound Adapter Responsibilities
264
+
265
+ Inbound adapters MUST:
266
+
267
+ * Receive external input.
268
+ * Translate external input into application contracts.
269
+ * Invoke inbound application ports.
270
+ * Translate application results into external responses.
271
+ * Handle transport-specific concerns.
272
+
273
+ Inbound adapters MUST NOT:
274
+
275
+ * Contain domain business rules.
276
+ * Access repositories directly.
277
+ * Access JPA repositories directly.
278
+ * Access persistence entities directly.
279
+ * Implement application use cases.
280
+ * Implement domain behavior.
281
+
282
+ The dependency direction MUST be:
283
+
284
+ ```text
285
+ Inbound Adapter
286
+ ↓
287
+ Inbound Application Port
288
+ ```
289
+
290
+ ---
291
+
292
+ # 10. Outbound Adapters
293
+
294
+ Outbound adapters represent external systems used by the application.
295
+
296
+ Standard structure:
297
+
298
+ ```text
299
+ adapter/
300
+ └── out/
301
+ ```
302
+
303
+ Possible examples:
304
+
305
+ ```text
306
+ adapter/out/
307
+ ├── external/
308
+ ├── messaging/
309
+ ├── notification/
310
+ └── ...
311
+ ```
312
+
313
+ Outbound adapters are optional.
314
+
315
+ They SHOULD be created only when the application communicates with external systems.
316
+
317
+ Examples:
318
+
319
+ * REST clients
320
+ * External APIs
321
+ * Message brokers
322
+ * Email providers
323
+ * Payment gateways
324
+ * File storage
325
+ * Third-party services
326
+
327
+ ---
328
+
329
+ # 11. Application Layer
330
+
331
+ Location:
332
+
333
+ ```text
334
+ application/
335
+ ```
336
+
337
+ The application layer defines and orchestrates application use cases.
338
+
339
+ Default structure:
340
+
341
+ ```text
342
+ application/
343
+ ├── dto/
344
+ │ ├── request/
345
+ │ └── response/
346
+ │
347
+ ├── port/
348
+ │ ├── in/
349
+ │ └── out/
350
+ │
351
+ └── service/
352
+ ```
353
+
354
+ Optional packages MAY be added when required by the project.
355
+
356
+ ---
357
+
358
+ # 12. Application DTOs
359
+
360
+ ## Request DTOs
361
+
362
+ Location:
363
+
364
+ ```text
365
+ application/dto/request/
366
+ ```
367
+
368
+ Request DTOs represent data entering an application use case.
369
+
370
+ Example:
371
+
372
+ ```text
373
+ <CreateFeature>RequestDto.java
374
+ ```
375
+
376
+ Rules:
377
+
378
+ * DTOs MUST represent application contracts.
379
+ * DTOs MUST NOT contain domain business logic.
380
+ * DTOs MUST NOT depend on persistence entities.
381
+ * DTOs SHOULD remain independent of transport-specific models where practical.
382
+
383
+ ---
384
+
385
+ ## Response DTOs
386
+
387
+ Location:
388
+
389
+ ```text
390
+ application/dto/response/
391
+ ```
392
+
393
+ Response DTOs represent application results.
394
+
395
+ Example:
396
+
397
+ ```text
398
+ <CreateFeature>ResponseDto.java
399
+ ```
400
+
401
+ The exact DTO naming convention MAY be adapted to project conventions.
402
+
403
+ ---
404
+
405
+ # 13. Inbound Application Ports
406
+
407
+ Location:
408
+
409
+ ```text
410
+ application/port/in/
411
+ ```
412
+
413
+ Inbound ports define application use cases.
414
+
415
+ Example:
416
+
417
+ ```text
418
+ application/
419
+ └── port/
420
+ └── in/
421
+ └── <Feature>UseCase.java
422
+ ```
423
+
424
+ Inbound ports MUST:
425
+
426
+ * Define application capabilities.
427
+ * Represent use cases.
428
+ * Be independent of controllers.
429
+ * Be independent of HTTP.
430
+ * Be independent of persistence.
431
+ * Be implemented by application services.
432
+
433
+ Example conceptual relationship:
434
+
435
+ ```text
436
+ Controller
437
+ ↓
438
+ <Feature>UseCase
439
+ ↓
440
+ <Feature>UseCaseImpl
441
+ ```
442
+
443
+ ---
444
+
445
+ # 14. Outbound Application Ports
446
+
447
+ Location:
448
+
449
+ ```text
450
+ application/port/out/
451
+ ```
452
+
453
+ Outbound ports define dependencies required by the application.
454
+
455
+ Examples:
456
+
457
+ ```text
458
+ application/port/out/
459
+ ├── <Domain>Repository.java
460
+ ├── <ExternalService>Port.java
461
+ └── ...
462
+ ```
463
+
464
+ Outbound ports MUST define contracts rather than technical implementations.
465
+
466
+ For example:
467
+
468
+ ```text
469
+ Application
470
+ ↓
471
+ Repository Port
472
+ ```
473
+
474
+ rather than:
475
+
476
+ ```text
477
+ Application
478
+ ↓
479
+ JpaRepository
480
+ ```
481
+
482
+ The application layer MUST depend on the abstraction.
483
+
484
+ ---
485
+
486
+ # 15. Application Services
487
+
488
+ Location:
489
+
490
+ ```text
491
+ application/service/
492
+ ```
493
+
494
+ Application services implement inbound use cases.
495
+
496
+ Example:
497
+
498
+ ```text
499
+ application/service/
500
+ └── <Feature>UseCaseImpl.java
501
+ ```
502
+
503
+ Application services SHOULD:
504
+
505
+ * Implement inbound ports.
506
+ * Coordinate application operations.
507
+ * Invoke domain behavior.
508
+ * Invoke outbound ports.
509
+ * Manage application-level transactions where appropriate.
510
+ * Coordinate multiple domain objects when required.
511
+
512
+ Application services MUST NOT:
513
+
514
+ * Depend directly on controllers.
515
+ * Depend directly on `JpaRepository`.
516
+ * Contain HTTP concerns.
517
+ * Contain database implementation details.
518
+ * Replace domain behavior with procedural business logic when the behavior belongs to the domain.
519
+
520
+ ---
521
+
522
+ # 16. Domain Layer
523
+
524
+ Location:
525
+
526
+ ```text
527
+ domain/
528
+ ```
529
+
530
+ The domain layer represents the business model.
531
+
532
+ Default structure:
533
+
534
+ ```text
535
+ domain/
536
+ ├── entity/
537
+ ├── enums/
538
+ ├── exception/
539
+ └── valueObjects/
540
+ ```
541
+
542
+ Additional domain packages MAY be introduced when required.
543
+
544
+ Possible optional packages:
545
+
546
+ ```text
547
+ domain/
548
+ ├── entity/
549
+ ├── valueObjects/
550
+ ├── enums/
551
+ ├── exception/
552
+ ├── service/
553
+ ├── event/
554
+ ├── repository/
555
+ └── ...
556
+ ```
557
+
558
+ Only packages required by the project SHOULD be generated.
559
+
560
+ ---
561
+
562
+ # 17. Domain Entities
563
+
564
+ Location:
565
+
566
+ ```text
567
+ domain/entity/
568
+ ```
569
+
570
+ Domain entities represent business concepts with identity and behavior.
571
+
572
+ Example:
573
+
574
+ ```text
575
+ <DomainEntity>.java
576
+ ```
577
+
578
+ Domain entities SHOULD:
579
+
580
+ * Encapsulate business state.
581
+ * Protect invariants.
582
+ * Expose meaningful domain behavior.
583
+ * Avoid exposing unrestricted mutable state.
584
+ * Remain independent of infrastructure technology.
585
+
586
+ Domain entities MUST NOT depend on:
587
+
588
+ ```text
589
+ Spring MVC
590
+ Spring Data
591
+ JpaRepository
592
+ Hibernate
593
+ REST
594
+ Controllers
595
+ Infrastructure adapters
596
+ External API clients
597
+ ```
598
+
599
+ ---
600
+
601
+ # 18. Value Objects
602
+
603
+ Location:
604
+
605
+ ```text
606
+ domain/valueObjects/
607
+ ```
608
+
609
+ Value objects represent domain concepts defined by their values rather than identity.
610
+
611
+ Examples of conceptual value objects:
612
+
613
+ ```text
614
+ Identifier
615
+ Money
616
+ EmailAddress
617
+ Quantity
618
+ Code
619
+ Address
620
+ ```
621
+
622
+ The actual value objects MUST be derived from the project domain specification.
623
+
624
+ Value objects SHOULD:
625
+
626
+ * Be immutable.
627
+ * Validate their invariants.
628
+ * Encapsulate domain-specific behavior.
629
+ * Avoid infrastructure dependencies.
630
+
631
+ ---
632
+
633
+ # 19. Domain Enums
634
+
635
+ Location:
636
+
637
+ ```text
638
+ domain/enums/
639
+ ```
640
+
641
+ Enums SHOULD be used for stable domain classifications.
642
+
643
+ Examples:
644
+
645
+ ```text
646
+ Status
647
+ Type
648
+ Category
649
+ State
650
+ ```
651
+
652
+ Enums MUST represent meaningful domain concepts rather than technical implementation states.
653
+
654
+ ---
655
+
656
+ # 20. Domain Exceptions
657
+
658
+ Location:
659
+
660
+ ```text
661
+ domain/exception/
662
+ ```
663
+
664
+ Domain exceptions represent meaningful business failures.
665
+
666
+ Examples:
667
+
668
+ ```text
669
+ <DomainRule>ViolationException.java
670
+ <DomainEntity>NotFoundException.java
671
+ <InvalidDomainState>Exception.java
672
+ ```
673
+
674
+ Exception names MUST be derived from actual domain rules.
675
+
676
+ ---
677
+
678
+ # 21. Domain Services
679
+
680
+ Location:
681
+
682
+ ```text
683
+ domain/service/
684
+ ```
685
+
686
+ This package is OPTIONAL.
687
+
688
+ A domain service SHOULD be introduced only when a business operation:
689
+
690
+ * Does not naturally belong to a single entity or value object.
691
+ * Represents domain behavior.
692
+ * Requires multiple domain concepts.
693
+
694
+ Domain services MUST NOT be used merely to move arbitrary business logic out of entities.
695
+
696
+ ---
697
+
698
+ # 22. Domain Events
699
+
700
+ Location:
701
+
702
+ ```text
703
+ domain/event/
704
+ ```
705
+
706
+ This package is OPTIONAL.
707
+
708
+ It SHOULD only be generated when the project requires domain events.
709
+
710
+ Example:
711
+
712
+ ```text
713
+ <BusinessEvent>.java
714
+ ```
715
+
716
+ Domain events MUST represent business-significant occurrences rather than infrastructure events.
717
+
718
+ ---
719
+
720
+ # 23. Infrastructure Layer
721
+
722
+ Location:
723
+
724
+ ```text
725
+ infrastructure/
726
+ ```
727
+
728
+ Infrastructure contains technology-specific implementations.
729
+
730
+ Default structure:
731
+
732
+ ```text
733
+ infrastructure/
734
+ ├── config/
735
+ └── persistence/
736
+ ```
737
+
738
+ Additional infrastructure packages MAY be created when required.
739
+
740
+ Possible structure:
741
+
742
+ ```text
743
+ infrastructure/
744
+ ├── config/
745
+ ├── persistence/
746
+ ├── security/
747
+ ├── messaging/
748
+ ├── external/
749
+ └── ...
750
+ ```
751
+
752
+ Only required infrastructure components SHOULD be generated.
753
+
754
+ ---
755
+
756
+ # 24. Infrastructure Configuration
757
+
758
+ Location:
759
+
760
+ ```text
761
+ infrastructure/config/
762
+ ```
763
+
764
+ Configuration classes MAY include:
765
+
766
+ * Framework configuration
767
+ * Security configuration
768
+ * Serialization configuration
769
+ * Database configuration
770
+ * Messaging configuration
771
+ * Integration configuration
772
+
773
+ Example:
774
+
775
+ ```text
776
+ SecurityConfig.java
777
+ PersistenceConfig.java
778
+ ```
779
+
780
+ Configuration MUST remain outside the domain.
781
+
782
+ ---
783
+
784
+ # 25. Persistence Structure
785
+
786
+ When relational persistence using JPA is required, the default structure is:
787
+
788
+ ```text
789
+ infrastructure/
790
+ └── persistence/
791
+ ├── mapper/
792
+ ├── <Entity>JpaEntity.java
793
+ ├── Jpa<Entity>Repository.java
794
+ └── <Entity>RepositoryImpl.java
795
+ ```
796
+
797
+ Persistence is OPTIONAL.
798
+
799
+ Projects that do not require persistence MUST NOT generate persistence packages merely because they exist in the baseline architecture.
800
+
801
+ ---
802
+
803
+ # 26. JPA Entities
804
+
805
+ Location:
806
+
807
+ ```text
808
+ infrastructure/persistence/
809
+ ```
810
+
811
+ JPA entities represent the persistence model.
812
+
813
+ Example:
814
+
815
+ ```text
816
+ <Entity>JpaEntity.java
817
+ ```
818
+
819
+ JPA entities MUST remain separate from domain entities.
820
+
821
+ The architecture MUST NOT assume:
822
+
823
+ ```text
824
+ Domain Entity == JPA Entity
825
+ ```
826
+
827
+ Instead:
828
+
829
+ ```text
830
+ Domain Entity
831
+ ↕
832
+ Persistence Mapper
833
+ ↕
834
+ JPA Entity
835
+ ```
836
+
837
+ ---
838
+
839
+ # 27. Spring Data Repositories
840
+
841
+ When Spring Data JPA is used:
842
+
843
+ ```text
844
+ infrastructure/persistence/
845
+ └── Jpa<Entity>Repository.java
846
+ ```
847
+
848
+ Example conceptual structure:
849
+
850
+ ```text
851
+ application/port/out/
852
+ └── EntityRepository.java
853
+
854
+ infrastructure/persistence/
855
+ └── JpaEntityRepository.java
856
+ ```
857
+
858
+ The application MUST depend on:
859
+
860
+ ```text
861
+ EntityRepository
862
+ ```
863
+
864
+ and MUST NOT directly depend on:
865
+
866
+ ```text
867
+ JpaEntityRepository
868
+ ```
869
+
870
+ ---
871
+
872
+ # 28. Repository Implementations
873
+
874
+ Repository implementations adapt infrastructure persistence to the application port.
875
+
876
+ Example:
877
+
878
+ ```text
879
+ infrastructure/persistence/
880
+ └── EntityRepositoryImpl.java
881
+ ```
882
+
883
+ Relationship:
884
+
885
+ ```text
886
+ application/port/out/EntityRepository
887
+ ▲
888
+ │ implements
889
+ │
890
+ infrastructure/persistence/EntityRepositoryImpl
891
+ │
892
+ ▼
893
+ JpaEntityRepository
894
+ ```
895
+
896
+ This preserves dependency inversion.
897
+
898
+ ---
899
+
900
+ # 29. Persistence Mappers
901
+
902
+ Location:
903
+
904
+ ```text
905
+ infrastructure/persistence/mapper/
906
+ ```
907
+
908
+ Mappers convert between domain and persistence representations.
909
+
910
+ Example:
911
+
912
+ ```text
913
+ <Entity>Mapper.java
914
+ ```
915
+
916
+ Conceptual flow:
917
+
918
+ ```text
919
+ Domain Entity
920
+ ↓
921
+ Persistence Mapper
922
+ ↓
923
+ JPA Entity
924
+ ```
925
+
926
+ and:
927
+
928
+ ```text
929
+ JPA Entity
930
+ ↓
931
+ Persistence Mapper
932
+ ↓
933
+ Domain Entity
934
+ ```
935
+
936
+ Persistence mapping MUST NOT be embedded into domain entities.
937
+
938
+ ---
939
+
940
+ # 30. Application Bootstrap
941
+
942
+ The Spring Boot application entry point SHOULD be located at the root package.
943
+
944
+ Example:
945
+
946
+ ```text
947
+ <base-package>/Application.java
948
+ ```
949
+
950
+ The application bootstrap class MUST remain outside individual domain or feature packages.
951
+
952
+ ---
953
+
954
+ # 31. Resources Structure
955
+
956
+ The standard resource structure is:
957
+
958
+ ```text
959
+ src/main/resources/
960
+ ├── application.yml
961
+ └── ...
962
+ ```
963
+
964
+ Additional directories MAY be introduced based on project requirements.
965
+
966
+ Examples:
967
+
968
+ ```text
969
+ src/main/resources/
970
+ ├── application.yml
971
+ ├── db/
972
+ │ └── migration/
973
+ ├── templates/
974
+ └── ...
975
+ ```
976
+
977
+ Only required resources SHOULD be generated.
978
+
979
+ ---
980
+
981
+ # 32. Test Structure
982
+
983
+ Tests SHOULD mirror the production architecture.
984
+
985
+ ```text
986
+ src/test/java/<base-package>/
987
+ ├── adapter/
988
+ ├── application/
989
+ ├── domain/
990
+ └── infrastructure/
991
+ ```
992
+
993
+ Example:
994
+
995
+ ```text
996
+ src/test/java/<base-package>/
997
+ │
998
+ ├── adapter/
999
+ │ └── in/
1000
+ │ └── controller/
1001
+ │
1002
+ ├── application/
1003
+ │ └── service/
1004
+ │
1005
+ ├── domain/
1006
+ │ ├── entity/
1007
+ │ └── valueObjects/
1008
+ │
1009
+ └── infrastructure/
1010
+ └── persistence/
1011
+ ```
1012
+
1013
+ Tests MUST be organized according to the responsibility being tested.
1014
+
1015
+ ---
1016
+
1017
+ # 33. Dependency Rules
1018
+
1019
+ The following dependency rules are mandatory.
1020
+
1021
+ ## Allowed
1022
+
1023
+ ```text
1024
+ Adapter → Application
1025
+ Application → Domain
1026
+ Infrastructure → Application
1027
+ Infrastructure → Domain
1028
+ ```
1029
+
1030
+ ## Forbidden
1031
+
1032
+ ```text
1033
+ Domain → Infrastructure
1034
+ Domain → Adapter
1035
+ Domain → Spring
1036
+ Domain → JPA
1037
+
1038
+ Application → Controller
1039
+ Application → JpaRepository
1040
+ Application → JPA Entity
1041
+
1042
+ Controller → JpaRepository
1043
+ Controller → JPA Entity
1044
+ ```
1045
+
1046
+ The domain MUST remain at the center of the architecture.
1047
+
1048
+ ---
1049
+
1050
+ # 34. Dependency Direction
1051
+
1052
+ The target dependency model is:
1053
+
1054
+ ```text
1055
+ ┌───────────────────┐
1056
+ │ Inbound Adapter │
1057
+ └─────────┬─────────┘
1058
+ │
1059
+ ▼
1060
+ ┌───────────────────┐
1061
+ │ Application │
1062
+ │ │
1063
+ │ Inbound Ports │
1064
+ │ Use Cases │
1065
+ │ Outbound Ports │
1066
+ └─────────┬─────────┘
1067
+ │
1068
+ ▼
1069
+ ┌───────────────────┐
1070
+ │ Domain │
1071
+ │ │
1072
+ │ Entities │
1073
+ │ Value Objects │
1074
+ │ Domain Services │
1075
+ │ Domain Events │
1076
+ └───────────────────┘
1077
+ ▲
1078
+ │
1079
+ ┌─────────┴─────────┐
1080
+ │ Infrastructure │
1081
+ │ │
1082
+ │ Persistence │
1083
+ │ External Systems │
1084
+ │ Configuration │
1085
+ └───────────────────┘
1086
+ ```
1087
+
1088
+ ---
1089
+
1090
+ # 35. Feature Generation Rules
1091
+
1092
+ When implementing a feature from a specification, the generator MUST determine which architectural artifacts are required.
1093
+
1094
+ For a generic use case:
1095
+
1096
+ ```text
1097
+ <Feature>
1098
+ ```
1099
+
1100
+ the generator MAY create:
1101
+
1102
+ ```text
1103
+ adapter/in/controller/
1104
+ └── <Feature>Controller.java
1105
+
1106
+ application/dto/request/
1107
+ └── <Feature>RequestDto.java
1108
+
1109
+ application/dto/response/
1110
+ └── <Feature>ResponseDto.java
1111
+
1112
+ application/port/in/
1113
+ └── <Feature>UseCase.java
1114
+
1115
+ application/port/out/
1116
+ └── <RequiredDependency>Port.java
1117
+
1118
+ application/service/
1119
+ └── <Feature>UseCaseImpl.java
1120
+
1121
+ domain/entity/
1122
+ └── <RequiredDomainEntity>.java
1123
+
1124
+ domain/valueObjects/
1125
+ └── <RequiredValueObject>.java
1126
+
1127
+ infrastructure/persistence/
1128
+ ├── <RequiredEntity>JpaEntity.java
1129
+ ├── Jpa<RequiredEntity>Repository.java
1130
+ ├── <RequiredEntity>RepositoryImpl.java
1131
+ └── mapper/
1132
+ └── <RequiredEntity>Mapper.java
1133
+ ```
1134
+
1135
+ The generator MUST NOT create every possible artifact automatically.
1136
+
1137
+ Artifacts MUST be generated based on the requirements and design.
1138
+
1139
+ ---
1140
+
1141
+ # 36. No Empty Architectural Packages
1142
+
1143
+ The generator SHOULD NOT create unnecessary empty packages.
1144
+
1145
+ For example, if a project does not require messaging:
1146
+
1147
+ ```text
1148
+ adapter/in/messaging/
1149
+ ```
1150
+
1151
+ SHOULD NOT be created.
1152
+
1153
+ If a project does not require JPA:
1154
+
1155
+ ```text
1156
+ infrastructure/persistence/
1157
+ ```
1158
+
1159
+ SHOULD NOT be created.
1160
+
1161
+ The architecture defines available extension points, not mandatory empty directories.
1162
+
1163
+ ---
1164
+
1165
+ # 37. Naming Rules
1166
+
1167
+ Generated Java types MUST follow standard Java naming conventions.
1168
+
1169
+ Examples:
1170
+
1171
+ ```text
1172
+ <ClassName>.java
1173
+ <Feature>Controller.java
1174
+ <Feature>UseCase.java
1175
+ <Feature>UseCaseImpl.java
1176
+ <Entity>JpaEntity.java
1177
+ <Entity>Repository.java
1178
+ <Entity>RepositoryImpl.java
1179
+ <Entity>Mapper.java
1180
+ ```
1181
+
1182
+ Class names MUST be derived from the project specification.
1183
+
1184
+ Domain-specific names MUST NOT be hard-coded in this architecture document.
1185
+
1186
+ ---
1187
+
1188
+ # 38. Domain Independence
1189
+
1190
+ The domain MUST NOT require Spring Boot to execute its core business behavior.
1191
+
1192
+ The preferred dependency model is:
1193
+
1194
+ ```text
1195
+ Domain
1196
+ ↓
1197
+ Java / Standard Library
1198
+ ```
1199
+
1200
+ rather than:
1201
+
1202
+ ```text
1203
+ Domain
1204
+ ↓
1205
+ Spring Boot
1206
+ ↓
1207
+ Hibernate
1208
+ ↓
1209
+ Database
1210
+ ```
1211
+
1212
+ Framework dependencies MAY be introduced into the domain only when explicitly justified by the project architecture and constitution.
1213
+
1214
+ ---
1215
+
1216
+ # 39. Infrastructure Independence from Application Details
1217
+
1218
+ Infrastructure implementations MUST depend on application-defined contracts wherever an external dependency is required.
1219
+
1220
+ Preferred:
1221
+
1222
+ ```text
1223
+ Application Port
1224
+ ▲
1225
+ │ implements
1226
+ │
1227
+ Infrastructure Adapter
1228
+ ```
1229
+
1230
+ Not:
1231
+
1232
+ ```text
1233
+ Application Service
1234
+ ↓
1235
+ Concrete Infrastructure Class
1236
+ ```
1237
+
1238
+ This allows infrastructure implementations to be replaced without changing application use cases.
1239
+
1240
+ ---
1241
+
1242
+ # 40. Architecture Extension Rules
1243
+
1244
+ The standard structure MAY be extended when a project requires additional technical capabilities.
1245
+
1246
+ Examples:
1247
+
1248
+ ```text
1249
+ infrastructure/
1250
+ ├── security/
1251
+ ├── messaging/
1252
+ ├── external/
1253
+ └── storage/
1254
+ ```
1255
+
1256
+ or:
1257
+
1258
+ ```text
1259
+ adapter/
1260
+ ├── in/
1261
+ │ ├── controller/
1262
+ │ ├── messaging/
1263
+ │ └── scheduler/
1264
+ │
1265
+ └── out/
1266
+ ├── messaging/
1267
+ └── external/
1268
+ ```
1269
+
1270
+ Extensions MUST:
1271
+
1272
+ 1. Have a clear architectural responsibility.
1273
+ 2. Preserve dependency direction.
1274
+ 3. Not bypass application ports.
1275
+ 4. Not introduce infrastructure dependencies into the domain.
1276
+ 5. Be documented when they introduce a new architectural boundary.
1277
+
1278
+ ---
1279
+
1280
+ # 41. Project-Specific Architecture Overrides
1281
+
1282
+ This document defines the **default Java architecture**.
1283
+
1284
+ A project MAY define additional architectural requirements.
1285
+
1286
+ Project-specific requirements MUST NOT silently violate the baseline architecture.
1287
+
1288
+ If an override is required, it SHOULD explicitly document:
1289
+
1290
+ ```text
1291
+ Override:
1292
+ Reason:
1293
+ Affected Layer:
1294
+ New Dependency:
1295
+ Architectural Impact:
1296
+ ```
1297
+
1298
+ The project specification takes precedence for legitimate project-specific requirements while preserving the core architectural principles.
1299
+
1300
+ ---
1301
+
1302
+ # 42. Generation Decision Rules
1303
+
1304
+ The AW-Spec implementation process SHOULD use the following decision process.
1305
+
1306
+ ```text
1307
+ Requirement
1308
+ │
1309
+ ▼
1310
+ Does it represent a business concept?
1311
+ │
1312
+ ├── Yes → Domain
1313
+ │
1314
+ └── No
1315
+ │
1316
+ ▼
1317
+ Does it represent a use case?
1318
+ │
1319
+ ├── Yes → Application
1320
+ │
1321
+ └── No
1322
+ │
1323
+ ▼
1324
+ Does it expose the application externally?
1325
+ │
1326
+ ├── Yes → Inbound Adapter
1327
+ │
1328
+ └── No
1329
+ │
1330
+ ▼
1331
+ Does it communicate with an external system?
1332
+ │
1333
+ ├── Yes → Outbound Port + Adapter
1334
+ │
1335
+ └── No
1336
+ │
1337
+ ▼
1338
+ Does it implement a technical mechanism?
1339
+ │
1340
+ └── Yes → Infrastructure
1341
+ ```
1342
+
1343
+ ---
1344
+
1345
+ # 43. Standard Artifact Mapping
1346
+
1347
+ | Requirement Artifact | Default Location |
1348
+ | ----------------------------- | ---------------------------------------------------- |
1349
+ | REST Controller | `adapter/in/controller` |
1350
+ | Messaging Consumer | `adapter/in/messaging` |
1351
+ | Scheduler Entry Point | `adapter/in/scheduler` |
1352
+ | External API Adapter | `adapter/out/external` |
1353
+ | Request DTO | `application/dto/request` |
1354
+ | Response DTO | `application/dto/response` |
1355
+ | Inbound Use Case | `application/port/in` |
1356
+ | Outbound Port | `application/port/out` |
1357
+ | Use Case Implementation | `application/service` |
1358
+ | Domain Entity | `domain/entity` |
1359
+ | Value Object | `domain/valueObjects` |
1360
+ | Domain Enum | `domain/enums` |
1361
+ | Domain Exception | `domain/exception` |
1362
+ | Domain Service | `domain/service` |
1363
+ | Domain Event | `domain/event` |
1364
+ | JPA Entity | `infrastructure/persistence` |
1365
+ | Spring Data Repository | `infrastructure/persistence` |
1366
+ | Repository Implementation | `infrastructure/persistence` |
1367
+ | Persistence Mapper | `infrastructure/persistence/mapper` |
1368
+ | Security Configuration | `infrastructure/config` or `infrastructure/security` |
1369
+ | Database Configuration | `infrastructure/config` |
1370
+ | External Client Configuration | `infrastructure/config` |
1371
+ | Application Bootstrap | `<base-package>/Application.java` |
1372
+
1373
+ ---
1374
+
1375
+ # 44. Reusability Requirement
1376
+
1377
+ This document MUST remain domain-neutral.
1378
+
1379
+ It MUST NOT contain:
1380
+
1381
+ * Specific business entities
1382
+ * Specific business terminology
1383
+ * Specific API endpoints
1384
+ * Specific database tables
1385
+ * Specific use cases
1386
+ * Specific customer requirements
1387
+ * Specific domain validations
1388
+ * Specific project names
1389
+
1390
+ The following are examples of information that belong elsewhere:
1391
+
1392
+ ```text
1393
+ Flight
1394
+ Booking
1395
+ Library
1396
+ Book
1397
+ Employee
1398
+ Project
1399
+ Patient
1400
+ Account
1401
+ Order
1402
+ Payment
1403
+ ```
1404
+
1405
+ Those concepts MUST come from the project's domain specification.
1406
+
1407
+ ---
1408
+
1409
+ # 45. Relationship With AW-Spec
1410
+
1411
+ This document acts as the **Java architecture/folder-structure baseline** for AW-Spec.
1412
+
1413
+ The intended relationship is:
1414
+
1415
+ ```text
1416
+ Java Architecture Standard
1417
+ │
1418
+ ▼
1419
+ Project Foundation
1420
+ │
1421
+ ▼
1422
+ Project Constitution
1423
+ │
1424
+ ▼
1425
+ Domain Requirements
1426
+ │
1427
+ ▼
1428
+ Application Design
1429
+ │
1430
+ ▼
1431
+ Implementation
1432
+ ```
1433
+
1434
+ The architecture standard determines:
1435
+
1436
+ * Where generated code belongs.
1437
+ * Which layers exist.
1438
+ * Which dependencies are allowed.
1439
+ * Which technical concerns belong to infrastructure.
1440
+ * How application ports and adapters are organized.
1441
+
1442
+ The project specification determines:
1443
+
1444
+ * What the application does.
1445
+ * Which domain entities exist.
1446
+ * Which use cases exist.
1447
+ * Which APIs exist.
1448
+ * Which external systems are required.
1449
+ * Which persistence mechanisms are required.
1450
+
1451
+ ---
1452
+
1453
+ # 46. Core Principle
1454
+
1455
+ The generator MUST follow this principle:
1456
+
1457
+ > **Architecture defines the structure; specifications define the behavior.**
1458
+
1459
+ Therefore:
1460
+
1461
+ ```text
1462
+ Architecture MD
1463
+ ↓
1464
+ Where does code belong?
1465
+
1466
+ Project Specification
1467
+ ↓
1468
+ What code is required?
1469
+
1470
+ Design
1471
+ ↓
1472
+ How should the behavior be implemented?
1473
+
1474
+ Implementation
1475
+ ↓
1476
+ Generate the code
1477
+ ```
1478
+
1479
+ The architecture document MUST provide the reusable structural contract without embedding business-specific implementation details.
1480
+
1481
+ ---
1482
+
1483
+ # 47. Final Standard Structure
1484
+
1485
+ The canonical Java project structure is therefore:
1486
+
1487
+ ```text
1488
+ <project-root>/
1489
+ │
1490
+ ├── src/
1491
+ │ ├── main/
1492
+ │ │ ├── java/
1493
+ │ │ │ └── <base-package>/
1494
+ │ │ │ │
1495
+ │ │ │ ├── adapter/
1496
+ │ │ │ │ ├── in/
1497
+ │ │ │ │ └── out/
1498
+ │ │ │ │
1499
+ │ │ │ ├── application/
1500
+ │ │ │ │ ├── dto/
1501
+ │ │ │ │ │ ├── request/
1502
+ │ │ │ │ │ └── response/
1503
+ │ │ │ │ ├── port/
1504
+ │ │ │ │ │ ├── in/
1505
+ │ │ │ │ │ └── out/
1506
+ │ │ │ │ └── service/
1507
+ │ │ │ │
1508
+ │ │ │ ├── domain/
1509
+ │ │ │ │ ├── entity/
1510
+ │ │ │ │ ├── valueObjects/
1511
+ │ │ │ │ ├── enums/
1512
+ │ │ │ │ ├── exception/
1513
+ │ │ │ │ ├── service/ # optional
1514
+ │ │ │ │ └── event/ # optional
1515
+ │ │ │ │
1516
+ │ │ │ ├── infrastructure/
1517
+ │ │ │ │ ├── config/
1518
+ │ │ │ │ ├── persistence/ # optional
1519
+ │ │ │ │ ├── security/ # optional
1520
+ │ │ │ │ ├── messaging/ # optional
1521
+ │ │ │ │ └── external/ # optional
1522
+ │ │ │ │
1523
+ │ │ │ └── Application.java
1524
+ │ │ │
1525
+ │ │ └── resources/
1526
+ │ │
1527
+ │ └── test/
1528
+ │ └── java/
1529
+ │ └── <base-package>/
1530
+ │
1531
+ ├── pom.xml / build.gradle / build.gradle.kts
1532
+ └── README.md
1533
+ ```
1534
+
1535
+ This structure is the **reusable Java Hexagonal Architecture baseline**.
1536
+
1537
+ Every upcoming Java project SHOULD reuse this architecture unless its project constitution explicitly defines a different architectural strategy.