Logo di Backend Event Driven Architecture

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).

Panoramica

Pubblicato daj4flmao
Repositoryagent-skills
Nome della skillbackend-event-driven-architecture
Stelle
41
Fork
6
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da j4flmao su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Backend Event Driven Architecture in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/j4flmao/agent-skills/tree/main/skills/backend/event-driven-architecture
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

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
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Backend Event Driven Architecture in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Backend Event Driven Architecture non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Backend Event Driven Architecture non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

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.

Domande frequenti

Cosa fa la skill IA 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...

Perché usare Backend Event Driven Architecture su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Backend Event Driven Architecture è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Backend Event Driven Architecture in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/j4flmao/agent-skills/tree/main/skills/backend/event-driven-architecture. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Backend Event Driven Architecture?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Backend Event Driven Architecture?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Backend Event Driven Architecture: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Backend Event Driven Architecture è gratuita?

Sì. È pubblicata su GitHub da j4flmao con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇