nw-sd-patterns-advanced
Installation
SKILL.md
Advanced Distributed Patterns
Event Sourcing
Problem: need audit trail, state reconstruction, temporal queries.
Core idea: store every state change as immutable event, not current state.
Events: [WalletCreated: balance=0] [Deposited: +100] [Transferred: -30] [Deposited: +50]
Current state: 0 + 100 - 30 + 50 = 120
Benefits: complete audit trail | temporal queries ("balance on Jan 15?") | rebuild state from scratch | debug by replay | event-driven architecture
Challenges: computing state requires replaying all events -- use snapshots | schema evolution (events immutable) | store grows indefinitely -- compaction/archiving | eventual consistency for read models
Snapshots: periodically save computed state | current state = latest snapshot + events after it | trade-off: recovery speed vs storage