- Home
- Skills
- APIs & Backend
- Event-Driven Architecture Designer
Event-Driven Architecture Designer
Designs async messaging between services: event vs command, topology, delivery, ordering, retries, replay, recovery.
$12
Works with the AI tools you already use
Event-Driven Architecture Designer
Example session with this skill installed
Design the event-driven architecture for our Order Fulfillment and Inventory systems.
- System: Order Management (OMS) emitting order events to Inventory Service and Billing Service.
- Context: Current synchronous REST calls fail during flash sales. Peak throughput is 1,200 orders/sec; sustained rate is 300 orders/sec.
- Decider: Core Architecture Guild (Lead Architect: Marcus Vance).
- Broker: Managed Kafka cluster (3 brokers, replication factor 3, min.insync.replicas=2).
- Schema & Wire: CloudEvents v1.0 spec over JSON, registered in Confluent Schema Registry with BACKWARD compatibility.
- Tension: Payments team wants billing to process synchronously before inventory holds, while inventory lead insists on immediate event-driven stock reservation; stock over-allocation happened 4 times during last promotion.
- Reliability: Max allowable message processing latency is 500 ms at p95; zero event loss tolerance (at-least-once with transactional outbox).
- Exclusions: Customer notification pipeline and data warehouse ETL are out of scope.
Write the architecture under docs/architecture/eda/.
- Read your context and instructions
- Compiled the event-driven architecture designer
Wrote docs/architecture/eda/eda-architecture.md. Complete event-driven architecture specification covering topic topology, delivery guarantees, transactional outbox mechanics, and partition-ordering strategy.
Event-Driven Architecture: Order Fulfillment and Inventory
1. Executive Summary
This architecture establishes an asynchronous event-driven messaging boundary between Order Management System (OMS), Inventory Service, and Billing Service using Apache Kafka. It resolves flash-sale synchronous coupling and stock over-allocation by introducing transactional outbox publishing, partitioned order streams, and idempotent consumer workers.
| Dimension | Target Specification | Classification |
|---|---|---|
| Sustained Ingestion | 300 msg/sec | provided |
| Peak Ingestion | 1,200 msg/sec | provided |
| Latency Budget (p95) | ≤ 500 ms end-to-end | provided |
| Delivery Semantics | At-least-once with idempotent deduplication | decided |
| Broker Infrastructure | Kafka 3-node cluster (RF=3, min.insync.replicas=2) | provided |
| Message Standard | CloudEvents v1.0 JSON format | provided |
2. Context and Scope Boundary
2.1 Boundary Definitions
In-Scope: OMS event emission, Kafka cluster topic topology, Inventory allocation consumer, Billing transaction consumer, Dead Letter Queue (DLQ) routing, Schema Registry policies.
Out-of-Scope (Excluded): Customer notification pipeline, data warehouse / BI ETL pipelines, and internal database migrations outside outbox tables.
2.2 System Participants
| Service | Role | Data Store | Interaction Mode |
|---|---|---|---|
| Order Management System (OMS) | Producer | PostgreSQL 15 | Local ACID Transaction + Outbox Polling |
| Inventory Service | Consumer / Producer | PostgreSQL 15 | Idempotent Consumer + Event Emission |
| Billing Service | Consumer | MySQL 8.0 | Idempotent Consumer |
3. Domain Event Catalog
3.1 Event Classification
OrderPlaced (Domain Event)
├── Producer: OMS
├── Key: order_id
└── Routing: orders.lifecycle.v1
├── Subscriber: Inventory Service (reserves allocation)
└── Subscriber: Billing Service (initiates payment hold)
| Event Type | Purpose | Payload Summary | Producer | Mutability |
|---|---|---|---|---|
com.company.orders.placed.v1 | Signals customer confirmed order checkout | order_id, customer_id, items[], total_amount_cents, currency, placed_at | OMS | Immutable fact |
com.company.inventory.allocated.v1 | Confirms stock reserved for items | reservation_id, order_id, items[], allocated_at | Inventory | Immutable fact |
com.company.inventory.exhausted.v1 | Signals stock shortfall for order | order_id, insufficient_skus[], failed_at | Inventory | Immutable fact |
Note: Order placement is an immutable past fact (domain event), not an RPC command.
4. Channel and Topic Topology
4.1 Topic Layout
| Topic Name | Purpose | Partitions | Retention | Cleanup Policy |
|---|---|---|---|---|
orders.lifecycle.v1 | Primary order events | 12 | 7 days | delete |
inventory.events.v1 | Inventory stock status events | 12 | 7 days | delete |
orders.lifecycle.v1.retry | Delayed consumer retry topic | 6 | 3 days | delete |
orders.lifecycle.v1.dlq | Poison pill quarantine | 3 | 30 days | compact,delete |
4.2 Sizing & Partition Calculation
- Sustained rate: 300 msg/sec; Peak rate: 1,200 msg/sec.
- Target per-partition throughput budget: 100 msg/sec maximum to guarantee latency ≤ 500 ms at p95 under standard single-thread consumer processing (processing budget ~10 ms per record).
- Derived partition count: ceil(1200 / 100) = 12 partitions.
5. Message Contract and Serialization
5.1 CloudEvents Envelope
{
"specversion": "1.0",
"id": "e4b2d106-69fc-4b57-9db1-35b86e09e1e2",
"source": "/services/oms",
"type": "com.company.orders.placed.v1",
"datacontenttype": "application/json",
"dataschema": "http://registry.internal/schemas/orders.placed.v1.json",
"time": "2026-09-15T10:00:00Z",
"traceparent": "00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01",
"data": {
"order_id": "ord_99281a",
"customer_id": "cust_4812",
"items": [
{ "sku": "SKU-BLK-M", "quantity": 1, "price_cents": 4500 }
],
"total_amount_cents": 4500,
"currency": "USD"
}
}
6. Ordering and Partitioning Strategy
6.1 Partition Key Assignment
orders.lifecycle.v1is keyed byorder_id.- Rationale: Ensures total strict ordering of all state transitions belonging to a specific order (
placed->allocated->paid). - Flash Sale Hotspots: Popular products do NOT partition on
skuat the ingress topic, preventing Kafka partition skew. Inventory service aggregates SKU stock levels internally using database row locks keyed on SKU.
7. Delivery and Idempotency Architecture
7.1 Producer: Transactional Outbox Pattern
Direct dual-write to PostgreSQL and Kafka is prohibited to prevent dual-write divergence.
- OMS writes order record and an outbox event into
outbox_eventstable in one local ACID transaction. - A relay poller (CDC or scheduled de-queuer) reads unpublished outbox rows, writes to Kafka with
acks=all, and marks rows processed. - Producer idempotency enabled (
enable.idempotence=true,max.in.flight.requests.per.connection=5).
7.2 Consumer: Idempotent Deduplication
- Natural business deduplication via unique constraint in consumer datastore:
- Table:
processed_events (event_id PRIMARY KEY, processed_at TIMESTAMP, consumer_group VARCHAR(64))
- Table:
- Processing steps:
- Consumer reads message containing
event_id. - Transaction begins: Check existence of
event_idinprocessed_events. - If exists, bypass processing and acknowledge Kafka offset.
- If absent, execute business logic (e.g. stock reservation), insert
event_id, commit transaction, and acknowledge offset.
- Consumer reads message containing
8. Failure, Poison Message, and Replay Strategy
8.1 Error Classification and Handling
| Error Category | Example | Immediate Action | Destination |
|---|---|---|---|
| Transient System | Database deadlock, network timeout | Retry up to 3 times with exponential backoff (100ms, 200ms, 400ms) | In-process |
| Persistent Transient | Downstream system unavailable > 30s | Publish to orders.lifecycle.v1.retry with backoff header | Retry topic |
| Poison Pill | Deserialization failure, schema mismatch, validation violation | Capture error details in header, bypass main offset commit | orders.lifecycle.v1.dlq |
8.2 DLQ Replay Mechanism
- Replay from DLQ requires operator execution via administrative script after schema or bug resolution.
- DLQ messages preserve original
id,traceparent, and appendx-retry-original-topicheader.
9. Governance, Evolution, and Schema Registry
- Registry Mode: Confluent Schema Registry with
BACKWARDcompatibility mode. - Schema Evolution Rules:
- Field removal: forbidden unless deprecated across two major versions.
- Field addition: mandatory default values required for all new fields.
- Enum expansion: new enum values treated as unknown variant on older consumers.
10. Operational Observability and SLA Verification
10.1 Metrics and Monitoring
- Consumer Lag: Alert triggered if consumer lag on
orders.lifecycle.v1exceeds 5,000 records or consumer lead time exceeds 300 ms. - End-to-End Latency Metric: Measured via
timefield in CloudEvents envelope against consumer processing commit timestamp. SLA threshold: p95 <= 500 ms.
Appendix A: Decision Register
| ID | Decision | Chosen Alternative | Rejected Alternatives | Justification |
|---|---|---|---|---|
| DEC-EDA-01 | State Publishing | Transactional Outbox | Direct Dual-Write, 2PC / XA | Dual-write risks data inconsistency on broker failure; 2PC unsupported by Kafka. |
| DEC-EDA-02 | Partitioning Key | order_id | customer_id, sku | sku would create partition hotspots during flash promotions; order_id provides even balancing. |
| DEC-EDA-03 | Message Format | CloudEvents v1.0 JSON | Custom Avro, gRPC | Open interoperability across polyglot microservices without vendor-locked client bindings. |
Appendix B: Traceability Matrix
| Requirement / Tension | Specification Section | Resolution & Coverage |
|---|---|---|
| Peak 1,200 orders/sec | Section 4.2 | 12 Kafka partitions @ 100 msg/sec budget |
| Stock over-allocation | Section 6.1 & 7.2 | Keyed by order_id with idempotent DB transactions |
| Latency p95 <= 500 ms | Section 4.2 & 10.1 | Partition distribution and consumer lag alerting at 300 ms |
| Synchronous payment tension | Section 3.1 & 7.1 | Decoupled via OrderPlaced event; inventory & billing react concurrently |
Verification
No external automated validator was supplied; manual structural self-check executed:
- Adheres to standard 10-section EDA architectural template.
- All technical limits derived from provided intake metrics (1,200 peak msg/sec, 12 partitions derived via 100 msg/sec per-partition limit).
- Contains no self-granted approvals; recommendations submitted for Architecture Guild ratification.
Next steps
- Present topic topology and partition plan (DEC-EDA-02) to Core Architecture Guild for formal sign-off.
- Align Payments and Inventory engineering leads on asynchronous compensation flows in case of payment rejection post-inventory reservation.
- Validate CDC / Outbox table schema with database administration team to verify WAL generation overhead under 1,200 msg/sec peak write bursts.
Connects securely to your tools. The creator never sees your data.
What you get
About this skill
What it does
This skill owns the application-architecture decision for asynchronous communication among independently executing components. It defines message intent, producer and consumer ownership, topology, publication and delivery semantics, ordering, compatibility, failure containment, replay, backpressure, projections, and operations while preserving domain-event meaning and workflow authority.
Use it when
- One accepted fact must trigger independent reactions without making the producer know or wait for all consumers
- Work should survive producer/consumer downtime, absorb bursts, or execute asynchronously with explicit completion semantics
- Point-to-point work distribution, publish/subscribe fan-out, retained event log, stream processing, or asynchronous request/reply must be selected
- State commit and event/message publication need crash-safe atomic-intent semantics such as an outbox or another evidenced mechanism
- At-most-once or at-least-once delivery, duplicate attempts, idempotent effects, acknowledgments, offsets/checkpoints, and uncertain commits need design
- Ordering scope, partition/routing key, concurrency, late or missing events, event time, replay, or projection rebuild affect correctness
For example: “Our warehouse system publishes 'inventory.changed' with the whole item record. Five consumers each diff it, two of them act twice, and a stock correction triggered 40,000 reprice jobs.”
What you get
- architecture/event-driven-architect/README.md
- architecture/event-driven-architect/00-overview/event-driven-architect-overview.md
- architecture/event-driven-architect/verification/fitness-self-check.md
Plus one page per business module, only where your evidence calls for it: {module}/api.md, {module}/events.md, {module}/clients.md, {module}/data.md, {module}/security.md, {module}/observability.md, {module}/resilience.md.
All paths are relative to the output folder you choose.
What it will not do
Do not use for one domain event definition, synchronous API calls, workflow orchestration, webhook implementation, stream analytics alone, broker provisioning, or choosing Kafka/RabbitMQ from keywords such as event-driven or real-time.
How it works
- Check the scope is the application's event architecture.
- Distinguish events, commands and queries in the design.
- Fix the event granularity and its ownership.
- State the consistency contract per consumer.
- Design the failure and observability path.
- Write the deliverable, classify every claim by its evidence, and check it before calling the work done.
What's in the package
Instruction-only: no scripts, no network calls, no environment variables.
- LICENSE.txt
- SKILL.md
- agents/openai.yaml
- assets/output-template-artifact.md
- assets/output-template-contract.md
- assets/output-template-domain.md
- assets/output-template-fitness.md
- assets/output-template-mechanism.md
- references/domain-rules.md
- references/operating-rules.md
- references/output-contract.md
How to install
Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.
- 1
Download the ZIP
Free skills download straight away. Paid skills unlock right after purchase.
- 2
Unzip into your skills folder
Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.
- 3
Ask your agent to use it
Restart the agent if it was already running. It picks the skill up automatically - no config needed.
Skills folder by agent
Click the path to copy it. Create the folder if it does not exist yet.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
Fresh listing
Recently published to Agensi
30-day refund
Not a fit? Get your money back
Trust & safety
Security scanned
Verified clean 13 days ago
- Passed all security checks, Safe to install