Domain-Driven Design: Supporting Subdomains, designing capabilities that support the business without overengineering.
Design returns management in proportion to its rules and risks. Learn to choose functions, small models, automations, or existing tools, with TypeScript, proposed tests, and criteria for evolving without overengineering.
The indicator keeps the furthest percentage explored; marking the article complete is your choice.
Returns do not differentiate the store, but can bring it to a halt
The store in the previous article differentiates itself through personalized recommendations. However, its operators still review returns by looking up orders, counting units, and consulting instructions that differ between documents.
The team proposes automating this work. One option is to build a returns platform with a configurable rules engine, multiple services, and an event bus. Another is to add conditions directly to the administrative screen.
Between them is an alternative: model the necessary rules clearly with a proportionate implementation.
A Supporting Subdomain can contain business-specific knowledge and need custom development without becoming the primary focus of differentiation. Designing it well means supporting operations without absorbing complexity the requirements do not justify.
What characterizes a supporting subdomain
Supporting Subdomains maintain capabilities needed to operate, although they do not constitute the differentiating advantage sought by the organization. They may require their own rules, adaptations, and specialized maintenance. Microsoft documentation uses this distinction compared with core capabilities and generic problems already solved in the industry. Domain analysis.
This classification reflects its current strategy. A company whose main offering was managing returns for other stores might classify that capability differently.
Nor does “supporting” mean customer support. The word describes its strategic role, not a department.
It is not a folder or a layer
Supporting Subdomain classifies a business capability. A Bounded Context defines the boundaries of a model for solving problems; there is no automatic correspondence between them.
Creating src/supporting does not determine the solution's quality or scope. A supporting capability may be solved in a limited module, need a broader model, or rely on an existing tool.
Proportionality does not mean low quality
Returns can affect money, inventory, and customer trust. A failure can cost more than a temporary improvement to the recommender.
It is therefore useful to separate three dimensions:
Strategic role: how much it contributes to differentiation.
Criticality: the consequences of an error or interruption.
Actual complexity: the rules, states, and coordination it must handle.
A critical supporting process requires appropriate controls, tests, and operations. The label does not authorize omitting security, traceability, or rule review.
Proportionality means not adding mechanisms that address no need. It does not mean reducing the guarantees necessary to fulfill the responsibility correctly.
Evans proposes concentrating specialized design in the core and justifying effort elsewhere by how it supports the core. This guides priorities; it does not turn supporting components into disposable work. DDD Reference: Core Domain.
Identify the operational problem before choosing patterns
Store operators describe three difficulties:
They do not know how many units of a line already have an admitted return.
Damage requests need review and get mixed with ordinary commercial returns.
There is no record of which rule was applied when admitting a request.
The first delivery does not need to predict fraud or design a platform for other companies. It needs to evaluate a specific policy and record decisions.
Cases that change scope must also be clarified: partially returned lines, orders with separate deliveries, replacements, and simultaneous requests.
Not all require fully automated solutions from the start. But they must not disappear because a screen or field is missing.
A teaching policy with explicit boundaries
For the example we will use a fictional commercial policy:
Ordinary intake is evaluated for delivered units without a previously admitted return.
The commercial window is 30 complete periods of 24 hours from delivery, including the final instant.
A damage request is referred for review.
An opened product is also referred for review in this simplified flow.
Meeting the conditions permits admitting the request for intake, not authorizing a refund.
This does not represent a legal time limit or cover warranties or other obligations, which must be evaluated separately with the relevant responsible people. The code illustrates a limited operational decision, not a real policy ready to adopt.
Defining the window in elapsed hours avoids mixing it with local calendar days. If the business works with civil dates, another rule will be needed.
Orders with partial deliveries require facts per unit or delivery. The simplified version assumes the evaluated line has a single delivery instant.
The block is self-contained as teaching logic and uses no external dependencies. It assumes enumerated values were validated at runtime before calling the function: TypeScript does not validate JSON.
Delivery facts and purchased units must come from authoritative sources, not values freely submitted by the applicant. The system must set the request receipt instant according to the operational agreement.
The function does not depend on the database, global clock, or recommender. It receives facts and returns a testable decision.
Names matter. ELIGIBLE_FOR_INTAKE does not mean REFUND_APPROVED. Confusing them would create a business error even if the code were simple.
Rule precedence is also knowledge
Damage is referred for review before applying the ordinary commercial window. We are not claiming that a damage claim should be rejected for exceeding that window.
An invalid quantity, however, is not accepted merely by indicating damage. First we check that the request is consistent with the units considered.
Precedence must be discussed with the people managing the process and tested. It is not a detail AI should choose intuitively.
Test what can cause errors
This test example uses Node.js built-in APIs. It assumes TypeScript compilation to JavaScript ESM and complements the previous file. These are proposed tests; they have not been run as part of the article.
The tests document boundaries and precedence. They do not test authentication, persistence, or behavior under concurrent requests.
Adding an abstract class for each condition would not provide those guarantees. Identify where they are needed and verify them in the corresponding implementation.
From function to real process
An operational delivery needs to connect the rule with everyday work:
Authenticate and authorize whoever submits or reviews the request.
Validate the format and obtain reliable facts about the delivered line.
Identify whether the same request already exists.
Evaluate and record the decision with the applicable policy version.
Admit or refer for review according to the process.
Present an understandable result to the operator or applicant.
The decision and reservation of admitted units must be recorded with concurrency protection. If two requests read the same balance and then modify it without coordination, the pure function does not prevent both from consuming the same units.
Also define when an admission stops consuming units, for example upon cancellation, and how its history is preserved.
These requirements can be addressed with an application and suitable local transactions. They do not automatically require introducing distributed services.
If facts come from another context, explicit contracts and consumer translation are needed. An HTTP query does not share the local transaction. The design must recognize how it verifies or reconciles the facts used.
We do not implement that storage or an endpoint here: showing a function is not equivalent to delivering the complete returns system.
Compare a proportionate solution with an overengineered one
For the first version, one possible organization would be:
The names are illustrative. The rule, coordination, input, and persistence have clear responsibilities without needing an extensive hierarchy.
A more complex proposal might include:
Universal policy engine
-> condition plugins
-> rules compiler
-> decision bus
-> separate services per condition
Those elements are not wrong by definition. They could make sense with many policies, nontechnical owners who must edit them, or concrete scale and isolation needs.
For our initial rule, they add mechanisms the problem does not yet require. Their cost includes testing the engine itself, operations, and team learning.
The useful comparison is not “function good, architecture bad.” It is identifying which requirement justifies each piece and which risk it addresses.
A technical decision matrix
As initial guidance for this capability:
Observed situation Initial alternative
Few stable rules Function or small model with tests
Repeated administrative steps Limited, auditable automation
Tool that fits Configuration and limited adaptation
Many relevant transitions Explicit model of states and permissions
Operator-editable rules Evaluate governed configuration
Actual cross-system coordination Necessary contracts and failure handling
It is not an automatic recipe. Selection must be checked against criticality, volume, frequency of change, and maintenance capacity.
If rules grow and valid transitions become hard to express, introducing a richer model can reduce complexity. Doing so does not require making every element of DDD's tactical catalog mandatory.
The criterion remains process clarity and correctness, not keeping the fewest files forever.
Buy, adapt, or develop
An existing tool may cover request tracking, forms, and operator work. Before building, check whether it can express specific rules, export records, and maintain necessary controls.
Do not assume an available solution fits because it uses the word “returns.” Evaluate it with examples from your process.
Limited development may be reasonable if the differences are small and maintenance is understood. It need not become a platform configurable for any store.
A tool can also be combined with a small custom policy. The boundary must be clear to avoid duplicating the same decision in two places.
A real evaluation requires comparing current alternatives and full costs. This article does not recommend specific products or claim to have researched their features.
Supporting capabilities need owners and operations
An abandoned supporting capability can end up consuming more time than adequate initial investment.
Define who is responsible for:
Rule changes and their approval.
Reviewing cases referred manually.
Recording and retaining decisions.
Operational errors and agreed response times.
Data access and permissions.
Tests and dependency maintenance.
There is no need to promise service levels that have not been agreed. Exceptions do need a real destination.
A MANUAL_REVIEW decision without an inbox or an owner does not solve the problem: it only moves it outside the code.
Keep returns from invading the core domain
Recommendations may need to learn that a product is frequently returned for incompatibility. That does not mean they should import return intake rules.
If that data is necessary, define what information may be shared, with what meaning, and under which controls. The recommender does not need to read all operators' private notes.
Likewise, changing recommender prioritization should not change the commercial return window through an accidental dependency.
Maintaining boundaries lets each capability evolve for its own reasons. Strategic classification does not replace designing those relationships.
A supporting capability can change roles
Imagine the store starts differentiating itself through recovering products, assessing their condition, and reselling them with an exceptional experience.
Return classification and disposition might stop being merely operational work and become strategic knowledge for the new offering.
Renaming the folder would not suffice. Investment, data, collaboration with specialists, and experimentation capabilities would need review.
The category is reviewed when strategy or evidence changes. It must not be used to deny a necessary improvement by saying “it was always supporting.”
The contrast in an educational platform
In a platform centered on adaptive practice, managing requests to change groups may be supporting: it needs its own rules, but is not the main reason students choose the product.
An implementation with validations, understandable states, and exception review may suffice.
In another organization competing on reallocating students among compatible groups and optimizing personalized schedules, part of that same capability could be central to its offering.
It does not change because the code is longer. It changes because the outcome and specialized knowledge have a different strategic role.
As a third contrast, a company dedicated to managing administrative operations for educational institutions may find differentiation in automations that are supporting for those institutions. Classification depends on the organization being analyzed.
Common mistakes when implementing supporting capabilities
Everything must be CRUD. If rules and transitions exist, hiding them in controllers can make the process harder to understand.
Everything needs a complex model. A limited policy can be expressed with types, a function, and tests before needing further abstractions.
Supporting means no tests. Quantity errors or operational decisions can be critical even if they do not differentiate the business.
Automate every exception. Well-defined human review can be a safer initial solution than incomplete rules, provided it has owners and actual capacity.
Create a universal tool. Designing for imaginary organizations can divert effort from the current problem.
Leave rules in several places. If the interface, automation, and backend apply different versions, apparent simplicity conceals duplicated responsibility.
Use AI to accelerate within a clear scope
For Cursor, Claude, or Codex, describe rules and boundaries before requesting an implementation.
To choose a solution:
Analyze these return intake rules and the operator workflow. Propose the smallest implementation that preserves quantities, permissions, and traceability. Distinguish confirmed requirements from open questions. Do not add microservices or a universal engine without a concrete need.
To implement the policy:
Implement a TypeScript function with input facts and explicit decisions. Use the attached fictional commercial policy; do not invent legal time limits. Test the boundary instant, partial quantities, and damage review priority. Do not implement refunds or assume the function resolves concurrency.
To review:
Look for duplicated rules, units trusted from the client, states without an owner, and abstractions that address no requirements. Separate what unit tests cover from what requires persistence and concurrency control. Explain what to correct before automating a decision.
A person must validate the policy, operational scope, and applicable obligations. Generated code can accelerate the wrong solution if those decisions are missing.
Exercises
1. The mandatory aggregate
The policy has three stable decisions. The team proposes several aggregates and distributed events because the project uses DDD. What justification is missing?
2. Two simultaneous requests
One unit remains admissible and two requests for one unit arrive. Each passes the evaluation function with the same facts. Is the policy necessarily wrong?
3. Supporting becomes the offering
A platform starts selling its ability to reassign groups and schedules as the main reason to subscribe. What must be reviewed?
Reasoned solutions
1. Identify which rule, risk, or operational need each mechanism addresses. Using DDD does not require implementing all its patterns. A small tested policy may suffice.
2. Not necessarily. Evaluation may be correct for the received facts, but recording and updating must be coordinated so both requests do not consume the same unit. Function tests do not replace that control.
3. Its strategic classification, the knowledge the model needs, and investment to improve it. The capability can move from supporting to differentiating; the change requires evidence and concrete decisions, not merely another label.
Support the business without manufacturing complexity
A Supporting Subdomain deserves a solution that does its job well, preserves its rules, and can be maintained at reasonable cost.
Start with actual decisions and risks. Add structure when it makes the process clearer or safer, and retain an evolution path when the business changes.
Proportionality is evident when you can explain which need each part addresses and which guarantees remain pending.
Integrate the collection by building an order API with TypeScript, Express, Zod, and SQLite. Includes project files, domain rules, events, version control, Vitest tests, and commands to run and verify it locally.
Learn to guide AI agents with business rules, context boundaries, and verifiable criteria. A TypeScript case shows how to prepare instructions, protect Order, design tests, and review changes without delegating architectural judgment.
Compare a modular monolith with separating Sales, Payments, and Inventory. Design contracts in TypeScript and Express and understand partial failures, eventual consistency, idempotency, Outbox, and Sagas without introducing complex infrastructure.