Athas Boilerplate

Backend Patterns

shared

Practical backend architecture patterns for use cases, adapters, and reliability.

Layer ownership

  • application: use-case orchestration and business flow
  • infrastructure: providers, repositories, external integrations
  • interface: transport adapters (oRPC, HTTP/OpenAPI, webhooks)

Core rules

  1. Keep provider SDK calls in infrastructure adapters only.
  2. Keep transport logic out of use cases.
  3. Keep business invariants in application/domain code.
  4. Keep contract/output mapping explicit at adapter boundaries.

Use-case style

  • one primary use-case service per business action
  • commands mutate state, queries read state
  • prefer simple CQS over full CQRS unless proven necessary

Reliability baseline

  • transactional core state changes
  • side effects via async/event handlers when possible
  • fail-fast env validation on startup
  • health/readiness endpoints required for operations

For detailed examples and naming conventions, see docs/architecture/23-backend-patterns.md.

On this page