Service Layer medium complexity backend
0
Dependencies
0
Dependents
3
Entities
0
Integrations

Description

Backend service that manages the organizational hierarchy and enforces structural rules. Handles node CRUD, parent-child validation, and aggregation queries used by reporting.

Feature: Multi-Organization Hierarchy

hierarchy-service

Sources & reasoning

Required by NHF's stated structure (§69) and listed as an Admin Portal core capability (§143). Placed in Core Product because the MVP admin scope (§244-247) lists user management and org settings but not hierarchy, and NHF is the org most needing it after MVP launch.

Responsibilities

  • Create, update, move, and delete organizational nodes
  • Validate hierarchy integrity (no cycles, single parent per node)
  • Enforce double-reporting prevention across nodes
  • Resolve subtree membership for scoping users, activities, and reports
  • Expose aggregation queries that roll up data from descendants

Interfaces

createOrgNode(parentId, data): OrgNode
moveOrgNode(nodeId, newParentId): OrgNode
getSubtree(nodeId): OrgNode[]
resolveScopeForUser(userId): NodeId[]
checkDoubleReporting(activityId, nodeId): ValidationResult