Backend Event Driven Architecture logo

Backend Event Driven Architecture

Community
j4flmao
backend-event-driven-architecture

Use this skill when the user says 'event-driven architecture', 'EDA', 'publish domain events', 'kafka producer', 'kafka consumer', 'rabbitmq exchange', 'event broker', 'at-least-once delivery', 'event ordering', 'consumer group'. Designs broker-based event flows (Kafka or RabbitMQ): event shape, topic/exchange layout, partitioning for ordering, delivery guarantees, consumer idempotency, retries and dead-lettering, with working producer/consumer code. Do NOT use for: event sourcing as a persistence model (backend-event-sourcing), broker operations and tuning (backend-message-queue), reliable publish from a DB transaction (backend-transactional-outbox), stream processing with Flink/Kafka Streams (backend-data-streaming).

Overview

Publisherj4flmao
Repositoryagent-skills
Skill namebackend-event-driven-architecture
Stars
41
Forks
6
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by j4flmao on GitHub. Read the source before you install it.

Installation

Install the Backend Event Driven Architecture AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/j4flmao/agent-skills/tree/main/skills/backend/event-driven-architecture
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/j4flmao/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/backend/event-driven-architecture .claude/skills/backend-event-driven-architecture
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Backend Event Driven Architecture in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Backend Event Driven Architecture on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Backend Event Driven Architecture is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Event-Driven Architecture

Purpose

Decouple services by having producers publish facts ("OrderPlaced") to a broker and consumers react independently. The skill covers the design decisions that make this reliable in practice: what goes in an event, how ordering and delivery guarantees work, and how consumers stay correct under redelivery.

Agent Protocol

Trigger

Exact user phrases: "event-driven architecture", "EDA", "publish domain events", "kafka producer", "kafka consumer", "rabbitmq exchange", "event broker", "at-least-once delivery", "event ordering", "consumer group".

Input Context

  • Business flow and which services produce/consume.
  • Broker in use or candidates (Kafka, RabbitMQ, cloud: SNS/SQS, Pub/Sub, Event Hubs).
  • Ordering, latency and replay requirements.
  • Language and client library.

Output Artifact

Event catalogue, topology (topics/exchanges, keys, consumer groups), and producer/consumer code. No files unless requested.

Response Format

Event: {PastTenseName} v{n}   Key: {partition key}
Topic/Exchange: {name}         Producers: {svc}   Consumers: {svc,...}
Delivery: at-least-once        Ordering: per {key}
Consumer idempotency: {dedupe table | natural upsert}
Failure: retry {n} with backoff -> DLQ {name}

Core Concepts

ConceptMeaning
Event notificationThin event ("OrderPlaced id=42"); consumers call back for details. Low coupling on schema, higher coupling at runtime
Event-carried state transferEvent carries the data consumers need; no callback; larger payloads, schema is a contract
Command vs eventCommand = request to one handler ("ChargeCard"); event = fact for any number of subscribers ("PaymentCaptured")
Delivery guaranteeBrokers give at-most-once or at-least-once to consumers. "Exactly-once" end to end requires idempotent consumers or transactional read-process-write inside one system (Kafka transactions)

Broker Choice

NeedKafkaRabbitMQ
Replay history / new consumers reading the pastYes (retention-based log)No by default (queues delete on ack); RabbitMQ Streams add a log
Per-key ordering at scaleYes, per partitionPer queue, single active consumer needed for strict order
Flexible routing (topic/headers patterns)Limited (topic per event type)Rich (direct, topic, fanout, headers exchanges)
Per-message TTL, priority, delayed retryNot nativeNative (TTL, priority queues, DLX)
Very high throughput fan-outStrongGood, lower ceiling

Event Design Rules

  1. Name events in past tense for facts that already happened (OrderPlaced, not PlaceOrder).
  2. Include an envelope: event_id (unique, for dedupe), type, version, occurred_at, source, subject/aggregate_id, optional trace_id. CloudEvents is a standard envelope worth adopting.
  3. Choose the partition key = aggregate ID so all events for one entity are ordered.
  4. Evolve schemas backward-compatibly (add optional fields only); use a schema registry (Avro/Protobuf/JSON Schema) for Kafka.
  5. Publish only after the state change is durable. Writing to the DB and the broker in one request without the outbox pattern creates dual-write inconsistencies.

Kafka Producer (Go, confluent-kafka-go v2)

go
package events

import (
	"encoding/json"
	"fmt"

	"github.com/confluentinc/confluent-kafka-go/v2/kafka"
)

type OrderPlaced struct {
	EventID    string `json:"event_id"`
	OrderID    string `json:"order_id"`
	CustomerID string `json:"customer_id"`
	TotalCents int64  `json:"total_cents"`
	OccurredAt string `json:"occurred_at"`
}

func NewProducer(brokers string) (*kafka.Producer, error) {
	return kafka.NewProducer(&kafka.ConfigMap{
		"bootstrap.servers":  brokers,
		"acks":               "all", // wait for in-sync replicas
		"enable.idempotence": true,  // no duplicates from producer retries
		"linger.ms":          5,
	})
}

// PublishOrderPlaced blocks until the broker acknowledges the write.
func PublishOrderPlaced(p *kafka.Producer, topic string, evt OrderPlaced) error {
	payload, err := json.Marshal(evt)
	if err != nil {
		return fmt.Errorf("marshal event %s: %w", evt.EventID, err)
	}
	delivery := make(chan kafka.Event, 1)
	err = p.Produce(&kafka.Message{
		TopicPartition: kafka.TopicPartition{Topic: &topic, Partition: kafka.PartitionAny},
		Key:            []byte(evt.OrderID), // per-order ordering
		Value:          payload,
		Headers:        []kafka.Header{{Key: "type", Value: []byte("OrderPlaced.v1")}},
	}, delivery)
	if err != nil {
		return fmt.Errorf("enqueue event %s: %w", evt.EventID, err)
	}
	m := (<-delivery).(*kafka.Message)
	if m.TopicPartition.Error != nil {
		return fmt.Errorf("deliver event %s: %w", evt.EventID, m.TopicPartition.Error)
	}
	return nil
}

Create one producer per process and reuse it; call p.Flush(timeoutMs) and p.Close() on shutdown.

Kafka Consumer With Manual Commit

go
func Consume(brokers, group, topic string, handle func(*kafka.Message) error) error {
	c, err := kafka.NewConsumer(&kafka.ConfigMap{
		"bootstrap.servers":  brokers,
		"group.id":           group,
		"auto.offset.reset":  "earliest",
		"enable.auto.commit": false, // commit only after successful handling
	})
	if err != nil {
		return fmt.Errorf("create consumer for group %s: %w", group, err)
	}
	defer c.Close()
	if err := c.SubscribeTopics([]string{topic}, nil); err != nil {
		return fmt.Errorf("subscribe %s: %w", topic, err)
	}
	for {
		msg, err := c.ReadMessage(-1)
		if err != nil {
			if kerr, ok := err.(kafka.Error); ok && kerr.IsFatal() {
				return fmt.Errorf("fatal consumer error: %w", err)
			}
			continue // transient errors are retried by the client
		}
		if err := handle(msg); err != nil {
			// Hand off to retry/DLQ topic rather than blocking the partition forever.
			return fmt.Errorf("handle offset %v: %w", msg.TopicPartition, err)
		}
		if _, err := c.CommitMessage(msg); err != nil {
			return fmt.Errorf("commit offset %v: %w", msg.TopicPartition, err)
		}
	}
}

Idempotent Consumer

At-least-once means duplicates will arrive (rebalances, crashes before commit). Make the handler safe:

sql
CREATE TABLE processed_events (
  consumer   text        NOT NULL,
  event_id   text        NOT NULL,
  processed_at timestamptz NOT NULL DEFAULT now(),
  PRIMARY KEY (consumer, event_id)
);
-- In the same transaction as the side effect:
INSERT INTO processed_events (consumer, event_id) VALUES ('billing', $1)
ON CONFLICT DO NOTHING;   -- 0 rows affected => duplicate, skip side effect

Retries and Dead-Lettering

  • Kafka: on failure publish to orders.retry.1m, orders.retry.10m, then orders.dlq, committing the original offset. Blocking retries in place stall the whole partition.
  • RabbitMQ: basic.nack with requeue=false routes to the queue's dead-letter exchange (x-dead-letter-exchange); use TTL queues for delayed retry.
  • Classify errors: validation/poison messages go straight to DLQ; transient (timeouts) retry with exponential backoff and jitter.
  • Alert on DLQ depth and provide a replay tool.

Anti-Patterns

Anti-patternFix
Publishing before DB commit, or DB + broker dual writeTransactional outbox or CDC
Random/null keys when order mattersKey by aggregate ID
Auto-commit with slow handlersManual commit after processing
Events that are disguised RPC ("PleaseSendEmail" awaiting reply)Use a command queue or synchronous call
Breaking schema changes on an existing topicVersion the event type; dual-publish during migration
One giant "events" topic for everythingTopic per event type or bounded context

Checklist

  • Event catalogue with owners, schema versions and keys.
  • Producer: acks=all, idempotence on, publish via outbox.
  • Consumers idempotent; offsets committed after processing.
  • Retry topics/queues and DLQ with alerting and replay.
  • Consumer lag, DLQ depth and end-to-end latency monitored.
  • Trace context propagated in message headers.

References

  • Related skills: skills/backend/universal/event-driven/SKILL.md, skills/backend/universal/message-queue/SKILL.md, skills/backend/universal/transactional-outbox/SKILL.md, skills/backend/universal/event-sourcing/SKILL.md.

Frequently asked questions

What does the Backend Event Driven Architecture AI skill do?

Use this skill when the user says 'event-driven architecture', 'EDA', 'publish domain events', 'kafka producer', 'kafka consumer', 'rabbitmq exchange', 'event broker', 'at-least-once delivery', 'event ordering', 'consumer group'. Designs broker-based event flows (Kafka or RabbitMQ): event shape, topic/exchange layout, partitioning for ordering, delivery guarantees, consumer idempotency, retries and dead-lettering, with working producer/consumer code. Do NOT use for: event sourcing as a persistence model (backend-event-sourcing), broker operations and tuning (backend-message-queue), reliable...

Why use Backend Event Driven Architecture on TypingMind?

Because you install it once and use it with any model. Backend Event Driven Architecture is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Backend Event Driven Architecture in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/j4flmao/agent-skills/tree/main/skills/backend/event-driven-architecture. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Backend Event Driven Architecture?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Backend Event Driven Architecture?

As many as you like. As long as a model supports skills, you can use Backend Event Driven Architecture with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Backend Event Driven Architecture AI skill free?

Yes. It is published on GitHub by j4flmao under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇