Skip to content

ADR-002: Layered architecture with a pure domain core

Status: Accepted

Context

The valuable, error-prone logic is the money math: daily/weekly limits, calendar-week pro-rating, rollover, and settlement. This logic must be trustworthy and independently testable, and it should survive a backend change or a new client.

Decision

Adopt a layered structure (domain, data, application, presentation, shared) with an inward dependency rule. The domain layer is pure TypeScript with no framework imports. Path aliases (@domain, @data, @application, @ui, @shared) enforce intent and keep imports readable.

Consequences

  • Domain logic is unit-tested with zero mocks (44 tests at introduction).
  • A future web client reuses domain and most of application unchanged.
  • Slightly more files/indirection than a flat structure; justified by testability and the planned web target.

Spend together, settle simply.