maestro-bundle 1.3.1 → 1.4.0
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/package.json +1 -1
- package/templates/bundle-ai-agents/skills/agent-orchestration/SKILL.md +107 -41
- package/templates/bundle-ai-agents/skills/agent-orchestration/references/graph-patterns.md +50 -0
- package/templates/bundle-ai-agents/skills/agent-orchestration/references/routing-strategies.md +47 -0
- package/templates/bundle-ai-agents/skills/api-design/SKILL.md +125 -16
- package/templates/bundle-ai-agents/skills/api-design/references/pydantic-patterns.md +72 -0
- package/templates/bundle-ai-agents/skills/api-design/references/rest-conventions.md +51 -0
- package/templates/bundle-ai-agents/skills/clean-architecture/SKILL.md +113 -21
- package/templates/bundle-ai-agents/skills/clean-architecture/references/dependency-injection.md +60 -0
- package/templates/bundle-ai-agents/skills/clean-architecture/references/layer-rules.md +56 -0
- package/templates/bundle-ai-agents/skills/context-engineering/SKILL.md +104 -36
- package/templates/bundle-ai-agents/skills/context-engineering/references/compression-techniques.md +76 -0
- package/templates/bundle-ai-agents/skills/context-engineering/references/context-budget-calculator.md +45 -0
- package/templates/bundle-ai-agents/skills/database-modeling/SKILL.md +146 -19
- package/templates/bundle-ai-agents/skills/database-modeling/references/index-strategies.md +48 -0
- package/templates/bundle-ai-agents/skills/database-modeling/references/naming-conventions.md +27 -0
- package/templates/bundle-ai-agents/skills/docker-containerization/SKILL.md +124 -15
- package/templates/bundle-ai-agents/skills/docker-containerization/references/compose-patterns.md +97 -0
- package/templates/bundle-ai-agents/skills/docker-containerization/references/dockerfile-checklist.md +37 -0
- package/templates/bundle-ai-agents/skills/eval-testing/SKILL.md +113 -25
- package/templates/bundle-ai-agents/skills/eval-testing/references/eval-types.md +52 -0
- package/templates/bundle-ai-agents/skills/eval-testing/references/golden-dataset-template.md +59 -0
- package/templates/bundle-ai-agents/skills/memory-management/SKILL.md +112 -28
- package/templates/bundle-ai-agents/skills/memory-management/references/memory-tiers.md +41 -0
- package/templates/bundle-ai-agents/skills/memory-management/references/namespace-conventions.md +41 -0
- package/templates/bundle-ai-agents/skills/prompt-engineering/SKILL.md +139 -47
- package/templates/bundle-ai-agents/skills/prompt-engineering/references/anti-patterns.md +59 -0
- package/templates/bundle-ai-agents/skills/prompt-engineering/references/prompt-templates.md +75 -0
- package/templates/bundle-ai-agents/skills/rag-pipeline/SKILL.md +104 -27
- package/templates/bundle-ai-agents/skills/rag-pipeline/references/chunking-strategies.md +27 -0
- package/templates/bundle-ai-agents/skills/rag-pipeline/references/embedding-models.md +31 -0
- package/templates/bundle-ai-agents/skills/rag-pipeline/references/rag-evaluation.md +39 -0
- package/templates/bundle-ai-agents/skills/testing-strategy/SKILL.md +127 -18
- package/templates/bundle-ai-agents/skills/testing-strategy/references/fixture-patterns.md +81 -0
- package/templates/bundle-ai-agents/skills/testing-strategy/references/naming-conventions.md +69 -0
- package/templates/bundle-base/skills/branch-strategy/SKILL.md +134 -21
- package/templates/bundle-base/skills/branch-strategy/references/branch-rules.md +40 -0
- package/templates/bundle-base/skills/code-review/SKILL.md +123 -38
- package/templates/bundle-base/skills/code-review/references/review-checklist.md +45 -0
- package/templates/bundle-base/skills/commit-pattern/SKILL.md +98 -39
- package/templates/bundle-base/skills/commit-pattern/references/conventional-commits.md +40 -0
- package/templates/bundle-data-pipeline/skills/data-preprocessing/SKILL.md +110 -19
- package/templates/bundle-data-pipeline/skills/data-preprocessing/references/pandas-cheatsheet.md +63 -0
- package/templates/bundle-data-pipeline/skills/data-preprocessing/references/pandera-schemas.md +44 -0
- package/templates/bundle-data-pipeline/skills/docker-containerization/SKILL.md +132 -16
- package/templates/bundle-data-pipeline/skills/docker-containerization/references/compose-patterns.md +82 -0
- package/templates/bundle-data-pipeline/skills/docker-containerization/references/dockerfile-best-practices.md +57 -0
- package/templates/bundle-data-pipeline/skills/feature-engineering/SKILL.md +143 -45
- package/templates/bundle-data-pipeline/skills/feature-engineering/references/encoding-guide.md +41 -0
- package/templates/bundle-data-pipeline/skills/feature-engineering/references/scaling-guide.md +38 -0
- package/templates/bundle-data-pipeline/skills/mlops-pipeline/SKILL.md +156 -37
- package/templates/bundle-data-pipeline/skills/mlops-pipeline/references/mlflow-commands.md +69 -0
- package/templates/bundle-data-pipeline/skills/model-training/SKILL.md +152 -33
- package/templates/bundle-data-pipeline/skills/model-training/references/evaluation-metrics.md +52 -0
- package/templates/bundle-data-pipeline/skills/model-training/references/model-selection-guide.md +41 -0
- package/templates/bundle-data-pipeline/skills/rag-pipeline/SKILL.md +127 -39
- package/templates/bundle-data-pipeline/skills/rag-pipeline/references/chunking-strategies.md +51 -0
- package/templates/bundle-data-pipeline/skills/rag-pipeline/references/embedding-models.md +49 -0
- package/templates/bundle-frontend-spa/skills/authentication/SKILL.md +196 -13
- package/templates/bundle-frontend-spa/skills/authentication/references/jwt-security.md +41 -0
- package/templates/bundle-frontend-spa/skills/component-design/SKILL.md +191 -41
- package/templates/bundle-frontend-spa/skills/component-design/references/accessibility-checklist.md +41 -0
- package/templates/bundle-frontend-spa/skills/component-design/references/tailwind-patterns.md +65 -0
- package/templates/bundle-frontend-spa/skills/e2e-testing/SKILL.md +241 -79
- package/templates/bundle-frontend-spa/skills/e2e-testing/references/playwright-selectors.md +66 -0
- package/templates/bundle-frontend-spa/skills/e2e-testing/references/test-patterns.md +82 -0
- package/templates/bundle-frontend-spa/skills/integration-api/SKILL.md +221 -31
- package/templates/bundle-frontend-spa/skills/integration-api/references/api-patterns.md +81 -0
- package/templates/bundle-frontend-spa/skills/react-patterns/SKILL.md +195 -70
- package/templates/bundle-frontend-spa/skills/react-patterns/references/component-checklist.md +22 -0
- package/templates/bundle-frontend-spa/skills/react-patterns/references/hook-patterns.md +63 -0
- package/templates/bundle-frontend-spa/skills/responsive-layout/SKILL.md +162 -22
- package/templates/bundle-frontend-spa/skills/responsive-layout/references/breakpoint-guide.md +63 -0
- package/templates/bundle-frontend-spa/skills/state-management/SKILL.md +158 -30
- package/templates/bundle-frontend-spa/skills/state-management/references/react-query-config.md +64 -0
- package/templates/bundle-frontend-spa/skills/state-management/references/state-patterns.md +78 -0
- package/templates/bundle-jhipster-microservices/skills/ci-cd-pipeline/SKILL.md +135 -45
- package/templates/bundle-jhipster-microservices/skills/ci-cd-pipeline/references/gitlab-ci-templates.md +93 -0
- package/templates/bundle-jhipster-microservices/skills/clean-architecture/SKILL.md +87 -21
- package/templates/bundle-jhipster-microservices/skills/clean-architecture/references/layer-rules.md +78 -0
- package/templates/bundle-jhipster-microservices/skills/ddd-tactical/SKILL.md +94 -25
- package/templates/bundle-jhipster-microservices/skills/ddd-tactical/references/ddd-patterns.md +48 -0
- package/templates/bundle-jhipster-microservices/skills/jhipster-angular/SKILL.md +63 -21
- package/templates/bundle-jhipster-microservices/skills/jhipster-angular/references/angular-microservices.md +40 -0
- package/templates/bundle-jhipster-microservices/skills/jhipster-angular/references/angular-structure.md +59 -0
- package/templates/bundle-jhipster-microservices/skills/jhipster-docker-k8s/SKILL.md +125 -91
- package/templates/bundle-jhipster-microservices/skills/jhipster-docker-k8s/references/docker-k8s-commands.md +68 -0
- package/templates/bundle-jhipster-microservices/skills/jhipster-entities/SKILL.md +72 -20
- package/templates/bundle-jhipster-microservices/skills/jhipster-entities/references/cross-service-entities.md +36 -0
- package/templates/bundle-jhipster-microservices/skills/jhipster-entities/references/jdl-types.md +56 -0
- package/templates/bundle-jhipster-microservices/skills/jhipster-gateway/SKILL.md +80 -8
- package/templates/bundle-jhipster-microservices/skills/jhipster-gateway/references/gateway-config.md +43 -0
- package/templates/bundle-jhipster-microservices/skills/jhipster-kafka/SKILL.md +115 -22
- package/templates/bundle-jhipster-microservices/skills/jhipster-kafka/references/kafka-events.md +39 -0
- package/templates/bundle-jhipster-microservices/skills/jhipster-registry/SKILL.md +92 -23
- package/templates/bundle-jhipster-microservices/skills/jhipster-registry/references/consul-config.md +61 -0
- package/templates/bundle-jhipster-microservices/skills/jhipster-service/SKILL.md +81 -18
- package/templates/bundle-jhipster-microservices/skills/jhipster-service/references/service-patterns.md +40 -0
- package/templates/bundle-jhipster-microservices/skills/testing-strategy/SKILL.md +101 -20
- package/templates/bundle-jhipster-microservices/skills/testing-strategy/references/test-naming.md +55 -0
- package/templates/bundle-jhipster-monorepo/skills/clean-architecture/SKILL.md +87 -21
- package/templates/bundle-jhipster-monorepo/skills/clean-architecture/references/layer-rules.md +78 -0
- package/templates/bundle-jhipster-monorepo/skills/ddd-tactical/SKILL.md +94 -25
- package/templates/bundle-jhipster-monorepo/skills/ddd-tactical/references/ddd-patterns.md +48 -0
- package/templates/bundle-jhipster-monorepo/skills/jhipster-angular/SKILL.md +99 -52
- package/templates/bundle-jhipster-monorepo/skills/jhipster-angular/references/angular-structure.md +59 -0
- package/templates/bundle-jhipster-monorepo/skills/jhipster-entities/SKILL.md +89 -36
- package/templates/bundle-jhipster-monorepo/skills/jhipster-entities/references/jdl-types.md +56 -0
- package/templates/bundle-jhipster-monorepo/skills/jhipster-liquibase/SKILL.md +123 -23
- package/templates/bundle-jhipster-monorepo/skills/jhipster-liquibase/references/liquibase-operations.md +95 -0
- package/templates/bundle-jhipster-monorepo/skills/jhipster-security/SKILL.md +106 -19
- package/templates/bundle-jhipster-monorepo/skills/jhipster-security/references/security-checklist.md +47 -0
- package/templates/bundle-jhipster-monorepo/skills/jhipster-spring/SKILL.md +84 -16
- package/templates/bundle-jhipster-monorepo/skills/jhipster-spring/references/spring-layers.md +41 -0
- package/templates/bundle-jhipster-monorepo/skills/testing-strategy/SKILL.md +101 -20
- package/templates/bundle-jhipster-monorepo/skills/testing-strategy/references/test-naming.md +55 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# GitLab CI Templates Reference
|
|
2
|
+
|
|
3
|
+
## Pipeline Stages
|
|
4
|
+
```yaml
|
|
5
|
+
stages:
|
|
6
|
+
- lint
|
|
7
|
+
- test
|
|
8
|
+
- security
|
|
9
|
+
- build
|
|
10
|
+
- deploy-staging
|
|
11
|
+
- deploy-prod
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Java/Maven Lint Template
|
|
15
|
+
```yaml
|
|
16
|
+
.lint-java:
|
|
17
|
+
stage: lint
|
|
18
|
+
image: maven:3.9-eclipse-temurin-21
|
|
19
|
+
script:
|
|
20
|
+
- ./mvnw checkstyle:check -DskipTests
|
|
21
|
+
- ./mvnw pmd:check -DskipTests
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Java/Maven Test Template
|
|
25
|
+
```yaml
|
|
26
|
+
.test-java:
|
|
27
|
+
stage: test
|
|
28
|
+
image: maven:3.9-eclipse-temurin-21
|
|
29
|
+
services:
|
|
30
|
+
- postgres:16
|
|
31
|
+
variables:
|
|
32
|
+
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/testdb
|
|
33
|
+
script:
|
|
34
|
+
- ./mvnw verify -Pprod -DskipTests=false
|
|
35
|
+
artifacts:
|
|
36
|
+
reports:
|
|
37
|
+
junit: target/surefire-reports/*.xml
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Angular Test Template
|
|
41
|
+
```yaml
|
|
42
|
+
.test-angular:
|
|
43
|
+
stage: test
|
|
44
|
+
image: node:20-slim
|
|
45
|
+
script:
|
|
46
|
+
- npm ci
|
|
47
|
+
- npm run lint
|
|
48
|
+
- npm test -- --coverage
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Jib Build Template
|
|
52
|
+
```yaml
|
|
53
|
+
.build-jib:
|
|
54
|
+
stage: build
|
|
55
|
+
script:
|
|
56
|
+
- ./mvnw -ntp verify -DskipTests jib:build
|
|
57
|
+
-Djib.to.image=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
58
|
+
-Djib.to.auth.username=$CI_REGISTRY_USER
|
|
59
|
+
-Djib.to.auth.password=$CI_REGISTRY_PASSWORD
|
|
60
|
+
only:
|
|
61
|
+
- main
|
|
62
|
+
- develop
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## K8s Deploy Template
|
|
66
|
+
```yaml
|
|
67
|
+
.deploy-k8s:
|
|
68
|
+
image: bitnami/kubectl:latest
|
|
69
|
+
script:
|
|
70
|
+
- kubectl -n $NAMESPACE set image deployment/$SERVICE app=$IMAGE:$TAG
|
|
71
|
+
- kubectl -n $NAMESPACE rollout status deployment/$SERVICE --timeout=120s
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Security Scan Template
|
|
75
|
+
```yaml
|
|
76
|
+
.security-scan:
|
|
77
|
+
stage: security
|
|
78
|
+
script:
|
|
79
|
+
- ./mvnw org.owasp:dependency-check-maven:check
|
|
80
|
+
allow_failure: true
|
|
81
|
+
artifacts:
|
|
82
|
+
paths:
|
|
83
|
+
- target/dependency-check-report.html
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## CI Variables to Configure
|
|
87
|
+
| Variable | Purpose |
|
|
88
|
+
|---|---|
|
|
89
|
+
| `CI_REGISTRY_IMAGE` | Docker registry URL |
|
|
90
|
+
| `CI_REGISTRY_USER` | Registry username |
|
|
91
|
+
| `CI_REGISTRY_PASSWORD` | Registry password |
|
|
92
|
+
| `K3S_NAMESPACE` | Kubernetes namespace |
|
|
93
|
+
| `KUBECONFIG` | K8s config (file variable) |
|
|
@@ -1,28 +1,49 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: clean-architecture
|
|
3
|
-
description:
|
|
3
|
+
description: Implement Clean Architecture with domain, application, and infrastructure layers. Use when creating modules, organizing code in layers, separating business rules from infrastructure, or structuring a new project.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: Maestro
|
|
4
6
|
---
|
|
5
7
|
|
|
6
8
|
# Clean Architecture
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
Implement Clean Architecture with properly separated layers, dependency inversion, and domain-centric design.
|
|
11
|
+
|
|
12
|
+
## When to Use
|
|
13
|
+
- When creating a new module or bounded context
|
|
14
|
+
- When organizing code into proper layers
|
|
15
|
+
- When separating business rules from infrastructure
|
|
16
|
+
- When reviewing architecture compliance
|
|
17
|
+
- When refactoring a monolithic service class
|
|
18
|
+
|
|
19
|
+
## Available Operations
|
|
20
|
+
1. Create domain layer with entities and repository interfaces
|
|
21
|
+
2. Create application layer with use cases
|
|
22
|
+
3. Create infrastructure layer with adapters
|
|
23
|
+
4. Verify dependency direction compliance
|
|
24
|
+
5. Refactor code to follow Clean Architecture
|
|
25
|
+
|
|
26
|
+
## Multi-Step Workflow
|
|
27
|
+
|
|
28
|
+
### Step 1: Understand the Layer Structure
|
|
9
29
|
|
|
10
30
|
```
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Dependency Rule:
|
|
22
|
-
Domain
|
|
31
|
+
+------------------------------+
|
|
32
|
+
| API / CLI | <-- Controllers, Routers
|
|
33
|
+
+------------------------------+
|
|
34
|
+
| APPLICATION | <-- Use Cases, DTOs
|
|
35
|
+
+------------------------------+
|
|
36
|
+
| DOMAIN | <-- Entities, VOs, Events, Repos (interface)
|
|
37
|
+
+------------------------------+
|
|
38
|
+
| INFRASTRUCTURE | <-- DB, HTTP clients, Frameworks
|
|
39
|
+
+------------------------------+
|
|
40
|
+
|
|
41
|
+
Dependency Rule: arrows point INWARD (infra -> domain)
|
|
42
|
+
Domain NEVER imports from infrastructure
|
|
23
43
|
```
|
|
24
44
|
|
|
25
|
-
|
|
45
|
+
### Step 2: Implement the Domain Layer
|
|
46
|
+
The domain layer contains entities, value objects, domain events, and repository interfaces (ports).
|
|
26
47
|
|
|
27
48
|
```python
|
|
28
49
|
# domain/entities/demand.py
|
|
@@ -45,7 +66,7 @@ class Demand:
|
|
|
45
66
|
def pending_events(self) -> list[DomainEvent]:
|
|
46
67
|
return list(self._events)
|
|
47
68
|
|
|
48
|
-
# domain/repositories/demand_repository.py (PORT -
|
|
69
|
+
# domain/repositories/demand_repository.py (PORT - interface only)
|
|
49
70
|
class DemandRepository(ABC):
|
|
50
71
|
@abstractmethod
|
|
51
72
|
def find_by_id(self, id: DemandId) -> Demand: ...
|
|
@@ -53,7 +74,8 @@ class DemandRepository(ABC):
|
|
|
53
74
|
def save(self, demand: Demand) -> None: ...
|
|
54
75
|
```
|
|
55
76
|
|
|
56
|
-
|
|
77
|
+
### Step 3: Implement the Application Layer
|
|
78
|
+
Use cases orchestrate domain operations. They contain NO business rules.
|
|
57
79
|
|
|
58
80
|
```python
|
|
59
81
|
# application/use_cases/decompose_demand.py
|
|
@@ -72,7 +94,8 @@ class DecomposeDemand:
|
|
|
72
94
|
return DecomposeDemandOutput(tasks=[TaskDTO.from_entity(t) for t in tasks])
|
|
73
95
|
```
|
|
74
96
|
|
|
75
|
-
|
|
97
|
+
### Step 4: Implement the Infrastructure Layer
|
|
98
|
+
Adapters implement the ports defined in the domain layer.
|
|
76
99
|
|
|
77
100
|
```python
|
|
78
101
|
# infrastructure/persistence/pg_demand_repository.py (ADAPTER)
|
|
@@ -92,8 +115,51 @@ class PgDemandRepository(DemandRepository):
|
|
|
92
115
|
self._session.commit()
|
|
93
116
|
```
|
|
94
117
|
|
|
95
|
-
|
|
118
|
+
### Step 5: Verify Architecture Compliance
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
# Check for dependency violations: domain should not import infrastructure
|
|
122
|
+
grep -rn "from infrastructure" src/domain/ --include="*.py"
|
|
123
|
+
grep -rn "from.*infrastructure" src/domain/ --include="*.java"
|
|
96
124
|
|
|
97
|
-
|
|
125
|
+
# Run tests per layer
|
|
126
|
+
pytest tests/domain/ # Unit tests (no infra deps)
|
|
127
|
+
pytest tests/application/ # Use case tests (mocked deps)
|
|
128
|
+
pytest tests/infrastructure/ # Integration tests
|
|
129
|
+
```
|
|
98
130
|
|
|
99
|
-
|
|
131
|
+
## Resources
|
|
132
|
+
- `references/layer-rules.md` - Layer dependency rules and package organization
|
|
133
|
+
|
|
134
|
+
## Examples
|
|
135
|
+
### Example 1: Create a New Domain Module
|
|
136
|
+
User asks: "Create the demand management module with Clean Architecture"
|
|
137
|
+
Response approach:
|
|
138
|
+
1. Create `domain/entities/demand.py` with entity and behavior
|
|
139
|
+
2. Create `domain/repositories/demand_repository.py` as interface (port)
|
|
140
|
+
3. Create `application/use_cases/create_demand.py` as orchestrator
|
|
141
|
+
4. Create `infrastructure/persistence/pg_demand_repository.py` as adapter
|
|
142
|
+
5. Wire dependencies via DI container
|
|
143
|
+
|
|
144
|
+
### Example 2: Refactor a Fat Service
|
|
145
|
+
User asks: "This service has 500 lines and mixes business logic with database calls"
|
|
146
|
+
Response approach:
|
|
147
|
+
1. Extract business rules into domain entities
|
|
148
|
+
2. Extract repository interface from data access code
|
|
149
|
+
3. Create use case class for orchestration
|
|
150
|
+
4. Move database code to infrastructure adapter
|
|
151
|
+
5. Verify no domain imports from infrastructure
|
|
152
|
+
|
|
153
|
+
### Example 3: Verify Architecture
|
|
154
|
+
User asks: "Check if our code follows Clean Architecture"
|
|
155
|
+
Response approach:
|
|
156
|
+
1. Search for dependency violations with grep
|
|
157
|
+
2. Check that domain layer has no framework imports
|
|
158
|
+
3. Verify use cases only orchestrate, not contain logic
|
|
159
|
+
4. Check that entities have behavior, not just data
|
|
160
|
+
|
|
161
|
+
## Notes
|
|
162
|
+
- Golden Rule: Use Case orchestrates -> Entity contains rules -> Repository persists
|
|
163
|
+
- Never put business logic in Controller, Repository, or generic "Service"
|
|
164
|
+
- Domain layer must be testable without any infrastructure
|
|
165
|
+
- Use dependency injection to wire adapters to ports
|
package/templates/bundle-jhipster-microservices/skills/clean-architecture/references/layer-rules.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Clean Architecture Layer Rules
|
|
2
|
+
|
|
3
|
+
## Dependency Direction
|
|
4
|
+
```
|
|
5
|
+
API/CLI --> APPLICATION --> DOMAIN <-- INFRASTRUCTURE
|
|
6
|
+
```
|
|
7
|
+
- All dependencies point toward DOMAIN
|
|
8
|
+
- Domain NEVER imports from Application, Infrastructure, or API
|
|
9
|
+
- Infrastructure implements Domain interfaces (Dependency Inversion)
|
|
10
|
+
|
|
11
|
+
## Layer Contents
|
|
12
|
+
|
|
13
|
+
### Domain Layer
|
|
14
|
+
- Entities (with behavior, not anemic)
|
|
15
|
+
- Value Objects (immutable, validated)
|
|
16
|
+
- Domain Events
|
|
17
|
+
- Repository Interfaces (Ports)
|
|
18
|
+
- Domain Services (cross-entity logic)
|
|
19
|
+
- Exceptions (business exceptions)
|
|
20
|
+
|
|
21
|
+
### Application Layer
|
|
22
|
+
- Use Cases (one per operation)
|
|
23
|
+
- Input/Output DTOs
|
|
24
|
+
- Application Services (orchestration only)
|
|
25
|
+
- NO business rules here
|
|
26
|
+
|
|
27
|
+
### Infrastructure Layer
|
|
28
|
+
- Repository Implementations (Adapters)
|
|
29
|
+
- Database Models/Mappings
|
|
30
|
+
- HTTP Clients
|
|
31
|
+
- Message Queue Producers/Consumers
|
|
32
|
+
- Framework Configuration
|
|
33
|
+
|
|
34
|
+
### API Layer
|
|
35
|
+
- REST Controllers
|
|
36
|
+
- GraphQL Resolvers
|
|
37
|
+
- CLI Commands
|
|
38
|
+
- Request/Response mapping
|
|
39
|
+
|
|
40
|
+
## Package Organization (Java)
|
|
41
|
+
```
|
|
42
|
+
com.myapp/
|
|
43
|
+
domain/
|
|
44
|
+
model/ # Entities, VOs
|
|
45
|
+
event/ # Domain Events
|
|
46
|
+
repository/ # Repository interfaces
|
|
47
|
+
service/ # Domain Services
|
|
48
|
+
exception/ # Business exceptions
|
|
49
|
+
application/
|
|
50
|
+
usecase/ # Use Cases
|
|
51
|
+
dto/ # Input/Output DTOs
|
|
52
|
+
infrastructure/
|
|
53
|
+
persistence/ # JPA Repositories
|
|
54
|
+
messaging/ # Kafka/RabbitMQ
|
|
55
|
+
http/ # REST clients
|
|
56
|
+
web/
|
|
57
|
+
rest/ # Controllers
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Package Organization (Python)
|
|
61
|
+
```
|
|
62
|
+
src/
|
|
63
|
+
domain/
|
|
64
|
+
entities/
|
|
65
|
+
value_objects/
|
|
66
|
+
events/
|
|
67
|
+
repositories/ # ABC interfaces
|
|
68
|
+
services/
|
|
69
|
+
application/
|
|
70
|
+
use_cases/
|
|
71
|
+
dto/
|
|
72
|
+
infrastructure/
|
|
73
|
+
persistence/
|
|
74
|
+
messaging/
|
|
75
|
+
http_clients/
|
|
76
|
+
api/
|
|
77
|
+
routes/
|
|
78
|
+
```
|
|
@@ -1,13 +1,32 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: ddd-tactical
|
|
3
|
-
description:
|
|
3
|
+
description: Implement DDD tactical patterns -- Entities, Value Objects, Aggregates, Domain Events, Repositories, and Domain Services. Use when modeling domain, creating rich entities, defining aggregates, or applying DDD patterns.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: Maestro
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
# DDD
|
|
8
|
+
# DDD Tactical Patterns
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
Implement Domain-Driven Design tactical patterns including Entities, Value Objects, Aggregates, Domain Events, Repositories, and Domain Services.
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
## When to Use
|
|
13
|
+
- When modeling domain entities with rich behavior
|
|
14
|
+
- When creating value objects for validated types
|
|
15
|
+
- When defining aggregate boundaries and invariants
|
|
16
|
+
- When implementing domain events for cross-aggregate communication
|
|
17
|
+
- When business logic spans multiple entities (Domain Services)
|
|
18
|
+
|
|
19
|
+
## Available Operations
|
|
20
|
+
1. Create Value Objects with validation
|
|
21
|
+
2. Create Entities with identity and behavior
|
|
22
|
+
3. Define Aggregates with invariant protection
|
|
23
|
+
4. Implement Domain Events
|
|
24
|
+
5. Create Domain Services for cross-entity logic
|
|
25
|
+
|
|
26
|
+
## Multi-Step Workflow
|
|
27
|
+
|
|
28
|
+
### Step 1: Identify Value Objects
|
|
29
|
+
Value Objects are immutable, compared by value, and contain self-validation.
|
|
11
30
|
|
|
12
31
|
```python
|
|
13
32
|
@dataclass(frozen=True)
|
|
@@ -24,7 +43,7 @@ class ComplianceScore:
|
|
|
24
43
|
|
|
25
44
|
def __post_init__(self):
|
|
26
45
|
if not 0 <= self.value <= 100:
|
|
27
|
-
raise ValueError("Score
|
|
46
|
+
raise ValueError("Score must be between 0 and 100")
|
|
28
47
|
|
|
29
48
|
def is_passing(self) -> bool:
|
|
30
49
|
return self.value >= 80.0
|
|
@@ -33,9 +52,8 @@ class ComplianceScore:
|
|
|
33
52
|
return f"{self.value:.1f}%"
|
|
34
53
|
```
|
|
35
54
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Identidade única, mutáveis, contêm comportamento.
|
|
55
|
+
### Step 2: Create Entities
|
|
56
|
+
Entities have unique identity, are mutable, and contain behavior.
|
|
39
57
|
|
|
40
58
|
```python
|
|
41
59
|
class Task:
|
|
@@ -66,31 +84,29 @@ class Task:
|
|
|
66
84
|
return None
|
|
67
85
|
```
|
|
68
86
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Cluster de entities com uma raiz que protege invariantes.
|
|
87
|
+
### Step 3: Define Aggregates
|
|
88
|
+
An Aggregate is a cluster of entities with a root that protects invariants.
|
|
72
89
|
|
|
73
90
|
```python
|
|
74
91
|
class Demand: # Aggregate Root
|
|
75
|
-
"""Demand
|
|
92
|
+
"""Demand is the root. Tasks are only accessed via Demand."""
|
|
76
93
|
|
|
77
94
|
def add_task(self, task: Task) -> None:
|
|
78
95
|
if len(self._tasks) >= 20:
|
|
79
|
-
raise TooManyTasksException("
|
|
96
|
+
raise TooManyTasksException("Maximum 20 tasks per demand")
|
|
80
97
|
self._tasks.append(task)
|
|
81
98
|
|
|
82
99
|
def start_task(self, task_id: TaskId) -> None:
|
|
83
100
|
task = self._find_task(task_id)
|
|
84
|
-
#
|
|
101
|
+
# Invariant: no more than 3 concurrent tasks
|
|
85
102
|
active = [t for t in self._tasks if t.status == TaskStatus.IN_PROGRESS]
|
|
86
103
|
if len(active) >= 3:
|
|
87
104
|
raise TooManyActiveTasksException()
|
|
88
105
|
task.start()
|
|
89
106
|
```
|
|
90
107
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
Notificam que algo aconteceu no domínio.
|
|
108
|
+
### Step 4: Implement Domain Events
|
|
109
|
+
Domain Events notify that something happened in the domain.
|
|
94
110
|
|
|
95
111
|
```python
|
|
96
112
|
@dataclass(frozen=True)
|
|
@@ -112,9 +128,8 @@ class ComplianceViolationDetected(DomainEvent):
|
|
|
112
128
|
severity: str # "warning" | "critical"
|
|
113
129
|
```
|
|
114
130
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
Lógica que não pertence a uma única entidade.
|
|
131
|
+
### Step 5: Create Domain Services
|
|
132
|
+
For logic that does not belong to a single entity.
|
|
118
133
|
|
|
119
134
|
```python
|
|
120
135
|
class TeamRecruitmentService:
|
|
@@ -130,9 +145,63 @@ class TeamRecruitmentService:
|
|
|
130
145
|
return team
|
|
131
146
|
```
|
|
132
147
|
|
|
133
|
-
|
|
148
|
+
### Step 6: Write Tests for Domain Logic
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Run domain unit tests (no infrastructure dependencies)
|
|
152
|
+
pytest tests/domain/ -v
|
|
153
|
+
|
|
154
|
+
# For Java/JUnit
|
|
155
|
+
./mvnw test -Dtest="*DomainTest,*ValueObjectTest"
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
class TestComplianceScore:
|
|
160
|
+
def test_passing_score(self):
|
|
161
|
+
score = ComplianceScore(85.0)
|
|
162
|
+
assert score.is_passing() is True
|
|
163
|
+
|
|
164
|
+
def test_invalid_score_raises(self):
|
|
165
|
+
with pytest.raises(ValueError):
|
|
166
|
+
ComplianceScore(150.0)
|
|
167
|
+
```
|
|
134
168
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
169
|
+
## Resources
|
|
170
|
+
- `references/ddd-patterns.md` - DDD pattern decision guide and examples
|
|
171
|
+
|
|
172
|
+
## Examples
|
|
173
|
+
### Example 1: Create a Value Object
|
|
174
|
+
User asks: "Create a value object for email validation"
|
|
175
|
+
Response approach:
|
|
176
|
+
1. Create immutable dataclass/record with validation in constructor
|
|
177
|
+
2. Add behavior methods (e.g., `domain()`, `is_corporate()`)
|
|
178
|
+
3. Ensure equality by value, not reference
|
|
179
|
+
4. Write unit tests for valid and invalid cases
|
|
180
|
+
|
|
181
|
+
### Example 2: Define an Aggregate
|
|
182
|
+
User asks: "Model a Demand that contains Tasks with business rules"
|
|
183
|
+
Response approach:
|
|
184
|
+
1. Make Demand the Aggregate Root
|
|
185
|
+
2. Tasks are only accessed through Demand methods
|
|
186
|
+
3. Add invariants: max tasks, max concurrent, completion rules
|
|
187
|
+
4. Emit domain events on state changes
|
|
188
|
+
5. Write tests for each invariant
|
|
189
|
+
|
|
190
|
+
### Example 3: Implement a Domain Service
|
|
191
|
+
User asks: "I need logic that involves both Demands and Agents"
|
|
192
|
+
Response approach:
|
|
193
|
+
1. Create a Domain Service (not a generic "Service")
|
|
194
|
+
2. Accept entities as parameters, not IDs
|
|
195
|
+
3. Implement the cross-entity logic
|
|
196
|
+
4. Return results, let the use case persist
|
|
197
|
+
5. Write tests with test doubles for entities
|
|
198
|
+
|
|
199
|
+
## Notes
|
|
200
|
+
- Priority for placing business rules:
|
|
201
|
+
1. **Value Object** -- validation and simple behavior
|
|
202
|
+
2. **Entity** -- rules involving entity state
|
|
203
|
+
3. **Domain Service** -- rules involving multiple entities
|
|
204
|
+
4. **Use Case** -- orchestration only (NO business rules)
|
|
205
|
+
- Aggregates should be small -- prefer separate aggregates connected by ID
|
|
206
|
+
- Domain Events are immutable records of what happened
|
|
207
|
+
- Domain layer must have zero framework dependencies
|
package/templates/bundle-jhipster-microservices/skills/ddd-tactical/references/ddd-patterns.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# DDD Tactical Patterns Reference
|
|
2
|
+
|
|
3
|
+
## Decision Guide: Where to Put Business Logic
|
|
4
|
+
|
|
5
|
+
| Pattern | When to Use | Example |
|
|
6
|
+
|---|---|---|
|
|
7
|
+
| Value Object | Validation, simple behavior, no identity | Email, Money, ComplianceScore |
|
|
8
|
+
| Entity | Has identity, mutable state, behavior | Task, Agent, Demand |
|
|
9
|
+
| Aggregate | Cluster with invariants, transactional boundary | Demand (root) + Tasks (children) |
|
|
10
|
+
| Domain Event | Notify something happened | TaskCompleted, DemandCreated |
|
|
11
|
+
| Domain Service | Logic spanning multiple entities | TeamRecruitmentService |
|
|
12
|
+
| Repository (Port) | Persistence abstraction | DemandRepository (interface) |
|
|
13
|
+
|
|
14
|
+
## Value Object Checklist
|
|
15
|
+
- [ ] Immutable (frozen dataclass / Java record)
|
|
16
|
+
- [ ] Validated in constructor
|
|
17
|
+
- [ ] Compared by value, not reference
|
|
18
|
+
- [ ] Contains behavior methods
|
|
19
|
+
- [ ] No identity field
|
|
20
|
+
|
|
21
|
+
## Entity Checklist
|
|
22
|
+
- [ ] Has unique identity (ID)
|
|
23
|
+
- [ ] Mutable state with controlled transitions
|
|
24
|
+
- [ ] Contains behavior (not anemic)
|
|
25
|
+
- [ ] State changes enforce invariants
|
|
26
|
+
- [ ] Compared by identity, not value
|
|
27
|
+
|
|
28
|
+
## Aggregate Checklist
|
|
29
|
+
- [ ] Has a single root entity
|
|
30
|
+
- [ ] Children accessed only through root
|
|
31
|
+
- [ ] Invariants enforced by root
|
|
32
|
+
- [ ] Small boundary (prefer separate aggregates)
|
|
33
|
+
- [ ] Cross-aggregate references by ID only
|
|
34
|
+
- [ ] One aggregate per transaction
|
|
35
|
+
|
|
36
|
+
## Domain Event Checklist
|
|
37
|
+
- [ ] Immutable (record/frozen dataclass)
|
|
38
|
+
- [ ] Contains occurred_at timestamp
|
|
39
|
+
- [ ] Named in past tense (TaskCompleted, not CompleteTask)
|
|
40
|
+
- [ ] Contains only IDs and primitives (no entity references)
|
|
41
|
+
- [ ] Published after aggregate state change
|
|
42
|
+
|
|
43
|
+
## Domain Service Checklist
|
|
44
|
+
- [ ] Logic involves multiple aggregates
|
|
45
|
+
- [ ] Stateless (no internal state)
|
|
46
|
+
- [ ] Named after the operation (TeamRecruitmentService)
|
|
47
|
+
- [ ] Accepts entities as parameters
|
|
48
|
+
- [ ] Does not persist (caller persists)
|
|
@@ -1,25 +1,42 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: jhipster-angular
|
|
3
|
-
description:
|
|
3
|
+
description: Develop Angular frontend in the JHipster Gateway consuming multiple microservices. Use when creating screens that aggregate data from multiple services, handling partial failures, or customizing the Gateway frontend.
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
author: Maestro
|
|
4
6
|
---
|
|
5
7
|
|
|
6
|
-
# JHipster Angular
|
|
8
|
+
# JHipster Angular -- Microservices
|
|
7
9
|
|
|
8
|
-
|
|
10
|
+
Develop the Angular frontend hosted in the Gateway, which transparently consumes multiple microservices through the Gateway's routing.
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
## When to Use
|
|
13
|
+
- When creating screens that aggregate data from multiple services
|
|
14
|
+
- When building dashboards with data from different microservices
|
|
15
|
+
- When handling partial service failures gracefully in the UI
|
|
16
|
+
- When adding WebSocket real-time features via the Gateway
|
|
17
|
+
|
|
18
|
+
## Available Operations
|
|
19
|
+
1. Create services that aggregate data from multiple backends
|
|
20
|
+
2. Handle partial service failures with fallback UI
|
|
21
|
+
3. Add WebSocket real-time updates
|
|
22
|
+
4. Build cross-service dashboards
|
|
23
|
+
5. Customize entity components from different services
|
|
24
|
+
|
|
25
|
+
## Multi-Step Workflow
|
|
26
|
+
|
|
27
|
+
### Step 1: Understand the Architecture
|
|
11
28
|
|
|
12
29
|
```
|
|
13
|
-
Browser
|
|
14
|
-
Browser
|
|
30
|
+
Browser --> Gateway:8080/api/demands --> demand-service:8081/api/demands
|
|
31
|
+
Browser --> Gateway:8080/api/agents --> agent-service:8082/api/agents
|
|
15
32
|
```
|
|
16
33
|
|
|
17
|
-
|
|
34
|
+
The Angular app lives in the Gateway. From Angular's perspective, everything is a single API.
|
|
18
35
|
|
|
19
|
-
|
|
36
|
+
### Step 2: Create Services That Aggregate Data
|
|
20
37
|
|
|
21
38
|
```typescript
|
|
22
|
-
// dashboard.service.ts
|
|
39
|
+
// dashboard.service.ts -- aggregates data from multiple services (via gateway)
|
|
23
40
|
@Injectable({ providedIn: 'root' })
|
|
24
41
|
export class DashboardService {
|
|
25
42
|
constructor(
|
|
@@ -39,15 +56,13 @@ export class DashboardService {
|
|
|
39
56
|
}
|
|
40
57
|
```
|
|
41
58
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Se um serviço estiver fora do ar, mostrar o que conseguir:
|
|
59
|
+
### Step 3: Handle Partial Service Failures
|
|
45
60
|
|
|
46
61
|
```typescript
|
|
47
62
|
getMetrics(): Observable<DashboardMetrics> {
|
|
48
63
|
return forkJoin({
|
|
49
64
|
activeDemands: this.demandService.countByStatus('IN_PROGRESS').pipe(
|
|
50
|
-
catchError(() => of({ count: -1 })) // -1 =
|
|
65
|
+
catchError(() => of({ count: -1 })) // -1 = unavailable
|
|
51
66
|
),
|
|
52
67
|
activeAgents: this.agentService.countByStatus('BUSY').pipe(
|
|
53
68
|
catchError(() => of({ count: -1 }))
|
|
@@ -61,14 +76,13 @@ getMetrics(): Observable<DashboardMetrics> {
|
|
|
61
76
|
{{ metrics.activeDemands.count }}
|
|
62
77
|
</div>
|
|
63
78
|
<ng-template #unavailable>
|
|
64
|
-
<span class="text-muted">
|
|
79
|
+
<span class="text-muted">Unavailable</span>
|
|
65
80
|
</ng-template>
|
|
66
81
|
```
|
|
67
82
|
|
|
68
|
-
|
|
83
|
+
### Step 4: Add WebSocket for Real-Time Updates
|
|
69
84
|
|
|
70
85
|
```typescript
|
|
71
|
-
// No Gateway, conectar via STOMP
|
|
72
86
|
@Injectable({ providedIn: 'root' })
|
|
73
87
|
export class WebSocketService {
|
|
74
88
|
private stompClient: RxStomp;
|
|
@@ -89,9 +103,37 @@ export class WebSocketService {
|
|
|
89
103
|
}
|
|
90
104
|
```
|
|
91
105
|
|
|
92
|
-
|
|
106
|
+
### Step 5: Build and Verify
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm start
|
|
110
|
+
npm test
|
|
111
|
+
npm run lint
|
|
112
|
+
npm run build
|
|
113
|
+
```
|
|
93
114
|
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
|
|
97
|
-
|
|
115
|
+
## Resources
|
|
116
|
+
- `references/angular-microservices.md` - Angular patterns for microservices architecture
|
|
117
|
+
|
|
118
|
+
## Examples
|
|
119
|
+
### Example 1: Build a Cross-Service Dashboard
|
|
120
|
+
User asks: "Create a dashboard showing demands, agents, and metrics"
|
|
121
|
+
Response approach:
|
|
122
|
+
1. Create `DashboardService` using `forkJoin` to aggregate data
|
|
123
|
+
2. Add `catchError` for each service call
|
|
124
|
+
3. Create dashboard component with metric cards
|
|
125
|
+
4. Show "Unavailable" when a service is down
|
|
126
|
+
5. Run `npm start` to verify
|
|
127
|
+
|
|
128
|
+
### Example 2: Handle Service Outage
|
|
129
|
+
User asks: "The agent-service is down, the dashboard crashes"
|
|
130
|
+
Response approach:
|
|
131
|
+
1. Add `catchError(() => of(fallbackValue))` to the agent-service call
|
|
132
|
+
2. Show graceful "unavailable" UI instead of error
|
|
133
|
+
3. Other service data should still display correctly
|
|
134
|
+
|
|
135
|
+
## Notes
|
|
136
|
+
- Frontend lives in the Gateway, NOT in individual services
|
|
137
|
+
- Treat partial failures gracefully -- show what you can
|
|
138
|
+
- Use `forkJoin` for aggregation, `catchError` for resilience
|
|
139
|
+
- Use lazy loading per module/feature
|