Search docs

Docs search
Back to Rule Catalog
AP-DOM-004Domain Model Quality

Domain logic scattered across layers

Flags business rules repeated across controllers, services, repositories, or UI code.

warningviolationNo auto-fix

How to fix

  1. Choose one domain or application boundary for the rule.
  2. Replace duplicated checks with calls to that boundary.
  3. Add tests that cover the centralized rule.

What it means

The same domain decision appears in several layers instead of one authoritative place.

Why it matters

Scattered logic creates inconsistent behavior and makes policy changes expensive.

Common causes

  • A rule was copied into route and UI code.
  • Repositories contain business branches.
  • A domain service was never introduced.

Example bad pattern

Free-plan repository limits are checked separately in UI, API route, and database helper code.

Example good pattern

A plan policy service owns the limit decision and all layers call it.

Related files/config

  • apps/api/src/modules
  • packages

Related CLI commands

  • archpilot validate
  • archpilot validate --ci
AP-DOM-004 - Domain logic scattered across layers | ArchPilot Docs