Claude 3.5 Event-Driven Architecture (EDA) & Outbox Pattern
Design fault-tolerant event-driven distributed systems ensuring exactly-once processing semantics, saga orchestrations, and zero message loss.
Parametric Customizer & Compiler Live Tool
Adjust the variables below. The prompt code and API payload update dynamically in real time.
Core domain workflow
Event name and fields
You are a Principal Distributed Systems Architect specializing in Event-Driven Architecture (EDA).
Architect a production-grade, highly resilient event streaming system for {Multi-Tenant B2B SaaS Stripe Payment & Subscription Invoicing} using the Transactional Outbox Pattern and {Apache Kafka (Confluent Cloud with Schema Registry)}.
### MANDATORY ARCHITECTURAL INVARIANTS:
1. **Dual-Write Hazard Elimination**: Never write to the database and publish directly to the message broker in two uncoordinated steps. Use a transactional `outbox` table within the same ACID database transaction.
2. **Consumer Idempotency**: Consumers must enforce deduplication via an `idempotency_keys` table or Redis distributed lock before applying state mutations.
3. **Dead-Letter Queue (DLQ) & Poison Pills**: Implement exponential backoff retry policies (max 5 retries) with automatic routing to a DLQ topic after exhaustion.
4. **Schema Evolution**: Define strict CloudEvents 1.0 JSON schemas with backward compatibility guarantees.
Target Stack & Language: {TypeScript (Node.js 20 ESM with Prisma & KafkaJS)}
Target Event Schema: {subscription.renewed.v1 (tenant_id, invoice_id, amount_cents, currency, timestamp)}
Generate the complete architectural blueprint:
1. PostgreSQL Outbox table schema & trigger/polling worker
2. Idempotent Consumer handler with deduplication logic
3. End-to-end failure mode recovery flow Design bulletproof distributed event-driven systems and outbox architectures.
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.
Transactional Outbox Invariant Guarantees database writes and event publishing occur within a single atomic ACID transaction, eliminating partial failures.
Consumer Idempotency Key Prevents duplicate business processing when Kafka rebalances or re-delivers messages across partition boundaries.
π¬ Frequently Asked Questions
Troubleshooting common edge cases, model incompatibilities, and best practices.
Why is the Transactional Outbox pattern necessary?
Without an outbox, if your application saves to the database but crashes before publishing to Kafka, your system permanently falls out of sync.
Does this work with serverless environments like AWS Lambda or Cloudflare Workers?
Yes, serverless functions can write directly to an outbox table, allowing a scheduled cron worker to flush pending events into the event log.
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.