Frameworks provide useful adapters for HTTP, persistence and messaging. Business rules become harder to reuse when they depend directly on controller globals, ORM lifecycle callbacks or framework facades.
Identify the core rule
Describe the rule in terms of business inputs and outputs. It should not need an HTTP request object, a template engine or a database connection merely to decide whether an operation is valid.
Define application boundaries
An application service coordinates the use case. Repositories or gateways provide required data and external operations. Framework controllers translate HTTP requests into application calls and map results to responses. ORM models remain persistence-oriented rather than becoming the only place where all business behavior lives.
Avoid architecture by ceremony
Do not create interfaces and layers for every trivial operation. Add a boundary when it protects a meaningful rule, supports multiple adapters or makes testing substantially clearer.
Test the rule directly
Use fast unit tests for deterministic domain behavior and integration tests for persistence and framework wiring. This provides confidence without requiring every test to boot the full application.
Further reading
- Martin Fowler, Patterns of Enterprise Application Architecture: https://martinfowler.com/eaaCatalog/