Service Layer medium complexity Shared Component backend
0
Dependencies
2
Dependents
2
Entities
0
Integrations

Description

Resolves the organisational scope for export queries. Given a scope ID and level (local/region/national), returns all child entity IDs whose activities should be included. Handles NHF's structure of 12 national associations, 9 regions, and 1,400 local chapters.

Feature: Bufdir Report Export

org-hierarchy-resolver

Summaries

The Organisation Hierarchy Resolver is the backbone of NHF's multi-level reporting capability, enabling national leadership, regional coordinators, and local chapter administrators to each generate reports scoped exactly to their area of responsibility. This directly supports NHF's governance model across 12 national associations, 9 regions, and 1,400 local chapters. Without this component, every export would require manual list construction, which is error-prone and unscalable. It also enforces access boundaries, ensuring that a regional coordinator cannot inadvertently export data from chapters outside their jurisdiction, reducing data governance risk and supporting GDPR compliance obligations.

As a shared component used across multiple features, the Organisation Hierarchy Resolver carries above-average schedule risk: any defect discovered late in testing will affect all export flows simultaneously. It should be prioritised early in the sprint plan and given dedicated integration testing against a representative sample of NHF's actual organisational structure, including edge cases such as chapters with multiple region affiliations or recently migrated entities. The validateUserScopeAccess interface adds a security testing obligation. Plan for coordination with the data team to confirm that the organisation, region, and local-chapter tables are fully populated and correctly structured before end-to-end testing begins.

The Organisation Hierarchy Resolver is a shared backend service that traverses NHF's three-tier organisational tree (national → region → chapter) to expand a single scope ID into the full set of constituent entity IDs required for export queries. It consumes the organisation, region, and local-chapter data models and exposes resolveScopeEntities as the primary interface, plus helper methods for targeted traversal (getChildChapters, getRegionChapters) and access control (validateUserScopeAccess). Because it is shared across export features, implement it as a stateless service with recursive or iterative tree traversal; consider caching resolved scope sets with short TTLs since the hierarchy changes infrequently. The getScopeDisplayName interface supports UI label rendering without duplicating hierarchy logic in frontend code.

Responsibilities

  • Expand scope ID to all constituent child entities
  • Validate user access for requested scope
  • Support all three scope levels (local, region, national)

Interfaces

resolveScopeEntities(scopeId, level)
getChildChapters(regionId)
getRegionChapters(nationalId)
validateUserScopeAccess(userId, scopeId)
getScopeDisplayName(scopeId, level)

Relationships

Dependents (2)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/org-hierarchy 4 endpoints
GET /api/v1/org-hierarchy/scope/:scope_id Resolve all entities under a scope
GET /api/v1/org-hierarchy/regions/:region_id/chapters Get all chapters under a region
GET /api/v1/org-hierarchy/national/:national_id/regions Get all regions and their chapters under national level
POST /api/v1/org-hierarchy/validate-access Validate user's access to a given scope