Search docs

Docs search
Back to Rule Catalog
AP-APP-002Application Layering

Repository contains business logic

Flags repository/data-access code that contains domain or workflow decisions.

warningviolationNo auto-fix

How to fix

  1. Move workflow decisions into a service or domain object.
  2. Keep repository methods explicit about read/write behavior.
  3. Test business branching outside the repository layer.

What it means

A repository appears to make business decisions while reading or writing data.

Why it matters

Repositories should expose persistence operations without hiding policy or workflow behavior in data access.

Common causes

  • A data helper grew into a workflow.
  • Conditional business rules were placed near database queries.
  • Persistence code performs side effects beyond storage.

Example bad pattern

OrderRepository decides whether a refund is allowed before updating payment rows.

Example good pattern

RefundService decides eligibility, then asks OrderRepository to persist the approved change.

Related files/config

  • apps/api/src
  • apps/web
  • packages

Related CLI commands

  • archpilot validate
  • archpilot validate --ci
AP-APP-002 - Repository contains business logic | ArchPilot Docs