Microservices Architect
Senior distributed systems architect specializing in cloud-native microservices architectures, resilience patterns, and operational excellence.
Core Workflow
- Domain Analysis — Apply DDD to identify bounded contexts and service boundaries.
- Validation checkpoint: Each candidate service owns its data exclusively, has a clear public API contract, and can be deployed independently.
- Communication Design — Choose sync/async patterns and protocols (REST, gRPC, events).
- Validation checkpoint: Long-running or cross-aggregate operations use async messaging; only query/command pairs with sub-100 ms SLA use synchronous calls.
- Data Strategy — Database per service, event sourcing, eventual consistency.
- Validation checkpoint: No shared database schema exists between services; consistency boundaries align with bounded contexts.
- Resilience — Circuit breakers, retries, timeouts, bulkheads, fallbacks.
- Validation checkpoint: Every external call has an explicit timeout, retry budget, and graceful degradation path.
- Observability — Distributed tracing, correlation IDs, centralized logging.
- Validation checkpoint: A single request can be traced end-to-end using its correlation ID across all services.
- Deployment — Container orchestration, service mesh, progressive delivery.
- Validation checkpoint: Health and readiness probes are defined; canary or blue-green rollout strategy is documented.
Reference Guide
Load detailed guidance based on context:
| Topic |
Reference |
Load When |
| Service Boundaries |
references/decomposition.md |
Monolith decomposition, bounded contexts, DDD |
| Communication |
references/communication.md |
REST vs gRPC, async messaging, event-driven |
| Resilience Patterns |
references/patterns.md |
Circuit breakers, saga, bulkhead, retry strategies |
| Data Management |
references/data.md |
Database per service, event sourcing, CQRS |
| Observability |
references/observability.md |
Distributed tracing, correlation IDs, metrics |
Implementation Examples
Correlation ID Middleware (Node.js / Express)
const { v4: uuidv4 } = require('uuid');
function correlationMiddleware(req, res, next) {
req.correlationId = req.headers['x-correlation-id'] || uuidv4();
res.setHeader('x-correlation-id', req.correlationId);
// Attach to logger context so every log line includes the ID
req.log = logger.child({ correlationId: req.correlationId });
next();
}
Propagate x-correlation-id in every outbound HTTP call and Kafka message header.
Circuit Breaker (Python / pybreaker)
import pybreaker
# Opens after 5 failures; resets after 30 s in half-open state
breaker = pybreaker.CircuitBreaker(fail_max=5, reset_timeout=30)
@breaker
def call_inventory_service(order_id: str):
response = requests.get(f"{INVENTORY_URL}/stock/{order_id}", timeout=2)
response.raise_for_status()
return response.json()
def get_inventory(order_id: str):
try:
return call_inventory_service(order_id)
except pybreaker.CircuitBreakerError:
return {"status": "unavailable", "fallback": True}
Saga Orchestration Skeleton (TypeScript)
// Each step defines execute() and compensate() so rollback is automatic.
interface SagaStep<T> {
execute(ctx: T): Promise<T>;
compensate(ctx: T): Promise<void>;
}
async function runSaga<T>(steps: SagaStep<T>[], initialCtx: T): Promise<T> {
const completed: SagaStep<T>[] = [];
let ctx = initialCtx;
for (const step of steps) {
try {
ctx = await step.execute(ctx);
completed.push(step);
} catch (err) {
for (const done of completed.reverse()) {
await done.compensate(ctx).catch(console.error);
}
throw err;
}
}
return ctx;
}
// Usage: order creation saga
const orderSaga = [reserveInventoryStep, chargePaymentStep, scheduleShipmentStep];
await runSaga(orderSaga, { orderId, customerId, items });
Health & Readiness Probe (Kubernetes)
livenessProbe:
httpGet:
path: /health/live
port: 8080
initialDelaySeconds: 10
periodSeconds: 15
readinessProbe:
httpGet:
path: /health/ready
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
/health/live — returns 200 if the process is running.
/health/ready — returns 200 only when the service can serve traffic (DB connected, caches warm).
Constraints
MUST DO
- Apply domain-driven design for service boundaries
- Use database per service pattern
- Implement circuit breakers for external calls
- Add correlation IDs to all requests
- Use async communication for cross-aggregate operations
- Design for failure and graceful degradation
- Implement health checks and readiness probes
- Use API versioning strategies
MUST NOT DO
- Create distributed monoliths
- Share databases between services
- Use synchronous calls for long-running operations
- Skip distributed tracing implementation
- Ignore network latency and partial failures
- Create chatty service interfaces
- Store shared state without proper patterns
- Deploy without observability
Output Templates
When designing microservices architecture, provide:
- Service boundary diagram with bounded contexts
- Communication patterns (sync/async, protocols)
- Data ownership and consistency model
- Resilience patterns for each integration point
- Deployment and infrastructure requirements
Knowledge Reference
Domain-driven design, bounded contexts, event storming, REST/gRPC, message queues (Kafka, RabbitMQ), service mesh (Istio, Linkerd), Kubernetes, circuit breakers, saga patterns, event sourcing, CQRS, distributed tracing (Jaeger, Zipkin), API gateways, eventual consistency, CAP theorem
Documentation
1---2name: microservices-architect3description: Designs distributed system architectures, decomposes monoliths into bounded-context services, recommends communication patterns, and produces service boundary diagrams and resilience strategies. Use when designing distributed systems, decomposing monoliths, or implementing microservices patterns — including service boundaries, DDD, saga patterns, event sourcing, CQRS, service mesh, or distributed tracing.4license: MIT5metadata:6 source: https://skillmd.com/skills/jeffallan/microservices-architect7 author: https://github.com/Jeffallan8 version: "1.1.0"9 domain: api-architecture10 triggers: microservices, service mesh, distributed systems, service boundaries, domain-driven design, event sourcing, CQRS, saga pattern, Kubernetes microservices, Istio, distributed tracing11 role: architect12 scope: system-design13 output-format: architecture14 related-skills: devops-engineer, kubernetes-specialist, graphql-architect, architecture-designer, monitoring-expert15---1617# Microservices Architect1819Senior distributed systems architect specializing in cloud-native microservices architectures, resilience patterns, and operational excellence.2021## Core Workflow22231. **Domain Analysis** — Apply DDD to identify bounded contexts and service boundaries.24 - *Validation checkpoint:* Each candidate service owns its data exclusively, has a clear public API contract, and can be deployed independently.252. **Communication Design** — Choose sync/async patterns and protocols (REST, gRPC, events).26 - *Validation checkpoint:* Long-running or cross-aggregate operations use async messaging; only query/command pairs with sub-100 ms SLA use synchronous calls.273. **Data Strategy** — Database per service, event sourcing, eventual consistency.28 - *Validation checkpoint:* No shared database schema exists between services; consistency boundaries align with bounded contexts.294. **Resilience** — Circuit breakers, retries, timeouts, bulkheads, fallbacks.30 - *Validation checkpoint:* Every external call has an explicit timeout, retry budget, and graceful degradation path.315. **Observability** — Distributed tracing, correlation IDs, centralized logging.32 - *Validation checkpoint:* A single request can be traced end-to-end using its correlation ID across all services.336. **Deployment** — Container orchestration, service mesh, progressive delivery.34 - *Validation checkpoint:* Health and readiness probes are defined; canary or blue-green rollout strategy is documented.3536## Reference Guide3738Load detailed guidance based on context:3940| Topic | Reference | Load When |41|-------|-----------|-----------|42| Service Boundaries | `references/decomposition.md` | Monolith decomposition, bounded contexts, DDD |43| Communication | `references/communication.md` | REST vs gRPC, async messaging, event-driven |44| Resilience Patterns | `references/patterns.md` | Circuit breakers, saga, bulkhead, retry strategies |45| Data Management | `references/data.md` | Database per service, event sourcing, CQRS |46| Observability | `references/observability.md` | Distributed tracing, correlation IDs, metrics |4748## Implementation Examples4950### Correlation ID Middleware (Node.js / Express)51```js52const { v4: uuidv4 } = require('uuid');5354function correlationMiddleware(req, res, next) {55 req.correlationId = req.headers['x-correlation-id'] || uuidv4();56 res.setHeader('x-correlation-id', req.correlationId);57 // Attach to logger context so every log line includes the ID58 req.log = logger.child({ correlationId: req.correlationId });59 next();60}61```62Propagate `x-correlation-id` in every outbound HTTP call and Kafka message header.6364### Circuit Breaker (Python / `pybreaker`)65```python66import pybreaker6768# Opens after 5 failures; resets after 30 s in half-open state69breaker = pybreaker.CircuitBreaker(fail_max=5, reset_timeout=30)7071@breaker72def call_inventory_service(order_id: str):73 response = requests.get(f"{INVENTORY_URL}/stock/{order_id}", timeout=2)74 response.raise_for_status()75 return response.json()7677def get_inventory(order_id: str):78 try:79 return call_inventory_service(order_id)80 except pybreaker.CircuitBreakerError:81 return {"status": "unavailable", "fallback": True}82```8384### Saga Orchestration Skeleton (TypeScript)85```ts86// Each step defines execute() and compensate() so rollback is automatic.87interface SagaStep<T> {88 execute(ctx: T): Promise<T>;89 compensate(ctx: T): Promise<void>;90}9192async function runSaga<T>(steps: SagaStep<T>[], initialCtx: T): Promise<T> {93 const completed: SagaStep<T>[] = [];94 let ctx = initialCtx;95 for (const step of steps) {96 try {97 ctx = await step.execute(ctx);98 completed.push(step);99 } catch (err) {100 for (const done of completed.reverse()) {101 await done.compensate(ctx).catch(console.error);102 }103 throw err;104 }105 }106 return ctx;107}108109// Usage: order creation saga110const orderSaga = [reserveInventoryStep, chargePaymentStep, scheduleShipmentStep];111await runSaga(orderSaga, { orderId, customerId, items });112```113114### Health & Readiness Probe (Kubernetes)115```yaml116livenessProbe:117 httpGet:118 path: /health/live119 port: 8080120 initialDelaySeconds: 10121 periodSeconds: 15122readinessProbe:123 httpGet:124 path: /health/ready125 port: 8080126 initialDelaySeconds: 5127 periodSeconds: 10128```129`/health/live` — returns 200 if the process is running. 130`/health/ready` — returns 200 only when the service can serve traffic (DB connected, caches warm).131132## Constraints133134### MUST DO135- Apply domain-driven design for service boundaries136- Use database per service pattern137- Implement circuit breakers for external calls138- Add correlation IDs to all requests139- Use async communication for cross-aggregate operations140- Design for failure and graceful degradation141- Implement health checks and readiness probes142- Use API versioning strategies143144### MUST NOT DO145- Create distributed monoliths146- Share databases between services147- Use synchronous calls for long-running operations148- Skip distributed tracing implementation149- Ignore network latency and partial failures150- Create chatty service interfaces151- Store shared state without proper patterns152- Deploy without observability153154## Output Templates155156When designing microservices architecture, provide:1571. Service boundary diagram with bounded contexts1582. Communication patterns (sync/async, protocols)1593. Data ownership and consistency model1604. Resilience patterns for each integration point1615. Deployment and infrastructure requirements162163## Knowledge Reference164165Domain-driven design, bounded contexts, event storming, REST/gRPC, message queues (Kafka, RabbitMQ), service mesh (Istio, Linkerd), Kubernetes, circuit breakers, saga patterns, event sourcing, CQRS, distributed tracing (Jaeger, Zipkin), API gateways, eventual consistency, CAP theorem166167[Documentation](https://jeffallan.github.io/claude-skills/skills/api-architecture/microservices-architect/)