Search docs
Docs searchValidation rule
Back to Rule CatalogAP-APP-001Application LayeringController contains business logic
Flags controllers that contain business decisions instead of delegating to application services.
warningviolationNo auto-fix
How to fix
- Move business decisions into an application service.
- Keep the controller focused on transport concerns.
- 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/srcapps/webpackages
Related CLI commands
archpilot validatearchpilot validate --ci