Prompt Details
Model
(claude-4-7-opus)
Token size
486
Example input
[CURRENT_ARCHITECTURE]: A massive Node.js Express monolith connected to a single 2TB PostgreSQL database.
[CORE_BUSINESS_DOMAIN]: Food Delivery Platform connecting restaurants, customers, and drivers.
[CURRENT_PAIN_POINTS]: Driver location updates are locking the database, causing the checkout process to timeout for customers during peak hours.
[TARGET_STACK]: Go microservices, Kubernetes (GKE), Apache Kafka.
Example output
# Domain-Driven Design Architecture Blueprint
## PHASE 1: DOMAIN ANALYSIS & BOUNDED CONTEXTS
**Core Domain:** Food Delivery Platform.
To decouple the Node.js monolith, we break the system into four distinct Bounded Contexts, ensuring high cohesion within each service and loose coupling between them:
1. **Catalog Context:** Manages restaurant menus, item availability, and pricing.
2. **Order Context:** Handles the customer cart, checkout process, and order state machine.
3. **Delivery Context:** Manages courier dispatch, GPS tracking, and delivery ETAs.
4. **Billing Context:** Handles payment processing, invoices, and restaurant payouts.
## PHASE 2: DATA OWNERSHIP & AGGREGATES
To eliminate the shared PostgreSQL database bottleneck, we implement the "Database-per-Service" pattern.
- **Order Context (Target DB: Amazon Aurora PostgreSQL):**
- Aggregate Root: Order
- Entities: OrderItem, DeliveryAddress
- Constraint: Cannot query the Catalog database for prices. Prices are copied into the OrderItem at the time of checkout for immutability.
- **Catalog Context (Target DB: MongoDB or DynamoDB):**
- Aggregate Root: RestaurantMenu
- Entities: MenuItem, Modifier
- Constraint: Optimized for heavy reads.
- **Delivery Context (Target DB: Redis + PostgreSQL):**
- Aggregate Root: DeliveryTrip
- Entities: Courier, Route
## PHASE 3: MICROSERVICE COMMUNICATION STRATEGY
We will heavily utilize Event-Driven Architecture (Choreography) to avoid tight synchronous coupling.
**Synchronous Communication (gRPC/REST):**
- The API Gateway synchronously queries the Catalog Service to display menus to the user.
**Asynchronous Communication (Apache Kafka):**
- *Event: OrderPlacedEvent* -> Emitted by the Order Context. Consumed by the Billing Context to initiate payment.
- *Event: PaymentSucceededEvent* -> Emitted by Billing Context. Consumed by Order Context to change status to "Preparing", and by Delivery Context to start searching for a nearby courier.
- *Event: CourierAssignedEvent* -> Emitted by Delivery Context. Consumed by Order Context to notify the customer.
## PHASE 4: INCREMENTAL MIGRATION ROADMAP
**Strangler Fig Pattern Implementation:**
1. **Step 1: Event Interception:** Implement Change Data Capture (CDC) using Debezium on the existing monolithic database to broadcast legacy state changes to Kafka.
2. **Step 2: Edge Routing:** Deploy an API Gateway (e.g., Kong) in front of the monolith. Route 100% of traffic to the monolith initially.
3. **Step 3: Extract Catalog:** Build the new Catalog Service in Go. Sync data from the monolith to the new Catalog DB via Kafka. Update the API Gateway to route /api/menus traffic to the new Go service.
4. **Step 4: Extract Delivery:** Build the Delivery Service. It listens to monolith DB events to know when to dispatch drivers.
5. **Step 5: Decommission:** Once all contexts are extracted, the monolith is retired.
By purchasing this prompt, you agree to our terms of service
CLAUDE-4-7-OPUS
Stop building distributed monoliths. This prompt acts as a Principal Software Architect, applying Domain-Driven Design (DDD) principles to help split your monolithic applications into scalable, decoupled microservices. It identifies Bounded Contexts, designs data ownership rules, and defines asynchronous event-driven communication strategies. Designed to assist tech leads and engineering teams in modernizing legacy architectures with clear domain boundaries. No hype, just proven architectural pa
...more
Added 1 week ago
