Search docs

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

Controller contains business logic

Flags controllers that contain business decisions instead of delegating to application services.

warningviolationNo auto-fix

How to fix

  1. Move business decisions into an application service.
  2. Keep the controller focused on transport concerns.
  3. Add focused service tests for the moved behavior.

What it means

A controller appears to do more than request parsing, authorization handoff, and response shaping.

Why it matters

Keeping controllers thin makes business behavior easier to test, reuse, and govern.

Common causes

  • Validation, branching, or persistence logic was added directly to a route handler.
  • A small endpoint grew without moving behavior into a service.
  • Controller code copied a service workflow inline.

Example bad pattern

A controller computes billing eligibility, writes records, and sends email in the route method.

Example good pattern

The controller validates request shape and calls BillingService.startCheckout(...).

Related files/config

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

Related CLI commands

  • archpilot validate
  • archpilot validate --ci
AP-APP-001 - Controller contains business logic | ArchPilot Docs