Prompt Details
Model
(claude-5-opus)
Token size
3,232
Example input
[PROJECT_CONTEXT]: Multi-tenant e-commerce SaaS serving mid-sized online retailers. The platform supports multiple stores, warehouse operators, customer support teams, and administrators. The backend currently processes checkout, orders, inventory, and fulfillment through a shared application.
[ENGINEERING_OBJECTIVE]: Redesign inventory synchronization so that inventory changes from multiple warehouses are processed asynchronously while keeping the existing checkout API backward compatible.
[CURRENT_SYSTEM]: Node.js and TypeScript monolithic backend with PostgreSQL and Redis. Checkout currently performs synchronous inventory updates. Warehouse updates are received through REST APIs. Unit tests exist, but integration coverage is limited. GitHub Actions handles CI/CD. The application is deployed in Docker containers on Kubernetes.
[TARGET_STATE]: Introduce an event-driven inventory synchronization workflow with idempotent event processing, reliable retry behavior, backward-compatible checkout APIs, improved integration coverage, and a rollback strategy that allows the existing synchronous flow to remain available during migration.
[CONSTRAINTS_AND_RESOURCES]: No breaking API changes, no loss of existing order or inventory data, minimal production downtime, rollback must be possible, two backend engineers and one QA engineer are available for two weeks, and the existing PostgreSQL database must remain the system of record.
Example output
AUTONOMOUS CODING ARCHITECTURE REPORT
1. Executive Decision
Implement the event-driven inventory workflow incrementally behind a compatibility boundary rather than replacing synchronous checkout behavior immediately. Preserve PostgreSQL as the system of record, introduce idempotent inventory events, validate the new path against the existing flow, and migrate warehouse synchronization before changing checkout behavior.
2. Requirement Normalization
Objective
Move warehouse inventory synchronization to asynchronous event processing without breaking checkout.
Scope
Event schema, event producer, consumer, idempotency handling, retry behavior, integration tests, observability, and controlled migration.
Out of Scope
Replacing PostgreSQL, redesigning the public checkout API, or rewriting the entire monolith.
Success Conditions
Inventory changes are processed reliably, duplicate events do not create incorrect inventory state, existing checkout clients continue to function, and rollback to the existing synchronization path remains possible.
Blocking Unknowns
Exact warehouse event volume and current transaction boundaries require repository inspection.
Assumptions
The current inventory write path can be isolated behind an application-level service.
3. Current-System Model
Architecture
A shared Node.js/TypeScript application handles checkout, inventory, and warehouse integrations. PostgreSQL stores authoritative inventory and order state while Redis provides supporting infrastructure.
Runtime Topology
Warehouse REST integration → application inventory layer → PostgreSQL.
Checkout → inventory service → PostgreSQL.
Data Flow
Warehouse inventory updates currently enter through REST requests and synchronously update inventory records. Checkout also performs inventory mutations synchronously.
Dependencies
Inventory state is shared by warehouse synchronization and checkout.
Critical Boundaries
The inventory write transaction and checkout behavior are the highest-risk boundaries.
4. Change Impact Analysis
Area Impact Confidence Evidence
Inventory processing High High Current synchronization is synchronous
Checkout API Medium High Must remain backward compatible
Database High High PostgreSQL remains system of record
Redis Medium Medium Existing infrastructure may support event coordination
CI/CD Low High Existing GitHub Actions pipeline
5. Risk Register
Risk Severity Evidence Mitigation Verification Rollback
Duplicate events High Async processing introduces retries Idempotency key and unique event record Duplicate-event integration tests Disable consumer and use existing path
Inventory race conditions High Multiple warehouses can update shared state Transactional update strategy Concurrent integration tests Revert consumer
Checkout incompatibility Critical Checkout depends on inventory state Preserve existing API and compatibility layer Contract tests Restore synchronous path
Event delivery failure High New asynchronous boundary Retry and dead-letter strategy Failure injection tests Disable asynchronous path
6. Atomic Implementation Plan
TASK-001 — Inventory Boundary Baseline
Purpose: Isolate the existing inventory mutation behavior.
Dependencies: None.
Scope: Existing inventory service and related tests.
Implementation: Document current transaction boundaries and establish regression tests around inventory mutation.
Acceptance Criteria:
Existing inventory behavior is captured by tests.
Checkout behavior remains unchanged.
Required Tests: Unit and integration tests.
Regression Scope: Component.
Rollback: Revert test-only changes if necessary.
Risk: Low.
TASK-002 — Event Contract
Purpose: Define a versioned inventory event contract.
Dependencies: TASK-001.
Scope: Event schema and validation.
Implementation: Define event payload, identifier, version, source, timestamp, and inventory-change data.
Acceptance Criteria:
Events validate against the defined schema.
Invalid events are rejected without mutating inventory.
Required Tests: Schema and validation tests.
Regression Scope: Component.
Rollback: Remove unused event contract without affecting checkout.
Risk: Medium.
TASK-003 — Idempotent Event Consumer
Purpose: Process inventory events safely.
Dependencies: TASK-002.
Scope: Consumer and persistence boundary.
Implementation: Add idempotency tracking and transactional inventory updates.
Acceptance Criteria:
Replaying the same event does not duplicate inventory mutation.
Failed processing can be retried safely.
Required Tests: Integration and concurrency tests.
Regression Scope: Service.
Rollback: Disable consumer and retain existing synchronization.
Risk: High.
TASK-004 — Controlled Warehouse Migration
Purpose: Move warehouse updates to the event path.
Dependencies: TASK-003.
Scope: Warehouse integration.
Implementation: Publish events while preserving the existing checkout synchronization path.
Acceptance Criteria:
Warehouse updates reach the new consumer.
Existing checkout tests remain green.
Rollback can disable event consumption.
Required Tests: Integration and regression tests.
Regression Scope: System.
Rollback: Disable event consumer and restore previous synchronization path.
Risk: High.
7. Task Dependency Graph
TASK-001 → TASK-002 → TASK-003 → TASK-004
8. Safety Gate Plan
Pre-Flight
Baseline inventory behavior, verify tests, verify rollback switch, confirm event schema.
In-Flight
Only modify inventory and warehouse synchronization scope. Stop on unexpected checkout changes.
Post-Flight
Run unit, integration, contract, concurrency, and checkout regression tests.
9. Testing and Regression Strategy
The highest regression priority is checkout because it shares the inventory state boundary. Event-specific integration and concurrency tests are required before production migration.
10. Failure and Recovery Strategy
If duplicate processing or inventory inconsistencies occur, disable asynchronous consumption and return to the existing synchronized path while preserving event records for diagnosis.
11. Human Escalation Points
Human approval is required before changing the production inventory write path because inventory correctness is business-critical.
12. Implementation Roadmap
Phase 1: Baseline and event contract.
Phase 2: Consumer and idempotency.
Phase 3: Controlled warehouse migration.
Phase 4: Production validation and gradual expansion.
13. Readiness Assessment
Architecture Confidence: 4/5 — primary boundaries are clear, but repository inspection is required.
Task Atomicity: 5/5 — tasks have isolated responsibilities.
Testability: 5/5 — inventory and event behavior are objectively testable.
Safety: 4/5 — rollback is available through controlled consumer activation.
Rollback Capability: 5/5 — existing synchronous behavior can remain available.
Requirement Traceability: 5/5 — target state directly maps to the task sequence.
Operational Readiness: 3/5 — production event volume and observability require confirmation.
14. Final Recommendation
Adopt the event-driven design incrementally behind a compatibility boundary. Do not remove the existing synchronous checkout path until the asynchronous workflow has passed concurrency, failure, and regression validation.
15. Open Questions
What is the current inventory transaction boundary?
What event volume must the consumer support?
Is there already a durable messaging infrastructure available?
By purchasing this prompt, you agree to our terms of service
CLAUDE-5-OPUS
Transform complex software projects into deterministic AI coding workflows. Analyze system architecture, dependencies, risks, atomic tasks, acceptance criteria, safety gates, testing, rollback, and execution strategy. Built for developers, software architects, AI engineers, and technical teams working on complex codebases.
...more
Added 1 day ago
