Summary
escrow.service.ts is 1,219 lines handling creation, funding, release, disputes, queries, and expiration in a single file. Decomposing this into focused services improves maintainability and makes all subsequent escrow feature work easier.
Requirements
- Split
escrow.service.ts into focused service classes:
EscrowLifecycleService — create, cancel, expire, state transitions
EscrowFundingService — fund, release milestones, refund
EscrowDisputeService — file dispute, resolve dispute, evidence management
EscrowQueryService — findAll, findOne, findOverview, search, filter
- Maintain the existing
EscrowController API surface (no breaking changes to endpoints)
- Extract shared validation logic into the existing
EscrowStateMachine
- Update the escrow module to register all new services
- Ensure all existing tests still pass after decomposition
Acceptance Criteria
Context
- Current service:
apps/backend/src/modules/escrow/services/escrow.service.ts (1,219 lines)
- State machine:
apps/backend/src/modules/escrow/escrow-state-machine.ts
- Controller:
apps/backend/src/modules/escrow/escrow.controller.ts
Points: 150
Summary
escrow.service.tsis 1,219 lines handling creation, funding, release, disputes, queries, and expiration in a single file. Decomposing this into focused services improves maintainability and makes all subsequent escrow feature work easier.Requirements
escrow.service.tsinto focused service classes:EscrowLifecycleService— create, cancel, expire, state transitionsEscrowFundingService— fund, release milestones, refundEscrowDisputeService— file dispute, resolve dispute, evidence managementEscrowQueryService— findAll, findOne, findOverview, search, filterEscrowControllerAPI surface (no breaking changes to endpoints)EscrowStateMachineAcceptance Criteria
escrow.service.tsis replaced by 4 focused service filesContext
apps/backend/src/modules/escrow/services/escrow.service.ts(1,219 lines)apps/backend/src/modules/escrow/escrow-state-machine.tsapps/backend/src/modules/escrow/escrow.controller.tsPoints: 150