Skip to content

Application Service Implementation Standard

Purpose

Application services execute use cases for a module. They coordinate security context, validation, domain behavior, repositories, events, outbox records, and integration ports.

Responsibilities

Responsibility Standard
Use-case orchestration Execute one command or query responsibility.
Authorization context Ensure Identity, Billing entitlement, and domain policy checks are satisfied.
Transaction boundary Own transaction scope for state-changing use cases.
Domain coordination Load aggregates and invoke domain behavior.
Persistence Use module-owned repositories only.
Event publication Publish past-tense events and write outbox records where required.
Audit Produce audit context for material actions.

Rules

  • Application services do not contain persistence SQL or HTTP details.
  • Commands must not return internal aggregates.
  • Queries must not mutate state.
  • Synchronous cross-module calls require explicit approval and should prefer published application boundaries.
  • Event-driven coordination is preferred for cross-module workflow reactions.
  • AIOS writes become state only through owning application services.

Use-Case Flow

sequenceDiagram
    participant Controller
    participant App as Application Service
    participant Domain
    participant Repo as Repository
    participant Outbox

    Controller->>App: Command or query
    App->>Repo: Load owned state
    App->>Domain: Apply behavior or policy
    App->>Repo: Persist owned state
    App->>Outbox: Record event if required