La interfaz está localizada; las descripciones y documentos de las Skills se traducen automáticamente con IA a su idioma. El código, los comandos, rutas y términos técnicos se mantienen en el original, y prevalece el documento del autor.
Explorar Skills
Diseño y creatividad · SKILL.md

event-architecture

event-architecture

Design event-driven systems — event schemas, message broker selection, ordering guarantees, dead letter queues, saga patterns, and idempotency. TRIGGER when: user says /event-architecture, needs to design event-driven systems, or asks about message queues, pub/sub, or async processing.

Independent GitHub snapshot · Automated classification · Original documentation governs

Documentación de la Skill

GitHub

name: event-architecture description: > Design event-driven systems — event schemas, message broker selection, ordering guarantees, dead letter queues, saga patterns, and idempotency. TRIGGER when: user says /event-architecture, needs to design event-driven systems, or asks about message queues, pub/sub, or async processing. argument-hint: "[system or workflow to make event-driven]" user-invocable: true

Event-Driven Architecture

You are a distributed systems engineer. Design event architectures that are reliable, scalable, and debuggable.

Process

Step 1: Identify Event-Driven Fit

SignalEvent-Driven SuitsRequest-Response Suits
CouplingLoose coupling between servicesTight coupling OK
LatencyEventual consistency acceptableImmediate response required
Fan-outMultiple consumers per eventSingle consumer
ReliabilityMust not lose eventsRetry on failure is fine
ScaleVariable, bursty workloadsPredictable load

Step 2: Design Event Schema

{
  "event_id": "uuid",
  "event_type": "order.placed",
  "version": "1.2",
  "timestamp": "2025-03-15T10:30:00Z",
  "source": "order-service",
  "correlation_id": "uuid",
  "data": {
    "order_id": "12345",
    "customer_id": "67890",
    "total": 99.99
  },
  "metadata": {
    "trace_id": "abc123",
    "environment": "production"
  }
}

Schema rules:

  • Use past tense for event names (order.placed, not place.order)
  • Version all schemas — breaking changes require new versions
  • Include event_id for idempotency
  • Include correlation_id for distributed tracing
  • Keep events self-contained — consumers shouldn't need to call back

Step 3: Select Message Broker

BrokerOrderingRetentionScaleBest For
KafkaPer-partitionDays-foreverVery highEvent streaming, log
RabbitMQPer-queueUntil consumedHighTask queues, RPC
SQSBest-effort (FIFO available)14 daysVery highAWS-native, simple queues
SNS + SQSFan-outVia SQSVery highPub/sub + queue combo
Pub/Sub (GCP)Per-key31 daysVery highGCP-native streaming
NATSPer-subjectConfigurableVery highLow-latency, lightweight

Step 4: Handle Reliability

ConcernSolution
Message lossAt-least-once delivery + idempotent consumers
Duplicate processingIdempotency key (event_id) + processed event log
OrderingPartition by entity ID (e.g., order_id)
Poison messagesDead letter queue (DLQ) after N retries
Consumer lagAutoscaling consumers, monitoring lag metrics
Schema evolutionSchema registry, backward-compatible changes

Step 5: Design Saga Patterns (if multi-step)

PatternHowUse When
ChoreographyEach service emits events, others reactSimple flows, few steps
OrchestrationCentral coordinator directs stepsComplex flows, many steps

Compensating transactions:

StepActionCompensation (on failure)
1. Reserve inventoryinventory.reservedinventory.released
2. Charge paymentpayment.chargedpayment.refunded
3. Ship orderorder.shippedshipment.cancelled

Step 6: Plan Observability

What to MonitorHow
Consumer lagBroker metrics (Kafka consumer group lag)
Processing timeHistogram per event type
Error rateDLQ depth, failed event count
ThroughputEvents/second per topic/queue
End-to-end latencyCorrelation ID tracing from publish to final consume

Output Format

## Event Architecture: [System]

### Events: [Event catalog with schemas]
### Broker: [Selection with rationale]
### Reliability: [Delivery guarantees, idempotency approach]
### Sagas: [Multi-step workflow design, if applicable]
### Monitoring: [Key metrics]

Quality Checklist

  • Events are self-contained and versioned
  • Consumers are idempotent
  • Dead letter queues handle poison messages
  • Ordering is guaranteed where needed (partition key)
  • Schema evolution strategy defined
  • Monitoring covers lag, errors, and throughput
  • Compensating transactions exist for saga steps

Edge Cases

  • For CQRS, separate command and query models with events bridging them
  • If events are large (>1MB), store payload externally and reference by ID
  • For cross-region, plan for event replication latency
  • If exactly-once semantics are required, use transactional outbox pattern
  • For debugging, build an event replay capability for dev/staging
Skills guardadas