@patricio0312rev/skillset 0.1.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/CHANGELOG.md +29 -0
- package/LICENSE +21 -0
- package/README.md +176 -0
- package/bin/cli.js +37 -0
- package/package.json +55 -0
- package/src/commands/init.js +301 -0
- package/src/index.js +168 -0
- package/src/lib/config.js +200 -0
- package/src/lib/generator.js +166 -0
- package/src/utils/display.js +95 -0
- package/src/utils/readme.js +196 -0
- package/src/utils/tool-specific.js +233 -0
- package/templates/ai-engineering/agent-orchestration-planner/ SKILL.md +266 -0
- package/templates/ai-engineering/cost-latency-optimizer/ SKILL.md +270 -0
- package/templates/ai-engineering/doc-to-vector-dataset-generator/ SKILL.md +239 -0
- package/templates/ai-engineering/evaluation-harness/ SKILL.md +219 -0
- package/templates/ai-engineering/guardrails-safety-filter-builder/ SKILL.md +226 -0
- package/templates/ai-engineering/llm-debugger/ SKILL.md +283 -0
- package/templates/ai-engineering/prompt-regression-tester/ SKILL.md +216 -0
- package/templates/ai-engineering/prompt-template-builder/ SKILL.md +393 -0
- package/templates/ai-engineering/rag-pipeline-builder/ SKILL.md +244 -0
- package/templates/ai-engineering/tool-function-schema-designer/ SKILL.md +219 -0
- package/templates/architecture/adr-writer/ SKILL.md +250 -0
- package/templates/architecture/api-versioning-deprecation-planner/ SKILL.md +331 -0
- package/templates/architecture/domain-model-boundaries-mapper/ SKILL.md +300 -0
- package/templates/architecture/migration-planner/ SKILL.md +376 -0
- package/templates/architecture/performance-budget-setter/ SKILL.md +318 -0
- package/templates/architecture/reliability-strategy-builder/ SKILL.md +286 -0
- package/templates/architecture/rfc-generator/ SKILL.md +362 -0
- package/templates/architecture/scalability-playbook/ SKILL.md +279 -0
- package/templates/architecture/system-design-generator/ SKILL.md +339 -0
- package/templates/architecture/tech-debt-prioritizer/ SKILL.md +329 -0
- package/templates/backend/api-contract-normalizer/ SKILL.md +487 -0
- package/templates/backend/api-endpoint-generator/ SKILL.md +415 -0
- package/templates/backend/auth-module-builder/ SKILL.md +99 -0
- package/templates/backend/background-jobs-designer/ SKILL.md +166 -0
- package/templates/backend/caching-strategist/ SKILL.md +190 -0
- package/templates/backend/error-handling-standardizer/ SKILL.md +174 -0
- package/templates/backend/rate-limiting-abuse-protection/ SKILL.md +147 -0
- package/templates/backend/rbac-permissions-builder/ SKILL.md +158 -0
- package/templates/backend/service-layer-extractor/ SKILL.md +269 -0
- package/templates/backend/webhook-receiver-hardener/ SKILL.md +211 -0
- package/templates/ci-cd/artifact-sbom-publisher/ SKILL.md +236 -0
- package/templates/ci-cd/caching-strategy-optimizer/ SKILL.md +195 -0
- package/templates/ci-cd/deployment-checklist-generator/ SKILL.md +381 -0
- package/templates/ci-cd/github-actions-pipeline-creator/ SKILL.md +348 -0
- package/templates/ci-cd/monorepo-ci-optimizer/ SKILL.md +298 -0
- package/templates/ci-cd/preview-environments-builder/ SKILL.md +187 -0
- package/templates/ci-cd/quality-gates-enforcer/ SKILL.md +342 -0
- package/templates/ci-cd/release-automation-builder/ SKILL.md +281 -0
- package/templates/ci-cd/rollback-workflow-builder/ SKILL.md +372 -0
- package/templates/ci-cd/secrets-env-manager/ SKILL.md +242 -0
- package/templates/db-management/backup-restore-runbook-generator/ SKILL.md +505 -0
- package/templates/db-management/data-integrity-auditor/ SKILL.md +505 -0
- package/templates/db-management/data-retention-archiving-planner/ SKILL.md +430 -0
- package/templates/db-management/data-seeding-fixtures-builder/ SKILL.md +375 -0
- package/templates/db-management/db-performance-watchlist/ SKILL.md +425 -0
- package/templates/db-management/etl-sync-job-builder/ SKILL.md +457 -0
- package/templates/db-management/multi-tenant-safety-checker/ SKILL.md +398 -0
- package/templates/db-management/prisma-migration-assistant/ SKILL.md +379 -0
- package/templates/db-management/schema-consistency-checker/ SKILL.md +440 -0
- package/templates/db-management/sql-query-optimizer/ SKILL.md +324 -0
- package/templates/foundation/changelog-writer/ SKILL.md +431 -0
- package/templates/foundation/code-formatter-installer/ SKILL.md +320 -0
- package/templates/foundation/codebase-summarizer/ SKILL.md +360 -0
- package/templates/foundation/dependency-doctor/ SKILL.md +163 -0
- package/templates/foundation/dev-environment-bootstrapper/ SKILL.md +259 -0
- package/templates/foundation/dev-onboarding-builder/ SKILL.md +556 -0
- package/templates/foundation/docs-starter-kit/ SKILL.md +574 -0
- package/templates/foundation/explaining-code/SKILL.md +13 -0
- package/templates/foundation/git-hygiene-enforcer/ SKILL.md +455 -0
- package/templates/foundation/project-scaffolder/ SKILL.md +65 -0
- package/templates/foundation/project-scaffolder/references/templates.md +126 -0
- package/templates/foundation/repo-structure-linter/ SKILL.md +0 -0
- package/templates/foundation/repo-structure-linter/references/conventions.md +98 -0
- package/templates/frontend/animation-micro-interaction-pack/ SKILL.md +41 -0
- package/templates/frontend/component-scaffold-generator/ SKILL.md +562 -0
- package/templates/frontend/design-to-component-translator/ SKILL.md +547 -0
- package/templates/frontend/form-wizard-builder/ SKILL.md +553 -0
- package/templates/frontend/frontend-refactor-planner/ SKILL.md +37 -0
- package/templates/frontend/i18n-frontend-implementer/ SKILL.md +44 -0
- package/templates/frontend/modal-drawer-system/ SKILL.md +377 -0
- package/templates/frontend/page-layout-builder/ SKILL.md +630 -0
- package/templates/frontend/state-ux-flow-builder/ SKILL.md +23 -0
- package/templates/frontend/table-builder/ SKILL.md +350 -0
- package/templates/performance/alerting-dashboard-builder/ SKILL.md +162 -0
- package/templates/performance/backend-latency-profiler-helper/ SKILL.md +108 -0
- package/templates/performance/caching-cdn-strategy-planner/ SKILL.md +150 -0
- package/templates/performance/capacity-planning-helper/ SKILL.md +242 -0
- package/templates/performance/core-web-vitals-tuner/ SKILL.md +126 -0
- package/templates/performance/incident-runbook-generator/ SKILL.md +162 -0
- package/templates/performance/load-test-scenario-builder/ SKILL.md +256 -0
- package/templates/performance/observability-setup/ SKILL.md +232 -0
- package/templates/performance/postmortem-writer/ SKILL.md +203 -0
- package/templates/performance/structured-logging-standardizer/ SKILL.md +122 -0
- package/templates/security/auth-security-reviewer/ SKILL.md +428 -0
- package/templates/security/dependency-vulnerability-triage/ SKILL.md +495 -0
- package/templates/security/input-validation-sanitization-auditor/ SKILL.md +76 -0
- package/templates/security/pii-redaction-logging-policy-builder/ SKILL.md +65 -0
- package/templates/security/rbac-policy-tester/ SKILL.md +80 -0
- package/templates/security/secrets-scanner/ SKILL.md +462 -0
- package/templates/security/secure-headers-csp-builder/ SKILL.md +404 -0
- package/templates/security/security-incident-playbook-generator/ SKILL.md +76 -0
- package/templates/security/security-pr-checklist-skill/ SKILL.md +62 -0
- package/templates/security/threat-model-generator/ SKILL.md +394 -0
- package/templates/testing/contract-testing-builder/ SKILL.md +492 -0
- package/templates/testing/coverage-strategist/ SKILL.md +436 -0
- package/templates/testing/e2e-test-builder/ SKILL.md +382 -0
- package/templates/testing/flaky-test-detective/ SKILL.md +416 -0
- package/templates/testing/integration-test-builder/ SKILL.md +525 -0
- package/templates/testing/mocking-assistant/ SKILL.md +383 -0
- package/templates/testing/snapshot-test-refactorer/ SKILL.md +375 -0
- package/templates/testing/test-data-factory-builder/ SKILL.md +449 -0
- package/templates/testing/test-reporting-triage-skill/ SKILL.md +469 -0
- package/templates/testing/unit-test-generator/ SKILL.md +548 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-versioning-deprecation-planner
|
|
3
|
+
description: Plans safe API evolution with versioning strategies, client migration guides, deprecation timelines, and backward compatibility considerations. Use for "API versioning", "deprecation planning", "API evolution", or "breaking changes".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API Versioning & Deprecation Planner
|
|
7
|
+
|
|
8
|
+
Safely evolve APIs without breaking existing clients.
|
|
9
|
+
|
|
10
|
+
## Versioning Strategies
|
|
11
|
+
|
|
12
|
+
### URL Versioning (Recommended)
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
/api/v1/users
|
|
16
|
+
/api/v2/users
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**Pros:** Clear, easy to route, simple to document
|
|
20
|
+
**Cons:** URL pollution with many versions
|
|
21
|
+
|
|
22
|
+
### Header Versioning
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
GET /api/users
|
|
26
|
+
Accept: application/vnd.api.v1+json
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Pros:** Clean URLs
|
|
30
|
+
**Cons:** Harder to test, less visible
|
|
31
|
+
|
|
32
|
+
### Query Parameter
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
/api/users?version=1
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Pros:** Easy to implement
|
|
39
|
+
**Cons:** Not RESTful, easy to forget
|
|
40
|
+
|
|
41
|
+
## Deprecation Timeline
|
|
42
|
+
|
|
43
|
+
```markdown
|
|
44
|
+
# API Deprecation Plan: v1 → v2
|
|
45
|
+
|
|
46
|
+
## Timeline (6 months)
|
|
47
|
+
|
|
48
|
+
### Month 1: Announcement
|
|
49
|
+
|
|
50
|
+
- [ ] Publish deprecation notice in changelog
|
|
51
|
+
- [ ] Email all API consumers
|
|
52
|
+
- [ ] Add deprecation headers to v1 responses
|
|
53
|
+
- [ ] Update documentation with migration guide
|
|
54
|
+
|
|
55
|
+
### Month 2-4: Migration Period
|
|
56
|
+
|
|
57
|
+
- [ ] v2 fully available
|
|
58
|
+
- [ ] Both v1 and v2 supported
|
|
59
|
+
- [ ] Track v1 usage metrics
|
|
60
|
+
- [ ] Offer migration support
|
|
61
|
+
|
|
62
|
+
### Month 5: Final Warning
|
|
63
|
+
|
|
64
|
+
- [ ] Email reminder to remaining v1 users
|
|
65
|
+
- [ ] Increase deprecation warning visibility
|
|
66
|
+
- [ ] Offer 1-on-1 migration help
|
|
67
|
+
|
|
68
|
+
### Month 6: Sunset
|
|
69
|
+
|
|
70
|
+
- [ ] Disable v1 endpoints
|
|
71
|
+
- [ ] Return 410 Gone with migration instructions
|
|
72
|
+
- [ ] Monitor for issues
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Deprecation Response Headers
|
|
76
|
+
|
|
77
|
+
```http
|
|
78
|
+
HTTP/1.1 200 OK
|
|
79
|
+
Deprecation: true
|
|
80
|
+
Sunset: Sat, 31 Dec 2024 23:59:59 GMT
|
|
81
|
+
Link: <https://api.example.com/v2/users>; rel="alternate"
|
|
82
|
+
Warning: 299 - "This API version is deprecated. Migrate to v2 by Dec 31, 2024"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Breaking vs Non-Breaking Changes
|
|
86
|
+
|
|
87
|
+
### Non-Breaking (Safe)
|
|
88
|
+
|
|
89
|
+
✅ Adding new endpoints
|
|
90
|
+
✅ Adding optional request parameters
|
|
91
|
+
✅ Adding fields to responses
|
|
92
|
+
✅ Adding new response status codes
|
|
93
|
+
✅ Making required fields optional
|
|
94
|
+
|
|
95
|
+
### Breaking (Requires New Version)
|
|
96
|
+
|
|
97
|
+
❌ Removing endpoints
|
|
98
|
+
❌ Removing request parameters
|
|
99
|
+
❌ Removing response fields
|
|
100
|
+
❌ Changing field types
|
|
101
|
+
❌ Making optional fields required
|
|
102
|
+
❌ Changing authentication
|
|
103
|
+
|
|
104
|
+
## Migration Guide Template
|
|
105
|
+
|
|
106
|
+
```markdown
|
|
107
|
+
# Migration Guide: API v1 → v2
|
|
108
|
+
|
|
109
|
+
## What's Changing
|
|
110
|
+
|
|
111
|
+
### Authentication
|
|
112
|
+
|
|
113
|
+
**v1:** API Key in query param
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
GET /api/v1/users?api_key=xxx
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**v2:** Bearer token in header
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
GET /api/v2/users
|
|
124
|
+
Authorization: Bearer xxx
|
|
125
|
+
|
|
126
|
+
````
|
|
127
|
+
|
|
128
|
+
### Response Format
|
|
129
|
+
**v1:** Snake case
|
|
130
|
+
```json
|
|
131
|
+
{"user_id": 123, "first_name": "John"}
|
|
132
|
+
````
|
|
133
|
+
|
|
134
|
+
**v2:** Camel case
|
|
135
|
+
|
|
136
|
+
```json
|
|
137
|
+
{ "userId": 123, "firstName": "John" }
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Pagination
|
|
141
|
+
|
|
142
|
+
**v1:** Page-based
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
GET /api/v1/users?page=2&per_page=10
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**v2:** Cursor-based
|
|
149
|
+
|
|
150
|
+
```
|
|
151
|
+
GET /api/v2/users?cursor=abc123&limit=10
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Step-by-Step Migration
|
|
155
|
+
|
|
156
|
+
### Step 1: Update Authentication
|
|
157
|
+
|
|
158
|
+
Replace query param auth with header-based:
|
|
159
|
+
|
|
160
|
+
```diff
|
|
161
|
+
- axios.get('/api/v1/users?api_key=xxx')
|
|
162
|
+
+ axios.get('/api/v2/users', {
|
|
163
|
+
+ headers: { 'Authorization': 'Bearer xxx' }
|
|
164
|
+
+ })
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Step 2: Update Response Handling
|
|
168
|
+
|
|
169
|
+
Adjust field name casing:
|
|
170
|
+
|
|
171
|
+
```diff
|
|
172
|
+
- const userId = data.user_id
|
|
173
|
+
+ const userId = data.userId
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Step 3: Update Pagination
|
|
177
|
+
|
|
178
|
+
Switch to cursor-based:
|
|
179
|
+
|
|
180
|
+
```diff
|
|
181
|
+
- const nextPage = page + 1
|
|
182
|
+
- fetch(`/api/v1/users?page=${nextPage}`)
|
|
183
|
+
+ const cursor = data.meta.next_cursor
|
|
184
|
+
+ fetch(`/api/v2/users?cursor=${cursor}`)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Testing Your Migration
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# 1. Test v2 in development
|
|
191
|
+
curl -H "Authorization: Bearer xxx" https://dev-api.example.com/v2/users
|
|
192
|
+
|
|
193
|
+
# 2. Run v1 and v2 side-by-side in staging
|
|
194
|
+
# Compare responses for consistency
|
|
195
|
+
|
|
196
|
+
# 3. Gradual rollout in production
|
|
197
|
+
# Route 10% → 50% → 100% traffic to v2
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Support Resources
|
|
201
|
+
|
|
202
|
+
- [API v2 Documentation](https://docs.example.com/v2)
|
|
203
|
+
- [Migration Examples Repo](https://github.com/example/v2-examples)
|
|
204
|
+
- [Support Channel](https://slack.example.com)
|
|
205
|
+
|
|
206
|
+
````
|
|
207
|
+
|
|
208
|
+
## Backward Compatibility Strategies
|
|
209
|
+
|
|
210
|
+
### 1. Parallel Versions
|
|
211
|
+
Run v1 and v2 simultaneously:
|
|
212
|
+
```typescript
|
|
213
|
+
app.use('/api/v1', v1Router);
|
|
214
|
+
app.use('/api/v2', v2Router);
|
|
215
|
+
````
|
|
216
|
+
|
|
217
|
+
### 2. Adapter Pattern
|
|
218
|
+
|
|
219
|
+
v1 calls v2 internally with adapter:
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
// v1 endpoint
|
|
223
|
+
router.get("/api/v1/users", async (req, res) => {
|
|
224
|
+
// Call v2
|
|
225
|
+
const v2Response = await v2Controller.getUsers(req);
|
|
226
|
+
|
|
227
|
+
// Adapt v2 response to v1 format
|
|
228
|
+
const v1Response = adaptV2ToV1(v2Response);
|
|
229
|
+
|
|
230
|
+
res.json(v1Response);
|
|
231
|
+
});
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### 3. Feature Flags
|
|
235
|
+
|
|
236
|
+
Gradual feature rollout:
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
if (req.version === "v2" && featureFlags.newPagination) {
|
|
240
|
+
return cursorBasedPagination(req);
|
|
241
|
+
} else {
|
|
242
|
+
return pageBasedPagination(req);
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
## Client Communication Plan
|
|
247
|
+
|
|
248
|
+
### Announcement Email Template
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
Subject: [ACTION REQUIRED] API v1 Deprecation - Migrate by Dec 31
|
|
252
|
+
|
|
253
|
+
Hi API Consumers,
|
|
254
|
+
|
|
255
|
+
We're deprecating API v1 on December 31, 2024. Please migrate to v2.
|
|
256
|
+
|
|
257
|
+
What's changing:
|
|
258
|
+
- Authentication: API keys → Bearer tokens
|
|
259
|
+
- Response format: snake_case → camelCase
|
|
260
|
+
- Pagination: page-based → cursor-based
|
|
261
|
+
|
|
262
|
+
Migration resources:
|
|
263
|
+
- Guide: https://docs.example.com/migration
|
|
264
|
+
- Examples: https://github.com/example/v2-examples
|
|
265
|
+
- Support: api-support@example.com
|
|
266
|
+
|
|
267
|
+
Timeline:
|
|
268
|
+
- Now: v2 available, v1 still works
|
|
269
|
+
- Oct 31: v1 will show deprecation warnings
|
|
270
|
+
- Dec 31: v1 will be shut down
|
|
271
|
+
|
|
272
|
+
Questions? Reply to this email.
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Monitoring Migration Progress
|
|
276
|
+
|
|
277
|
+
```typescript
|
|
278
|
+
// Track version usage
|
|
279
|
+
app.use((req, res, next) => {
|
|
280
|
+
const version = req.path.includes('/v1') ? 'v1' : 'v2';
|
|
281
|
+
metrics.increment('api.requests', { version });
|
|
282
|
+
next();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Dashboard metrics
|
|
286
|
+
- v1 requests/day: 10,000 → 5,000 → 1,000 → 0
|
|
287
|
+
- v2 requests/day: 0 → 5,000 → 9,000 → 10,000
|
|
288
|
+
- Unique v1 consumers: 50 → 25 → 5 → 0
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
## Rollback Plan
|
|
292
|
+
|
|
293
|
+
```markdown
|
|
294
|
+
## If Migration Goes Wrong
|
|
295
|
+
|
|
296
|
+
### Symptoms
|
|
297
|
+
|
|
298
|
+
- Spike in 5xx errors
|
|
299
|
+
- Client complaints
|
|
300
|
+
- Revenue impact
|
|
301
|
+
|
|
302
|
+
### Rollback Steps
|
|
303
|
+
|
|
304
|
+
1. Re-enable v1 endpoints
|
|
305
|
+
2. Update deprecation timeline
|
|
306
|
+
3. Communicate delay to clients
|
|
307
|
+
4. Fix issues in v2
|
|
308
|
+
5. Resume migration when stable
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Best Practices
|
|
312
|
+
|
|
313
|
+
1. **Announce early**: 6+ months notice
|
|
314
|
+
2. **Provide tools**: SDKs, migration scripts
|
|
315
|
+
3. **Support clients**: 1-on-1 help if needed
|
|
316
|
+
4. **Monitor usage**: Track who's still on v1
|
|
317
|
+
5. **Gradual sunset**: Don't surprise users
|
|
318
|
+
6. **Clear docs**: Step-by-step guides
|
|
319
|
+
7. **Offer grace period**: Extensions for large clients
|
|
320
|
+
|
|
321
|
+
## Output Checklist
|
|
322
|
+
|
|
323
|
+
- [ ] Versioning strategy chosen
|
|
324
|
+
- [ ] Deprecation timeline (6+ months)
|
|
325
|
+
- [ ] Migration guide written
|
|
326
|
+
- [ ] Breaking changes documented
|
|
327
|
+
- [ ] Backward compatibility plan
|
|
328
|
+
- [ ] Client communication drafted
|
|
329
|
+
- [ ] Monitoring dashboard setup
|
|
330
|
+
- [ ] Rollback plan documented
|
|
331
|
+
- [ ] Support resources prepared
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: domain-model-boundaries-mapper
|
|
3
|
+
description: Identifies domain modules, ownership boundaries, dependencies, and interfaces using Domain-Driven Design principles. Provides domain maps, bounded contexts, refactor recommendations. Use for "DDD", "domain modeling", "bounded contexts", or "service boundaries".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Domain Model & Boundaries Mapper
|
|
7
|
+
|
|
8
|
+
Map domain boundaries and ownership using Domain-Driven Design.
|
|
9
|
+
|
|
10
|
+
## Domain Map Template
|
|
11
|
+
|
|
12
|
+
```markdown
|
|
13
|
+
# Domain Map: E-Commerce Platform
|
|
14
|
+
|
|
15
|
+
## Bounded Contexts
|
|
16
|
+
|
|
17
|
+
### 1. Customer Management
|
|
18
|
+
|
|
19
|
+
**Core Domain:** User accounts, profiles, preferences
|
|
20
|
+
**Owner:** Customer Team
|
|
21
|
+
**Ubiquitous Language:**
|
|
22
|
+
|
|
23
|
+
- Customer: Registered user with account
|
|
24
|
+
- Profile: Customer personal information
|
|
25
|
+
- Preferences: User settings and choices
|
|
26
|
+
|
|
27
|
+
**Entities:**
|
|
28
|
+
|
|
29
|
+
- Customer (id, email, name)
|
|
30
|
+
- Address (id, customer_id, street, city)
|
|
31
|
+
- PaymentMethod (id, customer_id, type, token)
|
|
32
|
+
|
|
33
|
+
**Bounded Context Diagram:**
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
┌─────────────────────────────┐
|
|
37
|
+
│ Customer Management │
|
|
38
|
+
│ ┌─────────┐ ┌──────────┐ │
|
|
39
|
+
│ │Customer │ │ Address │ │
|
|
40
|
+
│ └─────────┘ └──────────┘ │
|
|
41
|
+
│ ┌─────────────────────┐ │
|
|
42
|
+
│ │ Payment Method │ │
|
|
43
|
+
│ └─────────────────────┘ │
|
|
44
|
+
└─────────────────────────────┘
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 2. Order Management
|
|
49
|
+
**Core Domain:** Order processing, fulfillment
|
|
50
|
+
**Owner:** Orders Team
|
|
51
|
+
**Ubiquitous Language:**
|
|
52
|
+
- Order: Purchase request with line items
|
|
53
|
+
- LineItem: Product quantity in order
|
|
54
|
+
- Fulfillment: Physical delivery of order
|
|
55
|
+
|
|
56
|
+
**Entities:**
|
|
57
|
+
- Order (id, customer_id, status, total)
|
|
58
|
+
- LineItem (id, order_id, product_id, quantity)
|
|
59
|
+
- Shipment (id, order_id, tracking_number)
|
|
60
|
+
|
|
61
|
+
### 3. Product Catalog
|
|
62
|
+
**Core Domain:** Product information, inventory
|
|
63
|
+
**Owner:** Catalog Team
|
|
64
|
+
**Ubiquitous Language:**
|
|
65
|
+
- Product: Sellable item
|
|
66
|
+
- SKU: Stock keeping unit
|
|
67
|
+
- Inventory: Available stock
|
|
68
|
+
|
|
69
|
+
**Entities:**
|
|
70
|
+
- Product (id, name, price, description)
|
|
71
|
+
- Inventory (sku, quantity, warehouse_id)
|
|
72
|
+
|
|
73
|
+
## Context Relationships
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Customer Management ──────▶ Order Management
|
|
78
|
+
(customer_id)
|
|
79
|
+
|
|
80
|
+
Product Catalog ──────▶ Order Management
|
|
81
|
+
(product_id)
|
|
82
|
+
|
|
83
|
+
Order Management ──────▶ Fulfillment
|
|
84
|
+
(order events)
|
|
85
|
+
|
|
86
|
+
````
|
|
87
|
+
|
|
88
|
+
## Anti-Corruption Layers
|
|
89
|
+
|
|
90
|
+
### Order Management → Customer Management
|
|
91
|
+
**Problem:** Orders need customer data but shouldn't depend on Customer domain model
|
|
92
|
+
|
|
93
|
+
**Solution:** Customer Adapter
|
|
94
|
+
```typescript
|
|
95
|
+
// Order domain's view of customer
|
|
96
|
+
interface CustomerForOrder {
|
|
97
|
+
id: string;
|
|
98
|
+
shippingAddress: Address;
|
|
99
|
+
billingAddress: Address;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Adapter translates Customer domain to Order domain
|
|
103
|
+
class CustomerAdapter {
|
|
104
|
+
async getCustomerForOrder(customerId: string): Promise<CustomerForOrder> {
|
|
105
|
+
const customer = await customerService.getCustomer(customerId);
|
|
106
|
+
return {
|
|
107
|
+
id: customer.id,
|
|
108
|
+
shippingAddress: this.toOrderAddress(customer.defaultShippingAddress),
|
|
109
|
+
billingAddress: this.toOrderAddress(customer.defaultBillingAddress),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
````
|
|
114
|
+
|
|
115
|
+
## Dependency Map
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
┌──────────────┐
|
|
119
|
+
│ Customer │
|
|
120
|
+
└──────┬───────┘
|
|
121
|
+
│
|
|
122
|
+
▼
|
|
123
|
+
┌──────────────┐ ┌────────────┐
|
|
124
|
+
│ Orders │─────▶│ Products │
|
|
125
|
+
└──────┬───────┘ └────────────┘
|
|
126
|
+
│
|
|
127
|
+
▼
|
|
128
|
+
┌──────────────┐
|
|
129
|
+
│ Fulfillment │
|
|
130
|
+
└──────────────┘
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Dependency Rules:**
|
|
134
|
+
|
|
135
|
+
- Customer has no dependencies
|
|
136
|
+
- Orders depends on Customer (read) and Products (read)
|
|
137
|
+
- Fulfillment depends on Orders (events)
|
|
138
|
+
|
|
139
|
+
## Interface Contracts
|
|
140
|
+
|
|
141
|
+
### Customer Management → Orders
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// Public interface exposed by Customer domain
|
|
145
|
+
interface CustomerService {
|
|
146
|
+
getCustomer(id: string): Promise<Customer>;
|
|
147
|
+
getCustomerAddresses(id: string): Promise<Address[]>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Events published
|
|
151
|
+
interface CustomerUpdated {
|
|
152
|
+
customerId: string;
|
|
153
|
+
email: string;
|
|
154
|
+
name: string;
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Product Catalog → Orders
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
interface ProductService {
|
|
162
|
+
getProduct(id: string): Promise<Product>;
|
|
163
|
+
checkAvailability(sku: string, quantity: number): Promise<boolean>;
|
|
164
|
+
reserveInventory(items: ReservationRequest[]): Promise<Reservation>;
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Refactor Recommendations
|
|
169
|
+
|
|
170
|
+
### Problem 1: Tight Coupling
|
|
171
|
+
|
|
172
|
+
**Current:** Orders directly queries Customer database
|
|
173
|
+
**Issue:** Breaks bounded context, creates coupling
|
|
174
|
+
**Recommendation:** Use Customer API instead
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
// ❌ Before: Direct database access
|
|
178
|
+
const customer = await db.customers.findById(customerId);
|
|
179
|
+
|
|
180
|
+
// ✅ After: API call through adapter
|
|
181
|
+
const customer = await customerAdapter.getCustomerForOrder(customerId);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Problem 2: Shared Models
|
|
185
|
+
|
|
186
|
+
**Current:** Same `User` model used across contexts
|
|
187
|
+
**Issue:** Changes in one context affect others
|
|
188
|
+
**Recommendation:** Separate models per context
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// Customer context
|
|
192
|
+
interface Customer {
|
|
193
|
+
id: string;
|
|
194
|
+
email: string;
|
|
195
|
+
profile: CustomerProfile;
|
|
196
|
+
preferences: CustomerPreferences;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Order context (different model!)
|
|
200
|
+
interface OrderCustomer {
|
|
201
|
+
id: string;
|
|
202
|
+
shippingAddress: Address;
|
|
203
|
+
billingAddress: Address;
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Problem 3: God Service
|
|
208
|
+
|
|
209
|
+
**Current:** `OrderService` handles orders, inventory, payments, shipping
|
|
210
|
+
**Issue:** Single service owns too much
|
|
211
|
+
**Recommendation:** Extract bounded contexts
|
|
212
|
+
|
|
213
|
+
- OrderService: Order lifecycle
|
|
214
|
+
- InventoryService: Stock management
|
|
215
|
+
- PaymentService: Payment processing
|
|
216
|
+
- FulfillmentService: Shipping
|
|
217
|
+
|
|
218
|
+
## Strategic Design Patterns
|
|
219
|
+
|
|
220
|
+
### Pattern 1: Shared Kernel
|
|
221
|
+
|
|
222
|
+
**When:** Two contexts must share some code
|
|
223
|
+
**Example:** Common value objects (Money, Address)
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
// Shared kernel (minimal!)
|
|
227
|
+
class Money {
|
|
228
|
+
constructor(public amount: number, public currency: string) {}
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Pattern 2: Customer/Supplier
|
|
233
|
+
|
|
234
|
+
**When:** One context depends on another
|
|
235
|
+
**Example:** Orders (customer) depends on Products (supplier)
|
|
236
|
+
|
|
237
|
+
- Supplier defines interface
|
|
238
|
+
- Customer adapts to their needs
|
|
239
|
+
|
|
240
|
+
### Pattern 3: Published Language
|
|
241
|
+
|
|
242
|
+
**When:** Many contexts need same data
|
|
243
|
+
**Example:** Product events
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
interface ProductCreated {
|
|
247
|
+
productId: string;
|
|
248
|
+
name: string;
|
|
249
|
+
price: Money;
|
|
250
|
+
publishedAt: Date;
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## Migration Strategy
|
|
255
|
+
|
|
256
|
+
### Phase 1: Identify Boundaries
|
|
257
|
+
|
|
258
|
+
- [ ] Map existing code to domains
|
|
259
|
+
- [ ] Identify coupling points
|
|
260
|
+
- [ ] Document dependencies
|
|
261
|
+
|
|
262
|
+
### Phase 2: Define Interfaces
|
|
263
|
+
|
|
264
|
+
- [ ] Design APIs between contexts
|
|
265
|
+
- [ ] Create adapter layers
|
|
266
|
+
- [ ] Define event contracts
|
|
267
|
+
|
|
268
|
+
### Phase 3: Decouple
|
|
269
|
+
|
|
270
|
+
- [ ] Replace direct DB access with APIs
|
|
271
|
+
- [ ] Introduce anti-corruption layers
|
|
272
|
+
- [ ] Separate models per context
|
|
273
|
+
|
|
274
|
+
### Phase 4: Extract Services (optional)
|
|
275
|
+
|
|
276
|
+
- [ ] Move contexts to separate services
|
|
277
|
+
- [ ] Implement API gateways
|
|
278
|
+
- [ ] Set up event bus
|
|
279
|
+
|
|
280
|
+
## Best Practices
|
|
281
|
+
|
|
282
|
+
1. **Ubiquitous language**: Same terms in code and domain
|
|
283
|
+
2. **Bounded contexts**: Clear boundaries, separate models
|
|
284
|
+
3. **Context maps**: Document relationships
|
|
285
|
+
4. **Anti-corruption layers**: Protect domain integrity
|
|
286
|
+
5. **Event-driven**: Loose coupling via events
|
|
287
|
+
6. **Separate databases**: Context owns its data
|
|
288
|
+
|
|
289
|
+
## Output Checklist
|
|
290
|
+
|
|
291
|
+
- [ ] Bounded contexts identified (3-7)
|
|
292
|
+
- [ ] Core domain vs supporting domains
|
|
293
|
+
- [ ] Ubiquitous language defined per context
|
|
294
|
+
- [ ] Entity/aggregate definitions
|
|
295
|
+
- [ ] Context relationship diagram
|
|
296
|
+
- [ ] Dependency map
|
|
297
|
+
- [ ] Interface contracts defined
|
|
298
|
+
- [ ] Anti-corruption layers designed
|
|
299
|
+
- [ ] Refactor recommendations
|
|
300
|
+
- [ ] Migration strategy
|