Organization Hierarchy Service
Component Detail
Service Layer
high complexity
backend
2
Dependencies
0
Dependents
7
Entities
0
Integrations
Description
Core service managing the three-tier organizational tree of national chapters, regions, and local associations. Handles tree traversal, node resolution, user-to-node assignment, and hierarchical data aggregation for cross-organization reporting. Enforces that every query and mutation is scoped to the authenticated user's authorized organizational nodes.
organization-hierarchy-service
Responsibilities
- Resolve and validate organization node from JWT claims (organization_id, role)
- Traverse the hierarchy tree for admin navigation and report aggregation
- Assign and reassign users to correct organizational nodes
- Aggregate activity and report data across hierarchy levels with authorization checks
- Seed and maintain the known hierarchy for all four organizations at deploy time
Interfaces
getOrganizationTree(rootOrgId: string): OrgNode[]
getNodeById(nodeId: string): OrgNode
getChildNodes(nodeId: string, level: 'region' | 'local_association'): OrgNode[]
getAncestors(nodeId: string): OrgNode[]
assignUserToNode(userId: string, nodeId: string, roleId: string): void
getUserNodes(userId: string): OrgNode[]
aggregateDataAcrossHierarchy(nodeId: string, query: AggregationQuery): AggregatedResult
validateNodeAccess(userId: string, nodeId: string): boolean
seedHierarchy(orgDefinition: OrgHierarchyDefinition): void
getDescendants(nodeId: string): OrgNode[]
resolveActiveTenant(jwtClaims: JwtClaims): TenantContext
Relationships
Dependencies (2)
Components this component depends on
Related Data Entities (7)
Data entities managed by this component