Claude 3.5 Sonnet Event Sourcing, CQRS & Kafka Transactional Outbox
Design immutable event-driven architectures with strict optimistic concurrency control, aggregate root replay, Kafka partitioning, and read-model projections.
Parametric Customizer & Compiler Live Tool
Adjust the variables below. The prompt code and API payload update dynamically in real time.
Core domain aggregate root
Strict business logic constraints
You are a Principal Distributed Systems Architect and Event-Driven Systems Authority.
Architect an enterprise-grade Event Sourcing and Command Query Responsibility Segregation (CQRS) engine for {Financial Ledger & Multi-Currency Payment Account with Fraud Holds} using {Go (Golang) with pgx, Kafka (segmentio/kafka-go), and Redis}.
### DISTRIBUTED ARCHITECTURE CONSTRAINTS:
1. **Immutable Event Store**: Model append-only event streams in PostgreSQL with aggregate ID, global sequence number, event type, JSON payload, and monotonic versioning for optimistic concurrency control (`EXPECTED_VERSION`).
2. **Transactional Outbox Pattern**: Guarantee at-least-once message delivery by committing events and outbox entries within a single ACID transaction, ingested via Debezium CDC or background polling to Apache Kafka.
3. **Kafka Partitioning Strategy**: Ensure strict in-order processing per aggregate boundary using deterministic partitioning keys (`aggregate_id`).
4. **CQRS Projection Engine**: Build asynchronous read-model projectors (Elasticsearch / Redis / Read-Replica Postgres) with idempotent event deduplication (`event_id` tracking).
5. **Snapshotting & Aggregate Rehydration**: Implement periodic snapshotting every {Every 100 events} events to bound aggregate rehydration latency to <5ms.
Domain Invariants & Business Commands:
{Command: WithdrawFunds(accountId, amount). Invariant: Account balance cannot breach overdraft limit; account must not have active AML freeze flag.}
Read Model Projections:
{PostgreSQL materialized view for real-time customer balance lookup and audit history} Design mission-critical enterprise architectures and distributed event systems with Claude 3.5 Sonnet.
Leonardo Phoenix & Flux: Generate photorealistic studio assets with 150 daily free credits. Zero setup required.
πΈ Real Sample Outputs & Verified Results
Visual evidence and benchmark responses generated using this exact prompt formula.
π¬ Prompt Engineering Anatomy
Why this prompt consistently delivers high-tier results: technical parameter breakdown.
Optimistic Concurrency Control Guarantees that two concurrent write commands cannot interleave events without detecting a version mismatch collision.
Transactional Outbox Pattern Eliminates dual-write anomalies by writing database updates and event messages to the same relational store in a single commit.
π¬ Frequently Asked Questions
Troubleshooting common edge cases, model incompatibilities, and best practices.
Why choose Event Sourcing over classic CRUD?
Event Sourcing provides an immutable, mathematically verifiable audit trail, time-travel debugging, and the ability to rebuild any arbitrary read model from scratch.
How do you handle event schema evolutions (upcasting)?
Claude 3.5 Sonnet structures event payloads with schema versions (v1, v2) and provides pure transformer functions to upcast historic events during aggregate rehydration.
Cursor AI & Claude 3.5 Sonnet Pro Bundle
Supercharge your workflow with instant codebase indexing, multi-file edits, and automated system rules.
Explore Related Coding & Architecture Prompts View all β
Claude 3.5 Sonnet Senior Staff Full-Stack Refactoring Architect
Specialized prompt framework for Claude 3.5 Sonnet and Claude 3.7. Transforms messy legacy codebases into modular, testable, high-performance systems with automated regression tests.
cursorCursor AI (.cursorrules) for Next.js 15, React 19 & Tailwind CSS
Stops Cursor from writing outdated Next.js 13 patterns, Pages Router syntax, or deprecated React hooks. Enforces strict TypeScript, Server Actions, and modular clean architecture.
deepseekDeepSeek-R1 Autonomous Deep Research & Synthesis Engine
DeepSeek-R1 chain-of-thought framework designed to force deep reflection, counterfactual auditing, and hypothesis testing before producing production-ready research reports.