Skip to main content

System Design Prompt: Event-Driven Microservices Architecture

Design event-driven microservices: event sourcing, CQRS, saga patterns, and eventual consistency with a message broker like Kafka.

Füllen Sie die Platzhalter aus

Edit the values, then copy your finished prompt.

Ihr Prompt
prompt.txt

                                

What this prompt does

This prompt asks the AI to design an event-driven microservices architecture for a [domain] platform built from [services]. It covers ten areas: an event bus on [message_broker], versioned event schemas with Avro or Protobuf, [consistency_pattern] for cross-service consistency, CQRS for [read_heavy_service], the saga pattern for [distributed_transaction], an event store with replay, service discovery and gateway, circuit breakers and bulkheads, distributed tracing with [tracing_tool], and data ownership via bounded contexts.

The structure works because moving from a monolith to events means trading simple transactions for eventual consistency, which is where most designs go wrong. Naming the [services] forces explicit bounded contexts and data ownership. [message_broker] shapes the event-bus and replay capabilities, [consistency_pattern] decides how cross-service writes reconcile, and [distributed_transaction] gives the saga a concrete flow — like reserving inventory, charging payment, then confirming an order — so the compensating-transaction logic is real rather than abstract.

When to use it

  • You're decomposing a monolith and need bounded contexts and data ownership defined
  • You're adopting [message_broker] and want event schema versioning done right
  • You need a saga design for a real [distributed_transaction] with compensation
  • You're applying CQRS to a [read_heavy_service] and want the read/write split justified
  • You need distributed tracing with [tracing_tool] across services
  • You want circuit breaker and bulkhead patterns specified, not assumed

Example output

Expect an architecture doc: a service map with bounded contexts, an event-bus design on [message_broker], versioned event schema examples, a CQRS layout for [read_heavy_service], a saga sequence for [distributed_transaction] with compensating steps, an event-store and replay design, and failure scenarios with rollback strategies. It usually includes an event-flow diagram and calls out where eventual consistency bites.

Pro tips

  • List [services] precisely; vague service names produce blurry bounded contexts and leaky data ownership
  • Make [distributed_transaction] a concrete multi-step flow so the saga's compensating transactions are real and testable
  • Pin [consistency_pattern] deliberately — eventual consistency with compensation is flexible but demands idempotent handlers
  • Choose [message_broker] based on your needs; Kafka's log-replay strengths differ from a traditional queue's
  • Ask the model to expand the failure scenarios; happy-path event flows hide the hard parts
  • Insist on idempotency in every event handler — at-least-once delivery means duplicates will happen

Frequently Asked Questions

Do I have to use Kafka?
No. Kafka is the default `[message_broker]` because its log and replay model suits event sourcing, but the design adapts to alternatives like RabbitMQ, NATS, or Pulsar. Tell the model your broker and it will adjust the event-bus and replay sections accordingly.
How does it handle transactions across services?
It uses the saga pattern for the `[distributed_transaction]` you specify, breaking a cross-service operation into local steps with compensating transactions to undo partial failures. This replaces traditional ACID transactions, which don't span service boundaries.
What is the saga pattern and why use it here?
A saga sequences a distributed transaction as a series of local transactions, each with a compensating action to roll back if a later step fails. It's used because microservices can't share a single database transaction, so you trade atomicity for explicit, recoverable steps.
Will it address eventual consistency problems?
Yes — the `[consistency_pattern]` variable centers the design on eventual consistency and compensating transactions. Expect the model to flag where stale reads can occur, which is exactly why idempotent event handlers are emphasized.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

Mehr in System Design Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support