Files
boc/packages/application/README.md
T
Bernt eab9da0100 PR-002.5: Application Layer — Command/Result pattern, end-to-end flow
- 8 commands (CreateFieldSession, CreateMission, RegisterArtifact,
  CreateObservation, CreateDecisionCase, ApproveDecision, StartReview,
  CompleteReview)
- 4 handlers with validation and orchestration
- Result<T, E> pattern — explicit success/failure, no exceptions
- End-to-end test: Session → Mission → DecisionCase → Approval
- 3 tests proving full flow works in memory
- ADR-007: Command/Result Pattern

Acceptance Criteria:
 CreateFieldSession → CreateMission → CreateDecisionCase → ApproveDecision
 Without PostgreSQL, Redis, S3, API, HTTP, UI
 Business logic verified before infrastructure attached

Next: PR-003 — PostgreSQL adapters (swap InMemory → Postgres)
2026-07-02 15:06:59 +00:00

1.7 KiB

@landvex/application

Application layer — orchestrates domain operations.

Architecture

UI → Application Layer (commands/handlers) → Domain → Repository Interfaces → Adapters

No business logic here. Only orchestration.

Commands

Command Purpose
CreateFieldSessionCommand Start a new field session
CreateMissionCommand Create a mission within a session
RegisterArtifactCommand Register an artifact
CreateObservationCommand Create an observation
CreateDecisionCaseCommand Create a decision case
ApproveDecisionCommand Approve a decision
StartReviewCommand Start a review
CompleteReviewCommand Complete a review

Handlers

Handler Command Result
CreateFieldSessionHandler CreateFieldSessionCommand Result<{ session }>
CreateMissionHandler CreateMissionCommand Result<{ mission }>
CreateDecisionCaseHandler CreateDecisionCaseCommand Result<{ decisionCase }>
ApproveDecisionHandler ApproveDecisionCommand Result<{ decisionCase }>

Result Pattern

const result = await handler.execute(command);

if (result.success) {
  // Use result.data
} else {
  // Handle result.error
}

End-to-End Test

use-cases/end-to-end-flow.test.ts proves the full flow works in memory:

CreateFieldSession → CreateMission → CreateDecisionCase → ApproveDecision

Without PostgreSQL, Redis, S3, API, HTTP, or UI.

Dependencies

  • @landvex/domain — domain objects and factories
  • @landvex/infrastructure — repository interfaces and in-memory adapters