high complexity extracted Authentication & Access Control Confidence: 100%
5
Components
106
Shared
0
User Stories
Yes
Analyzed

Description

Enforces access boundaries based on the authenticated user's assigned role — Peer Mentor, Coordinator, Organisation Admin, or Global Admin. Each role has a defined set of permitted screens, actions, and data scopes. The mobile app enforces role-based navigation (e.g., Peer Mentors cannot access coordinator-only screens), while the backend validates permissions on every API request. Global Admins are redirected to the admin portal and shown a no-access screen in the mobile app. Organisation context is determined by the user's account, not by a login-time selection.

User Flow

Role-Based Access Control user flow
Click to expand

Analysis

Business Value

Role-based access control is a foundational security requirement for a multi-tenant platform handling sensitive personal data including encrypted assignments, contact health information, and financial expense records. Without RBAC, a Peer Mentor could access coordinator tools, modify other users' data, or view organisation-wide reports — a serious privacy and compliance violation. Proper role enforcement also simplifies the UX by hiding irrelevant features per role, reducing cognitive load for low-digital-skill users. Multi-tenant isolation ensures that an org admin from one organisation cannot access another organisation's data, which is critical for GDPR compliance and partner trust.

Implementation Notes

Roles and permissions are stored in the PostgreSQL database (user_roles, user_role_assignments tables). The JWT access token includes the user's role and organisation ID as claims. The Next.js API validates these claims on every protected endpoint using middleware. In the Flutter app, the current role is loaded into a RoleGuard BLoC after login and stored in a PermissionStore. UI components check the BLoC state to conditionally render or hide features. Route guards in the Flutter navigation stack prevent direct URL navigation to restricted screens. The system supports users with multiple roles (e.g., a Coordinator who is also a Peer Mentor) using the profile-switching feature, with the active role determining current permissions.

Components (111)

User Interface (1)

Service Layer (2)

Data Layer (2)

Shared Components

These components are reused across multiple features

Service Layer (34)

Data Layer (22)

Infrastructure (38)

infrastructure Keychain/Keystore Adapter low Shared infrastructure JWT Claims Extractor low Shared infrastructure Organization Labels Adapter low Shared infrastructure Keychain/Keystore Adapter low Shared infrastructure Auth API Client medium Shared infrastructure REST API Client medium Shared infrastructure WCAG Accessibility Adapter low Shared infrastructure Registration API Client low Shared infrastructure Accounting API Client high Shared infrastructure PDF Renderer Adapter medium Shared infrastructure File Share Adapter low Shared infrastructure FCM/APNs Adapter high Shared infrastructure Share Sheet Adapter low Shared infrastructure Share Plus Adapter low Shared infrastructure Platform Accessibility Bridge medium Shared infrastructure Semantics Override Adapter high Shared infrastructure URL Launcher Adapter low Shared infrastructure Markdown Content Renderer low Shared infrastructure Network Connectivity Monitor low Shared infrastructure Expense Receipt Storage Adapter low Shared infrastructure Audit Log Writer low Shared infrastructure Feature Flag Checker low Shared infrastructure Logo Upload Adapter low Shared infrastructure Terminology Constants Registry low Shared infrastructure Feature Flag Cache Adapter low Shared infrastructure Org Scope JWT Resolver medium Shared infrastructure Association Audit Logger low Shared infrastructure Token Blocklist medium Shared infrastructure Analytics Tracker low Shared infrastructure SEO Metadata Config low Shared infrastructure Analytics Tracker low Shared infrastructure Analytics Tracker low Shared infrastructure Sales Analytics Tracker low Shared infrastructure Email Provider Adapter low Shared infrastructure Terms of Service Content Provider low Shared infrastructure Legal PDF Asset Provider low Shared infrastructure Consent-Gated Script Loader low Shared infrastructure Legal Page Layout low Shared

User Stories

No user stories have been generated for this feature yet.