Search docs
Docs searchValidation rule
Back to Rule CatalogAP-APP-003Application LayeringService bypasses repository layer
Flags application services that directly reach persistence APIs where a repository boundary is expected.
warningviolationNo auto-fix
How to fix
- 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.
What it means
A service appears to bypass the repository/data-access abstraction for its module.
Why it matters
Bypassing repositories scatters persistence behavior and makes transaction, tenant, and query policies harder to enforce.
Common causes
- A service imports the ORM client directly.
- A quick query was added during feature work.
- The repository does not yet expose the needed method.
Example bad pattern
BillingService calls prisma.invoice.findMany(...) directly while billing has an InvoiceRepository.Example good pattern
BillingService calls invoiceRepository.findOpenInvoicesForAccount(...).Related files/config
apps/api/srcapps/webpackages
Related CLI commands
archpilot validatearchpilot validate --ci