domains.json
domains.json captures the DDD bounded context map of the legacy system. It tells agents which parts of the codebase belong together, how tightly coupled they are, and what their upstream/downstream relationships look like.
Full Example
Section titled “Full Example”{ "contexts": [ { "name": "Accounts", "type": "core", "entities": ["GLEntry", "SalesInvoice", "PurchaseInvoice", "PaymentEntry", "JournalEntry"], "aggregateRoot": "GLEntry", "loc": 45000, "endpoints": 89, "coupling": { "internal": 0.82, "external": 0.34 }, "dependencies": ["Stock", "Selling", "Buying"], "godClasses": [ { "file": "controllers/accounts_controller.py", "loc": 4412, "functions": 168 } ] }, { "name": "Stock", "type": "supporting", "entities": ["StockEntry", "StockLedgerEntry", "Warehouse", "Item"], "aggregateRoot": "StockEntry", "loc": 28000, "endpoints": 62, "coupling": { "internal": 0.75, "external": 0.41 }, "dependencies": ["Accounts"], "godClasses": [ { "file": "stock/doctype/stock_entry/stock_entry.py", "loc": 4149, "functions": 120 } ] }, { "name": "Setup", "type": "generic", "entities": ["Company", "Currency", "Country"], "aggregateRoot": "Company", "loc": 8000, "endpoints": 15, "coupling": { "internal": 0.90, "external": 0.12 }, "dependencies": [], "godClasses": [] } ], "contextMap": [ { "upstream": "Accounts", "downstream": "Stock", "type": "conformist" }, { "upstream": "Accounts", "downstream": "Selling", "type": "conformist" }, { "upstream": "Setup", "downstream": "Accounts", "type": "shared-kernel" } ]}Interactive Visualization
Section titled “Interactive Visualization”Field Reference
Section titled “Field Reference”contexts Array
Section titled “contexts Array”Each entry describes a bounded context:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Context name (e.g., “Accounts”, “Stock”) |
type | string | Yes | DDD classification: "core", "supporting", or "generic" |
entities | string[] | Yes | Business entities belonging to this context |
aggregateRoot | string | Yes | The primary entity (aggregate root) of this context |
loc | number | Yes | Lines of code in this context |
endpoints | number | Yes | API endpoints owned by this context |
coupling | object | Yes | Coupling metrics (see below) |
dependencies | string[] | Yes | Other contexts this context depends on |
godClasses | array | No | Files exceeding complexity thresholds |
coupling Object
Section titled “coupling Object”| Field | Type | Description |
|---|---|---|
internal | number | Internal cohesion score (0.0 to 1.0). Higher is better. |
external | number | External coupling score (0.0 to 1.0). Lower is better. |
A well-bounded context has high internal cohesion (above 0.7) and low external coupling (below 0.3).
godClasses Array
Section titled “godClasses Array”| Field | Type | Description |
|---|---|---|
file | string | Path to the file relative to the project root |
loc | number | Lines of code |
functions | number | Number of functions/methods |
Files with more than 2,000 LOC or 100 functions should be flagged as God-classes. These typically need decomposition before extraction.
contextMap Array
Section titled “contextMap Array”Describes relationships between bounded contexts:
| Field | Type | Description |
|---|---|---|
upstream | string | The context that provides data/services |
downstream | string | The context that consumes data/services |
type | string | Relationship type: "conformist", "acl", "partnership", "shared-kernel" |
Context Map Relationship Types
Section titled “Context Map Relationship Types”| Type | Meaning |
|---|---|
conformist | Downstream conforms to upstream’s model without translation |
acl | Anti-Corruption Layer — downstream translates upstream’s model into its own |
partnership | Both contexts evolve together with shared ownership |
shared-kernel | Shared code/model that both contexts depend on |
Context Type Guidelines
Section titled “Context Type Guidelines”| Type | Description | Extraction Priority |
|---|---|---|
| core | Highest business value. Contains the domain logic that differentiates the product. | Extract first (highest value) |
| supporting | Supports the core domain. Necessary but not differentiating. | Extract second |
| generic | Generic functionality (auth, config, notifications). Could be replaced by off-the-shelf. | Extract last or replace |
Next Steps
Section titled “Next Steps”- complexity.json — Extraction difficulty tiers
- Context Map Example — Interactive visualization