Local Chapter Management Service
Component Detail
Service Layer
medium complexity
backend
2
Dependencies
2
Dependents
2
Entities
0
Integrations
Description
Core backend service that manages the lifecycle of user-to-organization memberships. Enforces the single-primary-membership constraint via atomic transactions and validates that all memberships remain within a single top-level organization tree.
local-chapter-management-service
Responsibilities
- Create and delete organization_memberships rows with duplicate prevention via unique constraint on (user_id, organization_id)
- Atomically unset the previous primary membership and set the new one within a single database transaction
- Validate that the target organization is within the same top-level hierarchy tree before adding a membership
- Enforce the platform cap of five simultaneous memberships per user
- Emit audit log entries for all membership changes
Interfaces
addMember(userId: string, organizationId: string, role: string): Promise<Membership>
removeMember(userId: string, organizationId: string): Promise<void>
setPrimaryMembership(userId: string, organizationId: string): Promise<void>
getMembersForOrganization(organizationId: string, page: number): Promise<MemberPage>
getMembershipsForUser(userId: string): Promise<Membership[]>
validateHierarchyConstraint(userId: string, targetOrgId: string): Promise<boolean>
Relationships
Dependencies (2)
Components this component depends on
Dependents (2)
Components that depend on this component
Related Data Entities (2)
Data entities managed by this component