ddd-patterns
Domain-Driven Design (DDD): Advanced Patterns
Advanced integration patterns for handling complex distributed system interactions and transactional consistency.
🚀 Advanced Patterns
- CQRS (Command Query Responsibility Segregation): Separation of write (Command) and read (Query) models to optimize performance and scalability.
- Event Sourcing: Capturing all changes to the state of an application as a sequence of events (The current state is reconstructed from the log).
- Outbox Pattern: Ensuring transactional consistency between a database and a message broker. (Save to DB and a 'Message Outbox' in the same transaction).
- ACL (Anti-Corruption Layer): Translating and isolating external systems' models to maintain the integrity of your core domain model.
⚡ CQRS + Event Sourcing Workflow
- Command Side: Receives request -> Aggregate Root (AR) validates -> AR emits Event -> Event saved to Event Store.
- Projection Side: Projector listens to Events -> Updates Read Model (Optimized for queries: e.g., Elasticsearch, Read DB).
- Query Side: Reads from Read Model only.
🚫 Advanced Anti-Patterns
- Premature CQRS: Adding CQRS to simple systems. (Increases complexity needlessly).
- The Giant Event: Capturing too much state in a single event. (Events should be granular business facts).
- Ignoring Eventual Consistency: Forgetting that Read Models may be out of sync for a short time. Solution: Compensating actions or UI feedback.
🔗 Integration Checklist
- Is the Outbox pattern used for cross-container communication?
- Is the ACL properly shielding the Core Domain?
- Are events immutable and versioned?
More from kinhluan/skills
scheduling-algorithms
Job scheduling algorithms for parallel and distributed systems
5ddd-core
Professional Strategic Domain-Driven Design (DDD) Hub. Use this skill for Event Storming, identifying Subdomains, defining Bounded Contexts, and mapping Domain Models to the heart of your architecture.
4c4-model
Professional C4 model architecture hub for "Design-to-Code Sync". Use this skill to navigate the C4 hierarchy, map diagrams to stakeholders, avoid architectural anti-patterns, and choose the right level for designing or documenting existing codebases.
4ddd-tactical
Tactical Domain-Driven Design (DDD) with Scoring Rubric. Use this skill when designing internal domain models or performing architectural reviews to ensure domain logic is isolated and rich.
4c4-level4-code
Specialized in Code diagrams (Level 4) of the C4 model. Use this skill when the user needs to describe the internal implementation of a component using UML class diagrams or database ER diagrams.
4c4-level2-container
Specialized in Container diagrams (Level 2) with Infrastructure mapping. Use this skill when the user requests decomposing systems into separately deployable units, identifying the tech stack, and mapping infrastructure components (Docker, K8s).
4