Search docs

Docs search

Domain Model Quality

Review implemented validation rules for anemic models, aggregate boundaries, oversized boundaries, scattered domain logic, and cross-aggregate writes.

Why it matters

Domain Model Quality findings make business responsibilities and aggregate ownership easier to review across modules.

What this category covers

  • Domain objects and services that own business invariants.
  • Aggregate boundaries respected by workflows.
  • Domain logic centralized instead of scattered across layers.

Implemented rules

These are the currently implemented rules in this category. Cloud stores and displays the uploaded findings from local validation; it does not add future or speculative rules.

Rule IDRule titleCategorySeverityShort explanationExample violationRemediation guidance
AP-DOM-001Anemic domain modelDomain Model QualitywarningFlags domain objects that appear to expose data without owning behavior or invariants.Every service checks subscription status differently before changing billing state.Move invariant checks into the domain object or focused domain service. Keep DTOs separate from domain behavior. Add tests around the domain rule being protected.
AP-DOM-002Aggregate boundary violationDomain Model QualitywarningFlags code that reaches across aggregate boundaries instead of using the owning boundary.Billing code directly mutates organization invitation state.Route changes through the aggregate that owns the invariant. Use domain events or application services for cross-aggregate coordination. Keep read models separate from write decisions.
AP-DOM-003Oversized aggregate/service boundaryDomain Model QualitywarningFlags domain or service boundaries that appear too broad for one aggregate responsibility.WorkspaceService owns billing, invitations, repository upload, and policy exceptions.Identify cohesive responsibility groups. Extract separate aggregates or services for unrelated behavior. Keep coordination in application services, not oversized domain objects.
AP-DOM-004Domain logic scattered across layersDomain Model QualitywarningFlags business rules repeated across controllers, services, repositories, or UI code.Free-plan repository limits are checked separately in UI, API route, and database helper code.Choose one domain or application boundary for the rule. Replace duplicated checks with calls to that boundary. Add tests that cover the centralized rule.
AP-DOM-005Cross-aggregate modification riskDomain Model QualitywarningFlags workflows that modify multiple aggregates without clear coordination.One method directly updates organization, billing subscription, and invitation records with no coordination model.Move coordination into an application service. Use events/outbox for eventual consistency when appropriate. Keep each aggregate responsible for its own state changes.
Domain Model Quality | ArchPilot Docs