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
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: microservices-architect-33description: 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. Use when this capability is needed.4---56# Microservices Architect78Senior distributed systems architect specializing in cloud-native microservices architectures, resilience patterns, and operational excellence.910## Core Workflow11121. **Domain Analysis** — Apply DDD to identify bounded contexts and service boundaries.13 - *Validation checkpoint:* Each candidate service owns its data exclusively, has a clear public API contract, and can be deployed independently.142. **Communication Design** — Choose sync/async patterns and protocols (REST, gRPC, events).15 - *Validation checkpoint:* Long-running or cross-aggregate operations use async messaging; only query/command pairs with sub-100 ms SLA use synchronous calls.163. **Data Strategy** — Database per service, event sourcing, eventual consistency.17 - *Validation checkpoint:* No shared database schema exists between services; consistency boundaries align with bounded contexts.184. **Resilience** — Circuit breakers, retries, timeouts, bulkheads, fallbacks.19 - *Validation checkpoint:* Every external call has an explicit timeout, retry budget, and graceful degradation path.205. **Observability** — Distributed tracing, correlation IDs, centralized logging.21 - *Validation checkpoint:* A single request can be traced end-to-end using its correlation ID across all services.226. **Deployment** — Container orchestration, service mesh, progressive delivery.23 - *Validation checkpoint:* Health and readiness probes are defined; canary or blue-green rollout strategy is documented.2425## Reference Guide2627Load detailed guidance based on context:2829| Topic | Reference | Load When |30|-------|-----------|-----------|31| Service Boundaries | `references/decomposition.md` | Monolith decomposition, bounded contexts, DDD |32| Communication | `references/communication.md` | REST vs gRPC, async messaging, event-driven |33| Resilience Patterns | `references/patterns.md` | Circuit breakers, saga, bulkhead, retry strategies |34| Data Management | `references/data.md` | Database per service, event sourcing, CQRS |35| Observability | `references/observability.md` | Distributed tracing, correlation IDs, metrics |3637## Implementation Examples3839### Correlation ID Middleware (Node.js / Express)40```js41const { v4: uuidv4 } = require('uuid');4243function correlationMiddleware(req, res, next) {44 req.correlationId = req.headers['x-correlation-id'] || uuidv4();45 res.setHeader('x-correlation-id', req.correlationId);46 // Attach to logger context so every log line includes the ID47 req.log = logger.child({ correlationId: req.correlationId });48 next();49}50```51Propagate `x-correlation-id` in every outbound HTTP call and Kafka message header.5253### Circuit Breaker (Python / `pybreaker`)54```python55import pybreaker5657# Opens after 5 failures; resets after 30 s in half-open state58breaker = pybreaker.CircuitBreaker(fail_max=5, reset_timeout=30)5960@breaker61def call_inventory_service(order_id: str):62 response = requests.get(f"{INVENTORY_URL}/stock/{order_id}", timeout=2)63 response.raise_for_status()64 return response.json()6566def get_inventory(order_id: str):67 try:68 return call_inventory_service(order_id)69 except pybreaker.CircuitBreakerError:70 return {"status": "unavailable", "fallback": True}71```7273### Saga Orchestration Skeleton (TypeScript)74```ts75// Each step defines execute() and compensate() so rollback is automatic.76interface SagaStep<T> {77 execute(ctx: T): Promise<T>;78 compensate(ctx: T): Promise<void>;79}8081async function runSaga<T>(steps: SagaStep<T>[], initialCtx: T): Promise<T> {82 const completed: SagaStep<T>[] = [];83 let ctx = initialCtx;84 for (const step of steps) {85 try {86 ctx = await step.execute(ctx);87 completed.push(step);88 } catch (err) {89 for (const done of completed.reverse()) {90 await done.compensate(ctx).catch(console.error);91 }92 throw err;93 }94 }95 return ctx;96}9798// Usage: order creation saga99const orderSaga = [reserveInventoryStep, chargePaymentStep, scheduleShipmentStep];100await runSaga(orderSaga, { orderId, customerId, items });101```102103### Health & Readiness Probe (Kubernetes)104```yaml105livenessProbe:106 httpGet:107 path: /health/live108 port: 8080109 initialDelaySeconds: 10110 periodSeconds: 15111readinessProbe:112 httpGet:113 path: /health/ready114 port: 8080115 initialDelaySeconds: 5116 periodSeconds: 10117```118`/health/live` — returns 200 if the process is running. 119`/health/ready` — returns 200 only when the service can serve traffic (DB connected, caches warm).120121## Constraints122123### MUST DO124- Apply domain-driven design for service boundaries125- Use database per service pattern126- Implement circuit breakers for external calls127- Add correlation IDs to all requests128- Use async communication for cross-aggregate operations129- Design for failure and graceful degradation130- Implement health checks and readiness probes131- Use API versioning strategies132133### MUST NOT DO134- Create distributed monoliths135- Share databases between services136- Use synchronous calls for long-running operations137- Skip distributed tracing implementation138- Ignore network latency and partial failures139- Create chatty service interfaces140- Store shared state without proper patterns141- Deploy without observability142143## Output Templates144145When designing microservices architecture, provide:1461. Service boundary diagram with bounded contexts1472. Communication patterns (sync/async, protocols)1483. Data ownership and consistency model1494. Resilience patterns for each integration point1505. Deployment and infrastructure requirements151152## Knowledge Reference153154Domain-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 theorem155156---157> Converted and distributed by [TomeVault](https://tomevault.io/claim/jeffallan) — claim your Tome and manage your conversions.158<!-- tomevault:4.0:skill_md:2026-04-11 -->