high complexity extracted Organization Structure & Multi-Tenancy Confidence: 100%
2
Components
58
Shared
0
User Stories
Yes
Analyzed

Description

This feature manages the complex multi-tier organizational structure of the platform, supporting 12 national chapters, 9 regions, and up to 1,400 local associations in a unified hierarchy. It enables proper data isolation and multi-tenancy so that activities, users, and reports are scoped correctly to each organizational level. The system allows administrators to navigate and manage the full tree, assign users to the correct nodes, and run reports that aggregate data across the hierarchy in a controlled and authorized manner.

User Flow

Multi-Organization Hierarchy Management user flow
Click to expand

Analysis

Business Value

Without a correct organizational hierarchy, the platform cannot serve multiple member organizations simultaneously, making this a foundational requirement. Each organization operates independently with its own settings, users, and data, yet the platform must support centralized Bufdir reporting and cross-organization administration. This feature directly enables the business model of selling a single shared platform to multiple organizations (NHF, Blindeforbundet, HLF, Barnekreftforeningen), reducing per-organization infrastructure cost and enabling economies of scale. Incorrect hierarchy handling would cause data leakage between organizations or prevent coordinators from managing their local associations, both of which are critical failures.

Implementation Notes

The hierarchy is modeled as organizations → regions → local_associations with foreign keys enforced at the PostgreSQL level. Row-level security (RLS) or application-level tenancy scoping ensures queries are always filtered by the authenticated user's organizational context. The REST API resolves the active tenant from the JWT claims (organization_id, role) and applies scope to every query. Flutter BLoC state holds the selected organization context and passes it as a header or path parameter on every API request. Admin panel uses Next.js middleware to enforce org-scoped data access. Migrations must seed the known hierarchy for all four organizations at deploy time.

Components (60)

Service Layer (1)

Infrastructure (1)

Shared Components

These components are reused across multiple features

Infrastructure (20)

User Stories

No user stories have been generated for this feature yet.