SKILL.md--- name: event-driven-architecture description: Generic Event-Driven Architecture patterns with Kafka, Dapr, and modern messaging systems. Provides reusable patterns for building scalable, resilient event-driven microservices. Framework-agnostic implementation supporting multiple message brokers, state stores, and event patterns. Follows 2025 best practices for distributed systems. license: MIT --- # Event-Driven Architecture with Modern Patterns This skill provides comprehensive patterns for implementing event-driven microservices using modern messaging systems, distributed runtimes, and cloud-native patterns. It's designed to be framework-agnostic and applicable to any domain requiring event-driven capabilities. ## When to Use This Skill Use this skill when you need to: - Build event-driven microservices architecture - Implement pub/sub patterns with Kafka, RabbitMQ, or cloud services - Use Dapr for distributed application patterns - Implement real-time notifications and workflows - Build recurring task and reminder systems - Create audit trails and activity logs - Implement distributed state management - Build serverless event workflows - Handle event sourcing and CQRS patterns ## 1. Core Event Architecture ### Base Event Schema ```python # events/core.py from pydantic import BaseModel, Field, validator from datetime import datetime from typing import Optional, Dict, Any, Union, List from enum import Enum from abc import ABC, abstractmethod import uuid import json class EventVersion(str, Enum): """Event versioning support""" V1_0 = "1.0" V1_1 = "1.1" V2_0 = "2.0" class EventPriority(str, Enum): """Event priority levels""" LOW = "low" NORMAL = "normal" HIGH = "high" CRITICAL = "critical" class BaseEvent(BaseModel, ABC): """Base event schema with common fields""" # Core identification event_id: str = Field(default_factory=lambda: str(uuid.uuid4())) event_type: str = Field(..., description="Type of the event") event_version: EventVersion = Field(default=EventVersion.V1_0) # Metadata timestamp: datetime = Field(default_factory=datetime.utcnow) correlation_id: Optional[str] = None causation_id: Optional[str] = None # Event that caused this one source: str = Field(..., description="Source service/identifier") # Context user_id: Optional[str] = None tenant_id: Optional[str] = None # Multi-tenant support session_id: Optional[str] = None # Processing metadata priority: EventPriority = Field(default=EventPriority.NORMAL) retry_count: int = Field(default=0) max_retries: int = Field(default=3) delay_until: Optional[datetime] = None # For delayed processing # Schema versioning schema_version: str = Field(default="1.0") class Config: # Allow additional fields for extensibility extra = "allow" # Use enum values use_enum_values = True @validator('event_type') def validate_event_type(cls, v): """Validate event type format""" if not v or '.' not in v: raise Valu