Skip to content

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.

{
"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" }
]
}

Each entry describes a bounded context:

FieldTypeRequiredDescription
namestringYesContext name (e.g., “Accounts”, “Stock”)
typestringYesDDD classification: "core", "supporting", or "generic"
entitiesstring[]YesBusiness entities belonging to this context
aggregateRootstringYesThe primary entity (aggregate root) of this context
locnumberYesLines of code in this context
endpointsnumberYesAPI endpoints owned by this context
couplingobjectYesCoupling metrics (see below)
dependenciesstring[]YesOther contexts this context depends on
godClassesarrayNoFiles exceeding complexity thresholds
FieldTypeDescription
internalnumberInternal cohesion score (0.0 to 1.0). Higher is better.
externalnumberExternal 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).

FieldTypeDescription
filestringPath to the file relative to the project root
locnumberLines of code
functionsnumberNumber 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.

Describes relationships between bounded contexts:

FieldTypeDescription
upstreamstringThe context that provides data/services
downstreamstringThe context that consumes data/services
typestringRelationship type: "conformist", "acl", "partnership", "shared-kernel"
TypeMeaning
conformistDownstream conforms to upstream’s model without translation
aclAnti-Corruption Layer — downstream translates upstream’s model into its own
partnershipBoth contexts evolve together with shared ownership
shared-kernelShared code/model that both contexts depend on
TypeDescriptionExtraction Priority
coreHighest business value. Contains the domain logic that differentiates the product.Extract first (highest value)
supportingSupports the core domain. Necessary but not differentiating.Extract second
genericGeneric functionality (auth, config, notifications). Could be replaced by off-the-shelf.Extract last or replace