@booklib/skills 1.0.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/LICENSE +21 -0
- package/README.md +105 -0
- package/animation-at-work/SKILL.md +246 -0
- package/animation-at-work/assets/example_asset.txt +1 -0
- package/animation-at-work/references/api_reference.md +369 -0
- package/animation-at-work/references/review-checklist.md +79 -0
- package/animation-at-work/scripts/example.py +1 -0
- package/bin/skills.js +85 -0
- package/clean-code-reviewer/SKILL.md +292 -0
- package/clean-code-reviewer/evals/evals.json +67 -0
- package/data-intensive-patterns/SKILL.md +204 -0
- package/data-intensive-patterns/assets/example_asset.txt +1 -0
- package/data-intensive-patterns/references/api_reference.md +34 -0
- package/data-intensive-patterns/references/patterns-catalog.md +551 -0
- package/data-intensive-patterns/references/review-checklist.md +193 -0
- package/data-intensive-patterns/scripts/example.py +1 -0
- package/data-pipelines/SKILL.md +252 -0
- package/data-pipelines/assets/example_asset.txt +1 -0
- package/data-pipelines/references/api_reference.md +301 -0
- package/data-pipelines/references/review-checklist.md +181 -0
- package/data-pipelines/scripts/example.py +1 -0
- package/design-patterns/SKILL.md +245 -0
- package/design-patterns/assets/example_asset.txt +1 -0
- package/design-patterns/references/api_reference.md +1 -0
- package/design-patterns/references/patterns-catalog.md +726 -0
- package/design-patterns/references/review-checklist.md +173 -0
- package/design-patterns/scripts/example.py +1 -0
- package/domain-driven-design/SKILL.md +221 -0
- package/domain-driven-design/assets/example_asset.txt +1 -0
- package/domain-driven-design/references/api_reference.md +1 -0
- package/domain-driven-design/references/patterns-catalog.md +545 -0
- package/domain-driven-design/references/review-checklist.md +158 -0
- package/domain-driven-design/scripts/example.py +1 -0
- package/effective-java/SKILL.md +195 -0
- package/effective-java/assets/example_asset.txt +1 -0
- package/effective-java/references/api_reference.md +1 -0
- package/effective-java/references/items-catalog.md +955 -0
- package/effective-java/references/review-checklist.md +216 -0
- package/effective-java/scripts/example.py +1 -0
- package/effective-kotlin/SKILL.md +225 -0
- package/effective-kotlin/assets/example_asset.txt +1 -0
- package/effective-kotlin/references/api_reference.md +1 -0
- package/effective-kotlin/references/practices-catalog.md +1228 -0
- package/effective-kotlin/references/review-checklist.md +126 -0
- package/effective-kotlin/scripts/example.py +1 -0
- package/kotlin-in-action/SKILL.md +251 -0
- package/kotlin-in-action/assets/example_asset.txt +1 -0
- package/kotlin-in-action/references/api_reference.md +1 -0
- package/kotlin-in-action/references/practices-catalog.md +436 -0
- package/kotlin-in-action/references/review-checklist.md +204 -0
- package/kotlin-in-action/scripts/example.py +1 -0
- package/lean-startup/SKILL.md +250 -0
- package/lean-startup/assets/example_asset.txt +1 -0
- package/lean-startup/references/api_reference.md +319 -0
- package/lean-startup/references/review-checklist.md +137 -0
- package/lean-startup/scripts/example.py +1 -0
- package/microservices-patterns/SKILL.md +179 -0
- package/microservices-patterns/references/patterns-catalog.md +391 -0
- package/microservices-patterns/references/review-checklist.md +169 -0
- package/package.json +17 -0
- package/refactoring-ui/SKILL.md +236 -0
- package/refactoring-ui/assets/example_asset.txt +1 -0
- package/refactoring-ui/references/api_reference.md +355 -0
- package/refactoring-ui/references/review-checklist.md +114 -0
- package/refactoring-ui/scripts/example.py +1 -0
- package/storytelling-with-data/SKILL.md +238 -0
- package/storytelling-with-data/assets/example_asset.txt +1 -0
- package/storytelling-with-data/references/api_reference.md +379 -0
- package/storytelling-with-data/references/review-checklist.md +111 -0
- package/storytelling-with-data/scripts/example.py +1 -0
- package/system-design-interview/SKILL.md +213 -0
- package/system-design-interview/assets/example_asset.txt +1 -0
- package/system-design-interview/references/api_reference.md +582 -0
- package/system-design-interview/references/review-checklist.md +201 -0
- package/system-design-interview/scripts/example.py +1 -0
- package/using-asyncio-python/SKILL.md +242 -0
- package/using-asyncio-python/assets/example_asset.txt +1 -0
- package/using-asyncio-python/references/api_reference.md +267 -0
- package/using-asyncio-python/references/review-checklist.md +149 -0
- package/using-asyncio-python/scripts/example.py +1 -0
- package/web-scraping-python/SKILL.md +259 -0
- package/web-scraping-python/assets/example_asset.txt +1 -0
- package/web-scraping-python/references/api_reference.md +393 -0
- package/web-scraping-python/references/review-checklist.md +163 -0
- package/web-scraping-python/scripts/example.py +1 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
# Microservices Patterns Catalog
|
|
2
|
+
|
|
3
|
+
Comprehensive reference of patterns from Chris Richardson's *Microservices Patterns*.
|
|
4
|
+
Organized by problem category. Read the section relevant to the code you're generating.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
1. [Decomposition Patterns](#decomposition-patterns)
|
|
11
|
+
2. [Communication Patterns](#communication-patterns)
|
|
12
|
+
3. [API Gateway Patterns](#api-gateway-patterns)
|
|
13
|
+
4. [Transaction Management — Sagas](#transaction-management--sagas)
|
|
14
|
+
5. [Business Logic Patterns](#business-logic-patterns)
|
|
15
|
+
6. [Event Sourcing](#event-sourcing)
|
|
16
|
+
7. [Query Patterns](#query-patterns)
|
|
17
|
+
8. [Testing Patterns](#testing-patterns)
|
|
18
|
+
9. [Deployment Patterns](#deployment-patterns)
|
|
19
|
+
10. [Observability Patterns](#observability-patterns)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Decomposition Patterns
|
|
24
|
+
|
|
25
|
+
### Decompose by Business Capability
|
|
26
|
+
|
|
27
|
+
Map services to what the organization *does*. Business capabilities are stable
|
|
28
|
+
over time even as org structure changes.
|
|
29
|
+
|
|
30
|
+
- Identify top-level capabilities (Order Management, Delivery, Billing, etc.)
|
|
31
|
+
- Each capability becomes a candidate service
|
|
32
|
+
- Services own the data for their capability
|
|
33
|
+
|
|
34
|
+
**When to use**: Starting a new microservices project or breaking up a monolith.
|
|
35
|
+
|
|
36
|
+
### Decompose by Subdomain (DDD)
|
|
37
|
+
|
|
38
|
+
Use Domain-Driven Design to identify bounded contexts. Each bounded context
|
|
39
|
+
becomes a service.
|
|
40
|
+
|
|
41
|
+
- Core subdomains: the competitive advantage (invest the most here)
|
|
42
|
+
- Supporting subdomains: necessary but not differentiating
|
|
43
|
+
- Generic subdomains: solved problems (use off-the-shelf solutions)
|
|
44
|
+
|
|
45
|
+
**When to use**: Complex domain where business capability mapping isn't granular enough.
|
|
46
|
+
|
|
47
|
+
### Strangler Fig Pattern
|
|
48
|
+
|
|
49
|
+
Incrementally migrate from monolith to microservices by building new functionality
|
|
50
|
+
as services and gradually routing traffic away from the monolith.
|
|
51
|
+
|
|
52
|
+
- Stand up new service alongside monolith
|
|
53
|
+
- Route specific requests to new service
|
|
54
|
+
- Gradually migrate functionality
|
|
55
|
+
- Eventually decommission monolith component
|
|
56
|
+
|
|
57
|
+
**When to use**: Migrating an existing monolith without a big-bang rewrite.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Communication Patterns
|
|
62
|
+
|
|
63
|
+
### Synchronous — REST
|
|
64
|
+
|
|
65
|
+
- Use for simple request/response interactions
|
|
66
|
+
- Design APIs using the Richardson Maturity Model (ideally Level 2+)
|
|
67
|
+
- Define IDL: OpenAPI/Swagger for REST
|
|
68
|
+
- Handle partial failure: timeouts, retries, circuit breakers
|
|
69
|
+
|
|
70
|
+
### Synchronous — gRPC
|
|
71
|
+
|
|
72
|
+
- Binary protocol, strongly typed via Protocol Buffers
|
|
73
|
+
- More efficient than REST for inter-service calls
|
|
74
|
+
- Supports streaming (server, client, bidirectional)
|
|
75
|
+
- Good for polyglot environments (code generation for many languages)
|
|
76
|
+
|
|
77
|
+
### Asynchronous — Messaging
|
|
78
|
+
|
|
79
|
+
- Services communicate via message broker (Kafka, RabbitMQ, etc.)
|
|
80
|
+
- Message types: **Document** (carries data), **Command** (request action), **Event** (notification of change)
|
|
81
|
+
- Channels: **Point-to-point** (one consumer) or **Publish-subscribe** (many consumers)
|
|
82
|
+
|
|
83
|
+
Key implementation concerns:
|
|
84
|
+
|
|
85
|
+
- **Message ordering**: Use partitioned channels (e.g., Kafka partitions keyed by aggregate ID)
|
|
86
|
+
- **Duplicate handling**: Make consumers idempotent (track processed message IDs, or make operations naturally idempotent)
|
|
87
|
+
- **Transactional outbox**: Write events to an OUTBOX table in the same transaction as business data, then relay to broker — ensures atomicity without distributed transactions
|
|
88
|
+
- **Polling publisher or Transaction log tailing**: Two strategies for relaying outbox messages to the broker
|
|
89
|
+
|
|
90
|
+
### Circuit Breaker
|
|
91
|
+
|
|
92
|
+
Wrap remote calls in a circuit breaker to handle downstream failures gracefully:
|
|
93
|
+
|
|
94
|
+
- **Closed**: Requests pass through normally
|
|
95
|
+
- **Open**: Requests fail immediately (after failure threshold exceeded)
|
|
96
|
+
- **Half-open**: Periodically try a request; if it succeeds, close the circuit
|
|
97
|
+
|
|
98
|
+
Use libraries like Resilience4j (Java) or Polly (.NET).
|
|
99
|
+
|
|
100
|
+
### Service Discovery
|
|
101
|
+
|
|
102
|
+
Services need to locate each other. Two approaches:
|
|
103
|
+
|
|
104
|
+
- **Client-side discovery**: Client queries a registry (e.g., Eureka) and load-balances
|
|
105
|
+
- **Server-side discovery**: Client calls a router/load balancer that queries the registry (e.g., Kubernetes services, AWS ELB)
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## API Gateway Patterns
|
|
110
|
+
|
|
111
|
+
### API Gateway
|
|
112
|
+
|
|
113
|
+
Single entry point for external clients. Responsibilities:
|
|
114
|
+
|
|
115
|
+
- Request routing to appropriate microservice
|
|
116
|
+
- API composition (aggregate responses from multiple services)
|
|
117
|
+
- Protocol translation (external REST to internal gRPC/messaging)
|
|
118
|
+
- Authentication and rate limiting
|
|
119
|
+
- Edge functions (caching, monitoring, etc.)
|
|
120
|
+
|
|
121
|
+
### Backend for Frontend (BFF)
|
|
122
|
+
|
|
123
|
+
Separate API gateway per client type (web, mobile, third-party). Each BFF:
|
|
124
|
+
|
|
125
|
+
- Tailors the API to its client's needs
|
|
126
|
+
- Handles client-specific data aggregation
|
|
127
|
+
- Is owned by the client team
|
|
128
|
+
- Reduces coupling between client and backend service evolution
|
|
129
|
+
|
|
130
|
+
**When to use BFF over single gateway**: When different clients have significantly different API needs.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Transaction Management — Sagas
|
|
135
|
+
|
|
136
|
+
### The Problem
|
|
137
|
+
|
|
138
|
+
Microservices use Database per Service, so you cannot use ACID transactions
|
|
139
|
+
across services. Sagas maintain data consistency using a sequence of local
|
|
140
|
+
transactions with compensating transactions for rollback.
|
|
141
|
+
|
|
142
|
+
### Choreography-based Saga
|
|
143
|
+
|
|
144
|
+
Services publish events and subscribe to each other's events:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
OrderService -> OrderCreated event
|
|
148
|
+
-> PaymentService listens, processes payment, publishes PaymentAuthorized
|
|
149
|
+
-> KitchenService listens, creates ticket, publishes TicketCreated
|
|
150
|
+
-> OrderService listens, approves order
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- Pros: Simple, no central coordinator, loose coupling
|
|
154
|
+
- Cons: Hard to understand the flow, cyclic dependencies possible
|
|
155
|
+
|
|
156
|
+
### Orchestration-based Saga
|
|
157
|
+
|
|
158
|
+
A central saga orchestrator tells participants what to do:
|
|
159
|
+
|
|
160
|
+
```
|
|
161
|
+
CreateOrderSaga:
|
|
162
|
+
1. OrderService.createOrder(PENDING)
|
|
163
|
+
2. PaymentService.authorize() -> fail? -> OrderService.rejectOrder()
|
|
164
|
+
3. KitchenService.createTicket() -> fail? -> PaymentService.reverseAuth(), OrderService.rejectOrder()
|
|
165
|
+
4. OrderService.approveOrder()
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
- Pros: Clear flow, easy to understand, avoids cyclic dependencies
|
|
169
|
+
- Cons: Risk of centralizing too much logic in orchestrator
|
|
170
|
+
|
|
171
|
+
### Saga Design Rules
|
|
172
|
+
|
|
173
|
+
- Each saga step modifies one aggregate in one service
|
|
174
|
+
- Every forward step needs a compensating transaction (undo/rollback action)
|
|
175
|
+
- Compensating transactions must be idempotent (safe to retry)
|
|
176
|
+
- Use semantic locks — mark records as "pending" during saga execution
|
|
177
|
+
- Countermeasures for lack of isolation: semantic locks, commutative updates, pessimistic/optimistic views, re-reading values
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
181
|
+
## Business Logic Patterns
|
|
182
|
+
|
|
183
|
+
### Aggregate Pattern (DDD)
|
|
184
|
+
|
|
185
|
+
An aggregate is a cluster of domain objects treated as a unit for data changes.
|
|
186
|
+
|
|
187
|
+
- **Aggregate root**: Top-level entity through which all external access occurs
|
|
188
|
+
- **Invariants**: Business rules enforced within the aggregate
|
|
189
|
+
- **Transaction boundary**: One transaction = one aggregate update
|
|
190
|
+
- **References between aggregates**: Use IDs, not object references
|
|
191
|
+
|
|
192
|
+
Design rules:
|
|
193
|
+
- Keep aggregates small — reference other aggregates by identity
|
|
194
|
+
- Business logic lives in the aggregate, not in service classes
|
|
195
|
+
- Aggregates publish domain events when their state changes
|
|
196
|
+
|
|
197
|
+
### Domain Events
|
|
198
|
+
|
|
199
|
+
Events represent something meaningful that happened in the domain:
|
|
200
|
+
|
|
201
|
+
- Named in past tense: OrderCreated, PaymentAuthorized, TicketAccepted
|
|
202
|
+
- Contain relevant data (IDs, state at time of event)
|
|
203
|
+
- Published by aggregates after state changes
|
|
204
|
+
- Consumed by other services for integration
|
|
205
|
+
|
|
206
|
+
### Domain Event Publishing
|
|
207
|
+
|
|
208
|
+
Two approaches to reliably publish events:
|
|
209
|
+
|
|
210
|
+
1. **Transactional outbox**: Store events in an outbox table in the same DB transaction as business data, then asynchronously publish to message broker
|
|
211
|
+
2. **Event sourcing**: Events are the primary store (see below)
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Event Sourcing
|
|
216
|
+
|
|
217
|
+
Instead of storing current state, store a sequence of state-changing events.
|
|
218
|
+
Reconstruct current state by replaying events.
|
|
219
|
+
|
|
220
|
+
### How It Works
|
|
221
|
+
|
|
222
|
+
- Each aggregate stored as a sequence of events in an event store
|
|
223
|
+
- To load: fetch all events, replay to reconstruct state
|
|
224
|
+
- To save: append new events to the store
|
|
225
|
+
- Event store is append-only (never update, never delete)
|
|
226
|
+
|
|
227
|
+
### Benefits
|
|
228
|
+
|
|
229
|
+
- Reliable event publishing (events ARE the data — no outbox needed)
|
|
230
|
+
- Complete audit trail
|
|
231
|
+
- Temporal queries (reconstruct state at any point in time)
|
|
232
|
+
- Enables CQRS naturally
|
|
233
|
+
|
|
234
|
+
### Challenges
|
|
235
|
+
|
|
236
|
+
- Learning curve; different way of thinking
|
|
237
|
+
- Querying the event store is hard (need CQRS for queries)
|
|
238
|
+
- Event schema evolution — events are immutable, so versioning matters
|
|
239
|
+
- Deleting data (e.g., GDPR) requires special handling like encryption with deletable keys
|
|
240
|
+
|
|
241
|
+
### Snapshots
|
|
242
|
+
|
|
243
|
+
For aggregates with many events, periodically save a snapshot of current state
|
|
244
|
+
to avoid replaying the entire history. Load: last snapshot + events after snapshot.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Query Patterns
|
|
249
|
+
|
|
250
|
+
### API Composition
|
|
251
|
+
|
|
252
|
+
For queries spanning multiple services, an API composer calls each service
|
|
253
|
+
and combines results in memory.
|
|
254
|
+
|
|
255
|
+
```
|
|
256
|
+
API Composer (or API Gateway):
|
|
257
|
+
1. Call OrderService.getOrders(customerId)
|
|
258
|
+
2. Call DeliveryService.getDeliveries(orderIds)
|
|
259
|
+
3. Call RestaurantService.getRestaurants(restaurantIds)
|
|
260
|
+
4. Join results in memory, return to client
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
- Pros: Simple to implement
|
|
264
|
+
- Cons: Increased latency, no efficient join/filter across services, reduced availability
|
|
265
|
+
|
|
266
|
+
**When to use**: Simple queries where data from 2-3 services needs combining.
|
|
267
|
+
|
|
268
|
+
### CQRS (Command Query Responsibility Segregation)
|
|
269
|
+
|
|
270
|
+
Separate the write model (commands) from the read model (queries):
|
|
271
|
+
|
|
272
|
+
- **Command side**: Services handle commands, publish domain events
|
|
273
|
+
- **Query side**: A separate view service subscribes to events and maintains denormalized read-optimized database
|
|
274
|
+
|
|
275
|
+
```
|
|
276
|
+
OrderService publishes OrderCreated ->
|
|
277
|
+
DeliveryService publishes DeliveryStatusUpdated ->
|
|
278
|
+
OrderHistoryViewService subscribes to both,
|
|
279
|
+
maintains denormalized OrderHistoryView table,
|
|
280
|
+
serves GET /order-history queries
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
- Pros: Efficient queries, scales reads independently, supports complex cross-service queries
|
|
284
|
+
- Cons: Extra complexity, eventual consistency, additional infrastructure
|
|
285
|
+
|
|
286
|
+
**When to use**: Complex queries spanning many services, or when read performance is critical.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Testing Patterns
|
|
291
|
+
|
|
292
|
+
### Consumer-Driven Contract Testing
|
|
293
|
+
|
|
294
|
+
Each consumer defines a contract: "I expect your API to behave like X."
|
|
295
|
+
Provider runs these contracts as tests to ensure compatibility.
|
|
296
|
+
|
|
297
|
+
- Tools: Spring Cloud Contract, Pact
|
|
298
|
+
- Catches breaking changes before deployment
|
|
299
|
+
|
|
300
|
+
### Service Component Testing
|
|
301
|
+
|
|
302
|
+
Test a service in isolation by stubbing its dependencies:
|
|
303
|
+
|
|
304
|
+
- In-memory stubs for downstream services
|
|
305
|
+
- In-memory or containerized database
|
|
306
|
+
- Verify behavior end-to-end through the service's API
|
|
307
|
+
|
|
308
|
+
### Integration Testing
|
|
309
|
+
|
|
310
|
+
Test interaction between a service and its infrastructure:
|
|
311
|
+
|
|
312
|
+
- Database integration tests (verify SQL, schema migrations)
|
|
313
|
+
- Messaging integration tests (verify event publishing/consuming)
|
|
314
|
+
- REST client integration tests (verify HTTP calls)
|
|
315
|
+
- Use Docker (Testcontainers) for realistic infrastructure
|
|
316
|
+
|
|
317
|
+
### Testing Pyramid for Microservices
|
|
318
|
+
|
|
319
|
+
From bottom (fast, many) to top (slow, few):
|
|
320
|
+
|
|
321
|
+
1. Unit tests — domain logic, aggregates, sagas
|
|
322
|
+
2. Integration tests — persistence, messaging, REST clients
|
|
323
|
+
3. Component tests — single service end-to-end with stubs
|
|
324
|
+
4. Contract tests — API compatibility between consumer and provider
|
|
325
|
+
5. End-to-end tests — full system (keep these minimal)
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Deployment Patterns
|
|
330
|
+
|
|
331
|
+
### Service per Container
|
|
332
|
+
|
|
333
|
+
Package each service as a Docker container image:
|
|
334
|
+
|
|
335
|
+
- Encapsulates service and dependencies
|
|
336
|
+
- Consistent across environments
|
|
337
|
+
- Use multi-stage builds to keep images small
|
|
338
|
+
|
|
339
|
+
### Kubernetes Orchestration
|
|
340
|
+
|
|
341
|
+
- Deployment: Manages replicas and rolling updates
|
|
342
|
+
- Service: Stable network endpoint for service discovery
|
|
343
|
+
- ConfigMap/Secret: Externalized configuration
|
|
344
|
+
- Probes: Liveness and readiness health checks
|
|
345
|
+
|
|
346
|
+
### Service Mesh
|
|
347
|
+
|
|
348
|
+
Infrastructure layer handling service-to-service communication:
|
|
349
|
+
|
|
350
|
+
- Automatic mTLS between services
|
|
351
|
+
- Traffic management (retries, timeouts, circuit breaking)
|
|
352
|
+
- Observability (distributed tracing, metrics)
|
|
353
|
+
- Tools: Istio, Linkerd
|
|
354
|
+
|
|
355
|
+
### Externalized Configuration
|
|
356
|
+
|
|
357
|
+
- Environment variables, config servers (Spring Cloud Config), Kubernetes ConfigMaps
|
|
358
|
+
- Secrets managed separately (Vault, Kubernetes Secrets)
|
|
359
|
+
- Same artifact runs in different environments
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## Observability Patterns
|
|
364
|
+
|
|
365
|
+
### Health Check API
|
|
366
|
+
|
|
367
|
+
Every service exposes a health endpoint (GET /health) reporting:
|
|
368
|
+
- Service status (UP/DOWN)
|
|
369
|
+
- Dependency status (database, message broker)
|
|
370
|
+
- Used by orchestrators and load balancers
|
|
371
|
+
|
|
372
|
+
### Distributed Tracing
|
|
373
|
+
|
|
374
|
+
Assign unique trace ID to each external request, propagate through all service calls.
|
|
375
|
+
- Tools: Zipkin, Jaeger, AWS X-Ray
|
|
376
|
+
- Instrument with OpenTelemetry
|
|
377
|
+
|
|
378
|
+
### Log Aggregation
|
|
379
|
+
|
|
380
|
+
Centralize logs from all services:
|
|
381
|
+
- Include trace IDs for correlation
|
|
382
|
+
- Structured logging (JSON format)
|
|
383
|
+
- Tools: ELK Stack, Fluentd, Datadog
|
|
384
|
+
|
|
385
|
+
### Application Metrics
|
|
386
|
+
|
|
387
|
+
Collect and expose metrics from each service:
|
|
388
|
+
- Request rate, latency, error rate (RED method)
|
|
389
|
+
- Resource utilization
|
|
390
|
+
- Business metrics
|
|
391
|
+
- Tools: Prometheus + Grafana, Datadog, CloudWatch
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Microservices Code Review Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist when reviewing microservices code. Work through each section
|
|
4
|
+
and flag any violations. Not every section applies to every review — skip sections
|
|
5
|
+
that aren't relevant to the code under review.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Service Decomposition
|
|
10
|
+
|
|
11
|
+
- [ ] Service boundaries align with business capabilities or DDD bounded contexts
|
|
12
|
+
- [ ] No "god service" doing too much — each service has a focused responsibility
|
|
13
|
+
- [ ] Services can be deployed independently
|
|
14
|
+
- [ ] No shared domain logic libraries that couple services at the code level
|
|
15
|
+
- [ ] Team ownership is clear — ideally one team owns one or a few related services
|
|
16
|
+
|
|
17
|
+
**Red flags**: A service that imports domain models from another service. A change
|
|
18
|
+
in one service requiring simultaneous deployment of another service.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 2. Data Ownership
|
|
23
|
+
|
|
24
|
+
- [ ] Each service has its own private database/schema
|
|
25
|
+
- [ ] No shared database tables between services
|
|
26
|
+
- [ ] Services never directly query another service's database
|
|
27
|
+
- [ ] Data duplication (where it exists) is managed via events, not shared writes
|
|
28
|
+
|
|
29
|
+
**Red flags**: SQL joins across tables owned by different services. Connection strings
|
|
30
|
+
pointing to another service's database. Multiple services with write access to the same table.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## 3. Inter-Service Communication
|
|
35
|
+
|
|
36
|
+
- [ ] Communication style (sync vs async) matches the use case
|
|
37
|
+
- [ ] Synchronous calls have timeouts configured
|
|
38
|
+
- [ ] Circuit breakers protect against cascading failures
|
|
39
|
+
- [ ] No long synchronous call chains (A -> B -> C -> D)
|
|
40
|
+
- [ ] Async messaging uses transactional outbox or event sourcing for reliability
|
|
41
|
+
- [ ] Message consumers are idempotent
|
|
42
|
+
- [ ] Service discovery is in place (not hardcoded URLs)
|
|
43
|
+
|
|
44
|
+
**Red flags**: HTTP calls without timeouts. Retry loops without backoff. Direct
|
|
45
|
+
database writes as a "faster alternative" to messaging.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 4. API Design
|
|
50
|
+
|
|
51
|
+
- [ ] APIs are versioned or use backward-compatible evolution
|
|
52
|
+
- [ ] API contracts are defined (OpenAPI, Proto files, AsyncAPI)
|
|
53
|
+
- [ ] Error responses follow a consistent format
|
|
54
|
+
- [ ] APIs return only what the client needs (no over-fetching)
|
|
55
|
+
- [ ] Consumer-driven contract tests exist for key API consumers
|
|
56
|
+
|
|
57
|
+
**Red flags**: Breaking API changes without versioning. No API documentation or contract.
|
|
58
|
+
Internal implementation details leaking through the API.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 5. Transaction Management (Sagas)
|
|
63
|
+
|
|
64
|
+
- [ ] Cross-service operations use sagas, not distributed transactions (no 2PC)
|
|
65
|
+
- [ ] Each saga step has a compensating transaction defined
|
|
66
|
+
- [ ] Compensating transactions are idempotent
|
|
67
|
+
- [ ] Saga state is persisted (not just in-memory)
|
|
68
|
+
- [ ] Semantic locks or other countermeasures handle isolation concerns
|
|
69
|
+
- [ ] Saga orchestrator (if used) doesn't contain business logic — only coordinates
|
|
70
|
+
|
|
71
|
+
**Red flags**: Try/catch blocks attempting to rollback across service boundaries without
|
|
72
|
+
a saga. Services directly calling another service's "undo" endpoint without saga coordination.
|
|
73
|
+
Missing compensating transactions.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 6. Business Logic & Domain Model
|
|
78
|
+
|
|
79
|
+
- [ ] Business logic lives in domain objects (aggregates), not in service/controller classes
|
|
80
|
+
- [ ] Aggregates enforce their own invariants
|
|
81
|
+
- [ ] One transaction modifies exactly one aggregate
|
|
82
|
+
- [ ] Aggregates reference other aggregates by ID, not by object reference
|
|
83
|
+
- [ ] Domain events are published after aggregate state changes
|
|
84
|
+
- [ ] Value objects are used where identity isn't needed
|
|
85
|
+
|
|
86
|
+
**Red flags**: Anemic domain model (entities are just data holders, all logic in services).
|
|
87
|
+
Transactions that modify multiple aggregates. Direct object references between aggregates.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 7. Event Handling
|
|
92
|
+
|
|
93
|
+
- [ ] Events are named in past tense (OrderCreated, not CreateOrder)
|
|
94
|
+
- [ ] Events contain sufficient data for consumers to act without callbacks
|
|
95
|
+
- [ ] Event schema versioning strategy exists
|
|
96
|
+
- [ ] Event handlers are idempotent
|
|
97
|
+
- [ ] Ordering is preserved where needed (partition by aggregate ID)
|
|
98
|
+
- [ ] If using event sourcing: snapshots exist for aggregates with many events
|
|
99
|
+
|
|
100
|
+
**Red flags**: Events named as commands. Event handlers that call back to the
|
|
101
|
+
publishing service for more data. No strategy for event schema evolution.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 8. Query Implementation
|
|
106
|
+
|
|
107
|
+
- [ ] Cross-service queries use API Composition or CQRS — not direct DB access
|
|
108
|
+
- [ ] API Composition: composer handles partial failures gracefully
|
|
109
|
+
- [ ] CQRS views: event handlers maintain denormalized read models
|
|
110
|
+
- [ ] CQRS views: eventual consistency is acceptable for the use case
|
|
111
|
+
- [ ] Query performance is adequate for the access patterns
|
|
112
|
+
|
|
113
|
+
**Red flags**: Queries that join data from multiple services' databases. N+1 query
|
|
114
|
+
patterns in API composition. CQRS view that falls too far behind event stream.
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 9. Testing
|
|
119
|
+
|
|
120
|
+
- [ ] Unit tests cover domain logic (aggregates, value objects, saga orchestrators)
|
|
121
|
+
- [ ] Integration tests verify infrastructure interactions (DB, messaging, HTTP clients)
|
|
122
|
+
- [ ] Component tests exercise the service end-to-end with stubbed dependencies
|
|
123
|
+
- [ ] Consumer-driven contract tests protect API compatibility
|
|
124
|
+
- [ ] End-to-end tests are minimal and focused on critical paths
|
|
125
|
+
- [ ] Tests use containers (Testcontainers) for realistic infrastructure testing
|
|
126
|
+
|
|
127
|
+
**Red flags**: Only end-to-end tests (slow, brittle). No contract tests between
|
|
128
|
+
services that communicate. Mocks that hide real integration issues.
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## 10. Observability
|
|
133
|
+
|
|
134
|
+
- [ ] Health check endpoint exists (GET /health or /actuator/health)
|
|
135
|
+
- [ ] Structured logging with correlation/trace IDs
|
|
136
|
+
- [ ] Distributed tracing is instrumented (OpenTelemetry or equivalent)
|
|
137
|
+
- [ ] Key metrics are exposed (request rate, latency, error rate)
|
|
138
|
+
- [ ] Alerts are configured for critical failure conditions
|
|
139
|
+
|
|
140
|
+
**Red flags**: Console.log as the only logging. No health endpoint. No way to
|
|
141
|
+
trace a request across service boundaries.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## 11. Configuration & Security
|
|
146
|
+
|
|
147
|
+
- [ ] Configuration is externalized (not hardcoded)
|
|
148
|
+
- [ ] Secrets are managed securely (not in source code or env files in repo)
|
|
149
|
+
- [ ] Service-to-service communication is authenticated (mTLS or API keys)
|
|
150
|
+
- [ ] Input validation exists at service boundaries
|
|
151
|
+
- [ ] Principle of least privilege for database access
|
|
152
|
+
|
|
153
|
+
**Red flags**: Database passwords in source code. Services accepting unauthenticated
|
|
154
|
+
internal requests. Configuration values baked into artifacts.
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Severity Classification
|
|
159
|
+
|
|
160
|
+
When reporting issues, classify them:
|
|
161
|
+
|
|
162
|
+
- **Critical**: Data loss risk, security vulnerability, or correctness issue
|
|
163
|
+
(e.g., shared database, missing compensating transactions, no auth)
|
|
164
|
+
- **Major**: Architectural debt that will cause scaling/maintenance problems
|
|
165
|
+
(e.g., synchronous chains, god service, anemic domain model)
|
|
166
|
+
- **Minor**: Best practice deviation with limited immediate impact
|
|
167
|
+
(e.g., missing health check, no structured logging)
|
|
168
|
+
- **Suggestion**: Improvement that would be nice but isn't urgent
|
|
169
|
+
(e.g., could benefit from CQRS in the future, consider event sourcing)
|
package/package.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@booklib/skills",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Book knowledge distilled into structured AI skills for Claude Code and other AI assistants",
|
|
5
|
+
"bin": {
|
|
6
|
+
"skills": "./bin/skills.js"
|
|
7
|
+
},
|
|
8
|
+
"keywords": ["claude", "claude-code", "ai", "skills", "agent-skills"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/agent-skills/skills.git"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=16"
|
|
16
|
+
}
|
|
17
|
+
}
|