Search docs
Docs searchValidation category
Application Layering
Review implemented validation rules for controller, service, repository, package, and application responsibility boundaries.
Application Layering findings help teams keep transport, workflow, persistence, and package responsibilities separated.
Overview
Review implemented validation rules for controller, service, repository, package, and application responsibility boundaries.
Application Layering findings help teams keep transport, workflow, persistence, and package responsibilities separated.
Why it matters
Cloud uses this guidance to help teams interpret local validation findings in organization context without turning the docs into implementation notes.
When this domain drifts, findings become harder to triage, ownership becomes less clear, and architecture review depends too much on individual memory.
Good architectural practices
- Thin controllers that delegate business behavior to services.
- Repositories focused on persistence instead of domain decisions.
- Services and packages with clear, cohesive responsibilities.
Common anti-patterns
- Controller contains business logic
- Repository contains business logic
- Service bypasses repository layer
- Package responsibility mismatch
- Service has oversized responsibility
Relationship to other architecture areas
This domain usually overlaps with neighboring validation categories. Use the related pages below to understand the adjacent architecture concerns before changing policy, suppressing a finding, or accepting risk.
Implemented rules
These are the currently implemented rules in this category. Use this table for category-level orientation, then open the Rule Catalog when you need rule-specific examples and remediation guidance.
| Rule ID | Rule title | Category | Severity | Short explanation | Example violation | Remediation guidance | Rule detail |
|---|---|---|---|---|---|---|---|
| AP-APP-001 | Controller contains business logic | Application Layering | warning | Flags controllers that contain business decisions instead of delegating to application services. | A controller computes billing eligibility, writes records, and sends email in the route method. | Move business decisions into an application service. Keep the controller focused on transport concerns. Add focused service tests for the moved behavior. | View rule page |
| AP-APP-002 | Repository contains business logic | Application Layering | warning | Flags repository/data-access code that contains domain or workflow decisions. | OrderRepository decides whether a refund is allowed before updating payment rows. | Move workflow decisions into a service or domain object. Keep repository methods explicit about read/write behavior. Test business branching outside the repository layer. | View rule page |
| AP-APP-003 | Service bypasses repository layer | Application Layering | warning | Flags application services that directly reach persistence APIs where a repository boundary is expected. | BillingService calls prisma.invoice.findMany(...) directly while billing has an InvoiceRepository. | Move the query into the owning repository. Expose a narrow repository method for the service workflow. Keep tenant and transaction handling consistent with adjacent repository methods. | View rule page |
| AP-APP-004 | Package responsibility mismatch | Application Layering | warning | Flags files whose responsibilities do not match the package or module they live in. | A payments package contains user-invitation email workflow code. | Move the file to the package that owns the responsibility. Split shared helpers into a clearer lower-level package. Update imports and module contracts after the move. | View rule page |
| AP-APP-005 | Service has oversized responsibility | Application Layering | warning | Flags services that appear to own too many workflows or responsibilities. | OrganizationService owns billing, invitations, token management, and onboarding side effects. | Group methods by workflow or domain responsibility. Extract focused services for distinct responsibilities. Keep public module exports aligned after extraction. | View rule page |
Related pages
Next steps