Event Driven Microservices
# Event-Driven Microservices Architecture
## Objective
Design and implement a production-grade event-driven microservices architecture using message brokers (Kafka/RabbitMQ) with Saga pattern for distributed transactions. The system must be resilient, scalable, and maintain data consistency across service boundaries.
---
## Core Architecture Principles
### Mandatory Requirements
1. **Event-Driven Communication**: Services communicate exclusively through asynchronous events, never direct HTTP calls between services
2. **Saga Pattern**: Implement choreography-based or orchestration-based Saga for distributed transactions
3. **Event Sourcing**: Store state changes as immutable event log for audit and replay capabilities
4. **CQRS**: Separate read and write models for optimal performance and scalability
5. **Idempotency**: All event handlers must be idempotent to handle duplicate messages
---
## Technology Stack
### Message Broker Selection
**Apache Kafka** (High-throughput, event streaming):
- Use for: Event sourcing, real-time analytics, high-volume event streams
- Retention: Configure based on replay requirements (7-30 days typical)
- Partitioning: Partition by aggregate ID for ordering guarantees
**RabbitMQ** (Flexible routing, traditional messaging):
- Use for: Task queues, RPC patterns, complex routing scenarios
- Exchanges: Topic exchange for event broadcasting, direct exchange for commands
- Dead Letter Queues: Configure DLQ for failed message handling
### Core Components
- **Event Store**: EventStoreDB or custom implementation on PostgreSQL
- **Schema Registry**: Confluent Schema Registry or AWS Glue for event schema versioning
- **Service Mesh**: Istio or Linkerd for observability and traffic management
- **Distributed Tracing**: Jaeger or Zipkin for request flow visualization
- **Monitoring**: Prometheus + Grafana for metrics, ELK stack for logs
---
## Event Design Standards
### Event Structurewhen to use it
Community prompt sourced from the open-source GitHub repo Dziqha/awesome-agentic-coding-prompts (MIT). A "Event Driven Microservices" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
roleplaycommunitygeneral
source
Dziqha/awesome-agentic-coding-prompts · MIT