Design a domain-driven architecture refactor mapping bounded contexts, aggregate…
- User
Design a domain-driven architecture refactor mapping bounded contexts, aggregate boundaries, and anti-corruption layers.
Assistant
The question/task: Design a domain-driven architecture refactor mapping bounded contexts, aggregate boundaries, and anti-corruption layers.
My reasoning: This request involves designing a strategic refactor using Domain-Driven Design (DDD) patterns. Since you did not provide a specific codebase or system description, I will design a comprehensive architectural refactor for a standard Legacy Monolithic E-Commerce System transforming into a Domain-Driven Modular Structure. This solution maps the theoretical definitions of Bounded Contexts, Aggregates, and Anti-Corruption Layers into a concrete implementation strategy. The Problem Space: "The Big Ball of Mud" We assume the starting point is a legacy monolith where a single
Orderdatabase table drives logic for Shipping, Inventory, and Finance. Phase 1: Mapping Bounded Contexts (Strategic Design)First, we must identify the linguistic boundaries where the same term means different things (Ubiquitous Language). | "Product": A line item for calculating tax and totals.
This request involves designing a strategic refactor using Domain-Driven Design (DDD) patterns. Since you did not provide a specific codebase or system description, I will design a comprehensive architectural refactor for a standard Legacy Monolithic E-Commerce System transforming into a Domain-Driven Modular Structure.
This solution maps the theoretical definitions of Bounded Contexts, Aggregates, and Anti-Corruption Layers into a concrete implementation strategy.
Domain-Driven Architecture Refactor Design
1. The Problem Space: "The Big Ball of Mud"
We assume the starting point is a legacy monolith where a single
Orderdatabase table drives logic for Shipping, Inventory, and Finance. Changing a field in theUsertable breaks the Tax calculation logic. The goal is to decouple these domains.Phase 1: Mapping Bounded Contexts (Strategic Design)
First, we must identify the linguistic boundaries where the same term means different things (Ubiquitous Language).
Context Name Responsibility Key Domain Concepts (vs. Legacy) Catalog Context Product information, descriptions, SEO. "Product": A sellable item with a price and title. Inventory Context Stock availability, warehousing. "Product": A physical SKU with a location and quantity count. Order Management The transaction lifecycle. "Product": A snapshot of an item at the time of purchase (immutable). Billing Context Payments, invoices, fraud. "Product": A line item for calculating tax and totals. Strategic Mapping:
- Catalog is
Upstream(Published Language). - Order Management is
Downstream(Conformist or ACL). - Inventory is
Upstreamto Orders butDownstreamto Warehouse logistics.
Phase 2: Defining Aggregate Boundacies (Tactical Design)
Aggregates ensure transactional consistency. A common mistake is creating large clusters. We will apply the "Rule of
- Catalog is
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.