Service Layer
212 components in the service layer layer
Service Layer components contain business logic, orchestrate operations, and provide core application functionality.
Business logic layer that manages the organization selection lifecycle. Loads the list of available organizations, persists the user's choic...
Application-layer service orchestrating authentication flows against the Supabase Auth backend. Abstracts Supabase SDK calls, maps errors to...
Pure validation service containing rules for email format and password constraints. Returns structured validation results consumed by the BL...
BLoC (or Riverpod StateNotifier) managing the complete state of the login form. Handles field input events, triggers validation, dispatches ...
Centralized Supabase session lifecycle manager shared across all authentication methods. Persists, refreshes, and invalidates Supabase JWT s...
Manages the BankID authentication lifecycle through a third-party BankID broker. Initiates the BankID session, validates the resulting asser...
Wraps Flutter's local_auth package to manage device-level biometric authentication for returning users. Checks hardware availability, enroll...
Wraps Flutter's local_auth package to manage device-level biometric authentication for returning users. Checks hardware availability, enroll...
Orchestrates the full Vipps Login OAuth 2.0 PKCE flow. Generates authorization URLs, exchanges authorization codes for tokens, extracts the ...
Core service that wraps the Flutter local_auth package and orchestrates the full biometric authentication flow. Checks device capability, tr...
Listens to Flutter app lifecycle events and decides whether to show the biometric prompt when the app returns to the foreground. Checks if t...
Evaluates whether the current active role is authorized to access a specific screen, action, or data set. Used by route guards, UI condition...
Resolves the authenticated user's role(s) from Supabase user metadata or the roles table immediately after login. Determines which role(s) a...
BLoC/Riverpod-based state manager that holds the current active role and exposes role change events to the widget tree. Acts as the single s...
Service responsible for determining that the current user's role is blocked from mobile access and providing the appropriate admin portal UR...
GoRouter redirect callback that intercepts navigation for users whose role is flagged as mobile-blocked. Acts as a terminal route handler, r...
Bloc/Cubit that owns the complete wizard state machine for the Quick Activity Registration flow. Each wizard step has its own state slice; t...
Business logic layer that validates a complete activity registration payload, applies organisation-specific rules (e.g. compensation eligibi...
Computes and provides pre-filled default values for the wizard, combining today's date and 30-minute duration constants with the last-used a...
Service that reads the JSON metadata column of an activity type and exposes strongly typed accessors for downstream features. Prevents other...
Business logic layer responsible for all CRUD operations on activity types. Enforces organisational scoping (org_id), validates metadata fla...
Validates report field values against org-specific schema rules: required fields, value types, allowed options for checkbox/radio, and date ...
Coordinates the full lifecycle of a post-session report: loading the org schema, initialising form state via Bloc/Riverpod, validating all f...
Fetches the org-specific report field configuration JSON from Supabase and exposes a parsed, typed field schema. Caches the schema locally t...
Converts the 'way forward' entries from a submitted report into trackable coordinator follow-up items. Persists each entry as a separate fol...
Blindeforbundet-specific service managing driver honorarium records and confidentiality declaration lifecycle. Persists honorarium amounts, ...
Service handling the coordinator attestation workflow for expense claims that exceed auto-approval thresholds. Provides methods to fetch the...
BLoC managing all state for the expense registration form including selected expense types, field values, receipt attachment state, and vali...
Orchestrates the end-to-end submission of a validated expense claim. Uploads receipt image to Supabase Storage if present, persists the expe...
Client-side validation service that enforces business rules for expense submissions. Validates mutual exclusion constraints using the expens...
Orchestrates bulk activity creation for multiple peer mentors in a single atomic operation. Invokes a Supabase RPC batch-insert call to crea...
Checks each target peer mentor in a bulk or proxy session against existing activity records to detect potential duplicates before insertion....
Business logic layer for single-proxy activity registration. Builds the activity record with both recorded_by_user_id (coordinator) and peer...
Service that verifies the aggregation logic used by the dashboard exactly matches the counting rules that will be applied at Bufdir export t...
Service that determines the set of chapter IDs a coordinator is authorized to query. Handles NHF's multi-chapter membership (up to 5 chapter...
Riverpod AsyncNotifier that owns the stats loading lifecycle for a given role and time window. Triggers an initial fetch on construction and...
Utility service that converts a TimeWindow enum value into concrete start and end DateTime boundaries for use in database queries. Handles m...
Runs inside the Supabase Edge Function. Queries all activity records for the given scope and period, groups them by peer mentor, and compute...
Phase 3 integration client for submitting export data directly to Bufdir's API once Norse Digital Products completes API negotiations. Desig...
Maps the application's internal activity types to the category codes required by Bufdir. Uses configuration stored in activity_type_configur...
Central service orchestrating the entire Bufdir export workflow. Calls the Supabase Edge Function with org_id, scope_id, and date range, rec...
Lightweight service that serialises the export payload as a UTF-8 CSV file. Acts as a simpler fallback before the Bufdir API is available. E...
Resolves the organisational scope for export queries. Given a scope ID and level (local/region/national), returns all child entity IDs whose...
Server-side service that renders the structured Bufdir export payload into a formatted PDF document. Runs inside the Supabase Edge Function ...
Service layer for coordinator-facing deduplication queue. Queries activities where duplicate_reviewed is false and at least one matching rec...
Business logic layer that invokes the Supabase RPC before the final activity insert to check for conflicts based on the triple constraint: s...
Orchestrates the three resolution paths available to a user when a duplicate is detected: proceed (insert with duplicate_reviewed: true), me...
Business logic layer that fetches and filters the contact list based on the authenticated user's role. Delegates to the contact repository a...
Handles search logic for contacts and peer mentors by name and notes fields. Supports both local in-memory filtering (for small lists) and d...
BLoC/Riverpod-managed service that orchestrates fetching of a contact's full profile, activity history, and assignment status from the repos...
Handles the complete edit flow for contact records: collecting validated form data, submitting updates to the repository, and reporting succ...
Manages the Blindeforbundet-specific workflow for writing read-receipt confirmations back to Supabase when a coordinator accesses an encrypt...
Pure service that derives a MentorStatus enum (active, expiring_soon, expired, paused) from a peer mentor's raw certification expiry date an...
BLoC state management controller for the peer mentor detail screen. Coordinates data fetching from profile, activity log, certification, and...
Orchestrates parallel fetching and merging of data from multiple sources (profile, certification, activity log, assignment history) into the...
Service responsible for delivering push and in-app notifications to coordinators when a peer mentor changes status. Resolves the correct coo...
Core business logic service managing peer mentor status transitions. Enforces valid state machine transitions (active → paused → active, act...
Bloc/Cubit state manager for the multi-chapter membership UI flow, tracking loading, assignment, and validation states during chapter affili...
Compares a pending activity submission against existing activity records for the same contact across all chapters they belong to, checking f...
Business logic layer for managing many-to-many relationships between contacts and chapters. Enforces the maximum of 5 simultaneous chapter a...
Orchestrates search execution, routing queries to Supabase when online or to the local Drift SQLite cache when offline. Handles debouncing, ...
Validates that a proxy activity record correctly attributes the activity to the intended peer mentor and not the coordinator. Also checks fo...
Orchestrates the creation of multiple proxy activity records from a single bulk submission. Iterates over the selected mentor list, creates ...
BLoC state management layer for proxy registration screens. Manages loading states, form validation feedback, mentor selection state, and su...
Core business logic service responsible for creating proxy activity records with dual attribution: the acting coordinator ID and the attribu...
Manages the lifecycle of mentor location consent records, including recording new consent decisions, checking current consent status, and re...
Encapsulates filtering logic for mentor search criteria including availability status and specialization tags. Translates UI filter state in...
Core service responsible for fetching peer mentor locations within a given geographic bounding box and applying filter criteria. Communicate...
Maps each expense type to its reimbursement formula and computes the expected payout for a given selection. Handles per-km rate lookup for m...
Riverpod StateNotifier or BLoC that owns the current expense type selection set and enforces mutual exclusion rules on every toggle event. C...
Provides WCAG 2.2 AA-compliant semantic labels, announcements, and focus management for the expense type picker. Ensures screen readers rece...
Pure Dart service that encodes the compatibility matrix for expense types. Given a set of currently selected types, returns the set of types...
A pure service that applies the organisation-level threshold rule to a pending mileage claim. If the claimed distance is below the configura...
Manages reading and writing the per-user last-used distance so that recurring routes require minimal re-entry. Persists values in local devi...
Orchestrates the full mileage claim submission lifecycle. On submit, it synchronously evaluates the auto-approval threshold against the ente...
Provides reimbursement amount computation logic used both by the real-time widget and the claim submission path. Multiplies the provided dis...
Orchestrates the full receipt capture and upload flow including image selection, client-side compression, Supabase Storage upload, and linki...
Performs client-side image compression before upload to Supabase Storage, reducing file size while preserving legibility for auditing purpos...
Evaluates whether a receipt attachment is required or optional based on the org-configurable monetary threshold (default 100 kr for HLF). Re...
Sends push notifications to the submitting peer mentor when their claim status changes (approved or rejected). Uses Supabase Realtime for re...
Core service implementing the claim finite state machine (draft → submitted → approved | rejected → exported). Evaluates threshold rules on ...
Service layer component that accepts a batch of claim IDs and processes coordinator bulk approvals with per-record error isolation. Reports ...
Shared Dart utility implementing the threshold decision logic used both client-side (immediate UX feedback) and server-side (via Supabase Ed...
Orchestrates the full lifecycle of confidentiality declarations: generating declarations from templates, encrypting and storing them in Supa...
Handles the lightweight e-signature acknowledgement flow, recording a checkbox confirmation and exact UTC timestamp when a driver confirms t...
Sends push notifications or in-app notifications to drivers when a confidentiality declaration is ready for acknowledgement. Tracks delivery...
Encrypts confidentiality declaration content before upload to Supabase Storage, consistent with the encrypted assignment handling requiremen...
Core business logic service for creating and managing driver assignments. Validates fee amounts, links assignments to contacts and expense r...
Provides read access to organization-level feature flags, including the driver administration feature toggle. Used by both UI guards and bac...
Abstract service layer implementing the AccountingExporter interface. Selects the correct org-specific exporter implementation (XledgerExpor...
Service that prevents expense claims from being included in more than one export run. Before generating an export, it filters out claims alr...
Concrete implementation of AccountingExporter for HLF's Dynamics portal integration. Maps approved expense claims to the Dynamics portal's e...
Concrete implementation of AccountingExporter for Blindeforbundet's Xledger accounting system. Maps approved expense claim fields to Xledger...
Core orchestration service that triggers and coordinates the full aggregation pipeline for a given organization and reporting period. Invoke...
Computes participant and activity counts broken down by geographic organizational units (regions, local chapters) as required by Bufdir repo...
Ensures that unique participant counts are accurate by detecting and excluding double-counted records arising from coordinator proxy registr...
Manages the definition and boundaries of Bufdir reporting periods (typically annual). Determines which activity records fall within a given ...
Loads and resolves the list of period presets configured for a specific organization. Handles organizations that have custom agreement dates...
Queries the aggregated activity data to return the number of records that fall within a given date range. Delegates to the Bufdir data aggre...
Validates the selected report period before allowing the user to proceed to export. Checks that the period is complete, that the date range ...
Evaluates each field in the assembled report preview against three rule classes: completeness (non-empty), threshold compliance (value meets...
Orchestrates the assembly of the report preview by combining aggregated data from the Bufdir Data Aggregation feature with the official form...
Transforms raw aggregated numeric data into the ordered section-and-field hierarchy defined by the official Bufdir reporting form. Maintains...
Business logic layer responsible for fetching, filtering, and managing the audit log of generated Bufdir reports. Enforces role-based access...
Service that orchestrates re-generation and re-export of a past Bufdir report using the stored metadata and period parameters. Delegates act...
Manages the distinction between who registered an activity and who it is attributed to. Ensures every proxy entry stores the coordinator's u...
Handles batch submission of the same activity for multiple peer mentors. Runs duplicate detection for every participant, collects all confli...
Detects conflicting activity entries by querying all registrations matching the triple (peer mentor ID, date, activity type) regardless of w...
BLoC managing UI state for both individual proxy and bulk registration flows. Handles loading states, field validation feedback, duplicate c...
Orchestrates the full lifecycle of a single proxy activity registration. Enforces coordinator role authorization, coordinates duplicate chec...
Nightly background service that scans all peer mentor certifications, identifies those expiring within 30 days, triggers auto-pause transiti...
HLF-specific service that synchronizes peer mentor visibility on the public-facing chapter website via webhook or API call to the HLF Dynami...
Core business logic service handling all peer mentor status transitions. Enforces valid state machine transitions (active→paused, paused→act...
Handles dispatch of push and in-app notifications to coordinators when a peer mentor's pause status is activated, lifted, or automatically c...
Generates CSV and Excel exports of org-level data for Bufdir grant reporting and internal governance. Queries activity, reimbursement, and u...
Middleware service that enforces Supabase row-level security policies for org_admin and super_admin roles. Intercepts all admin data queries...
Aggregates KPI metrics across the org hierarchy for dashboard display. Fetches counts of active peer mentors, monthly activities, pending re...
Resolves and traverses the organisation tree structure, supporting both NHF's deeply nested model (national → region → chapter) and flat two...
Business logic layer for creating, updating, deactivating, and role-assigning user accounts within an admin's org scope. Enforces that org_a...
Placeholder service implementing the interface for future REST-based submission directly to Bufdir once they adopt an API. Currently a no-op...
Queries and filters activity records from the database scoped to a specific organisation, date range, and optionally activity type. Returns ...
Maps the app's internal activity data model to Bufdir's required column schema. Supports per-organisation configuration to handle format dif...
Top-level service that coordinates the entire Bufdir export pipeline: querying activity data, applying org-specific column mapping, generati...
Collects document attachments (invitations, screenshots) linked to activities in the export period and bundles them alongside the export fil...
Records an immutable audit entry for every Bufdir export, capturing who triggered the export, the timestamp, organisation, period covered, f...
Orchestrates the full attachment lifecycle: validates file size (max 10 MB) and MIME type, uploads the binary to Supabase Storage, persists ...
Generates time-limited signed URLs for downloading attachment files from the private Supabase Storage bucket. Caches URLs briefly to avoid r...
Flutter BLoC state management for all certification-related UI screens. Handles loading certification data, submitting renewals, and reactin...
Core business logic service for managing peer mentor certifications. Handles creation of new certification records, recording renewals, comp...
Service invoked by the nightly cron job to evaluate upcoming certification expiries and dispatch push notifications and in-app badge updates...
Service responsible for synchronising peer mentor certification status changes with the external HLF Dynamics portal. On expiry or auto-paus...
Core business logic service that fetches and processes aggregated statistics for a coordinator's peer mentor roster. Applies RLS-aware queri...
Fetches and processes individual peer mentor statistics for the personal stats view. Provides the data foundation required for Phase 4 Spoti...
Validates and scopes statistics access based on user role. Coordinators may only see their own peer mentors via Supabase RLS; org admins see...
Parses FCM notification payloads and resolves the target go_router route for deep-link navigation. Handles both foreground taps and cold-sta...
Manages iOS and Android system-level notification permission requests and status checks. Shows a contextual rationale dialog before the syst...
Supabase Edge Function that listens to database change events and dispatches role-aware FCM push notifications. Triggers include new peer me...
Core BLoC-based service coordinating FCM token lifecycle, incoming message handling, and foreground/background notification display via flut...
Responsible for sending reminder and escalation notifications to the correct recipients. Composes the notification payload, delegates to the...
Encapsulates the business logic for determining whether an assignment is overdue for a reminder or escalation. Computes the difference betwe...
Backend service that orchestrates the scheduling and lifecycle of follow-up reminder jobs. Uses Supabase pg_cron or Edge Function cron trigg...
Core service that coordinates the end-to-end certificate expiry notification flow. It receives expiry data from the scheduled edge function,...
Handles the coordinator's ability to acknowledge a certificate lapse for a peer mentor, which clears the persistent notification banner for ...
Service that handles the coordinator-initiated course enrollment prompt from within a certificate expiry notification detail view. It links ...
Service responsible for automatically suppressing expired peer mentors from coordinator views and public chapter website listings when their...
Core service that coordinates the full notification flow when a peer mentor's pause status changes. Resolves the responsible coordinator via...
Builds structured notification payloads for coordinator and peer mentor recipients based on the pause event type. Enforces the 200-character...
Business logic layer for managing organisation-level scenario configurations. Handles reading and writing JSON scenario rule definitions per...
Translates a triggered scenario prompt into a go_router deep-link navigation call that opens the activity registration wizard with pre-fille...
Orchestrates the scheduled evaluation and dispatch of scenario-based prompts. Invoked by a recurring Supabase Edge Function cron job, it fet...
Core service that evaluates scenario rule definitions against recent activity metadata to determine whether a prompt should be generated. Su...
BLoC managing all notification centre state including the feed list, unread count, active filters, and real-time update events. Subscribes t...
Resolves a notification's payload to the correct route and navigates the user to the related entity (assignment, certificate, activity, peer...
Service handling all read-state mutations for notifications — marking individual items read, marking all as read, and clearing all notificat...
Service applying role-based visibility rules to the notification feed. Peer mentors see only their own notifications; coordinators additiona...
Core business logic service that queries the activity database over a rolling 12-month (or configurable half-year) window for a specific pee...
Evaluates a peer mentor's aggregated stats against a predefined set of milestone thresholds (e.g., first session, 10 sessions, 50 hours, 100...
Orchestrates the sharing workflow for the annual summary. Coordinates with the screenshot capture utility to render an off-screen widget to ...
BLoC state management layer for the annual summary screen. Manages loading, period selection, slide state, and share flow events. Coordinate...
Orchestrates the awarding of badges by writing earned records to Supabase with earned_at timestamps and triggering downstream notifications....
Manages the per-organisation configurable badge taxonomy, allowing organisations to define, enable, or disable badge types without code chan...
Server-side Supabase Edge Function that evaluates badge criteria whenever an activity is saved. Checks all configured badge definitions for ...
Computes aggregated activity statistics for a peer mentor required by badge criteria evaluation, including total assignment counts, streak l...
Manages named recognition tiers such as Coordinator of the Year and seasonal awards. Handles tier assignment logic, award period management,...
Analyses per-mentor period summaries against configurable thresholds to classify each mentor as underactive, normal, or overloaded. Results ...
Determines the date ranges for the current and equivalent prior-year periods based on a given period type (half-year or quarterly) and refer...
Sends push notifications to peer mentors and coordinators when their periodic summary is ready. Wraps the shared FCM/APNs delivery infrastru...
Core backend service that orchestrates the production of periodic summaries. Triggered by the summary scheduler, it computes aggregated metr...
Business logic layer for reading, updating, and enforcing notification opt-out preferences per user and scenario type. Acts as the authorita...
Mobile-side service that parses incoming push notification payloads and routes the user to the correct in-app screen. Handles cold-start dee...
Service responsible for generating localised, personalised notification copy for each scenario type. Injects user-specific context values (d...
Core backend service that evaluates scenario conditions against user data and fires notification events when conditions are met. Runs as a S...
Acts as the bridge between recruitment attribution events and the badge and recognition system. Evaluates recruitment milestones against bad...
Tracks the full conversion funnel from referral link click through to completed membership registration. Associates each new member signup w...
Generates, stores, and retrieves unique referral codes tied to individual peer mentor identities. Ensures codes are stable (one per mentor p...
Reads the volunteer's registered activity data and aggregates session count and total duration to pre-populate the calculator inputs. Depend...
Pure client-side service that computes personal and societal benefit metrics from activity inputs and organisation-specific multiplier confi...
Orchestrates capturing the results card as an image and invoking the native platform share sheet. Ensures the share payload includes a descr...
Validates semantic coverage across all app screens during development and QA. Traverses the semantic tree to detect missing labels, empty hi...
Centralizes screen reader focus management for navigation transitions, dialog opens/closes, and dynamic content updates. Ensures that when r...
Detects whether a screen reader (VoiceOver or TalkBack) is active on the device and exposes this state as a reactive stream throughout the a...
Business logic service that intercepts screen reader focus events on fields flagged as sensitive and orchestrates the warning flow. Maintain...
Enforces all cognitive accessibility constraints at the service layer, independent of UI rendering. Validates wizard step counts, choice cou...
Centrally manages all user-facing copy to ensure it meets plain-language guidelines. Provides keyed access to labels, error messages, and he...
BLoC-based state manager for all multi-step wizards, implementing pause-and-resume semantics. Persists partial wizard state locally so users...
Implements the WCAG 2.2 relative luminance and contrast ratio algorithms in Dart. Used both at runtime during token loading and by the CI li...
Manages the relationship between OS-level dynamic type settings and the app's text scale factor. Computes safe per-role scale caps so that s...
Runtime service that applies non-overridable accessibility constraints from the design token layer when building the Flutter theme. Rejects ...
A service layer that enforces gesture-free navigation contracts across the application. It audits route configurations to confirm every rout...
A Riverpod-backed service that tracks and restores per-tab navigation state using StatefulShellRoute branch navigators. Ensures users with m...
A policy-enforcement service that validates whether dictation is permitted in the current application context. Implements the explicit busin...
Core service that wraps the speech_to_text Flutter package to provide a unified interface over iOS SFSpeechRecognizer and Android SpeechReco...
A BLoC/Cubit that owns the dictation state machine for a single free-text field session: idle → requesting-permission → recording → processi...
Service that determines whether an authenticated user holds roles in more than one partner organization and resolves which organizations the...
go_router redirect guard that intercepts navigation for unauthenticated users or users without an active organization context and redirects ...
Orchestrates the organization selection business logic including fetching the active org list, validating that the selected org is active an...
Central service responsible for seeding and maintaining the active tenant context after an organization is selected. Loads organization-spec...
Stateless utility service that applies resolution logic to raw terminology maps: handles missing keys with fallbacks, supports parameterized...
A Riverpod StateNotifier that manages the active organization's terminology map lifecycle. On login it fetches the JSONB terminology map fro...
Orchestrates background synchronization of terminology maps to ensure the local cache stays up to date without blocking the UI. Compares the...
A Riverpod provider that exposes the resolved feature flag map for the currently active organization. Reads flags from the local cache or fe...
A pure service that evaluates phase-based rollout conditions for a feature flag given the current app version and date. Returns whether a fl...
Determines the set of organization units a given user may read or write data for, based on their assignments and role. Used to scope all dat...
Riverpod/BLoC state management for the currently selected chapter context when a user belongs to multiple chapters. Persists selection to lo...
Rolls activity data upward through the hierarchy tree from local chapter level to regional and national levels. Used by reporting and statis...
Core business logic service for managing organization unit trees. Wraps Supabase queries for the recursive adjacency-list table, enforces bu...
Manages the junction table that links users to one or more organization units. Enforces the is_primary constraint (only one primary per user...
Service that loads, caches, and applies per-organization field mappings from the database JSONB column when formatting export payloads. Reso...
Core backend service handling CRUD operations for organization integration configurations. Orchestrates saving integration metadata, credent...
Background service that periodically tests connectivity to configured external systems and records health status. Surfaces connection failur...
Implements the REST API adapter pattern for all supported integration types (Xledger, Dynamics, Cornerstone, Consio, Bufdir). Each adapter e...
Service responsible for triggering integration sync jobs according to configured schedules. Reads sync_schedule configuration per integratio...
Other Component Types
User Interface components handle presentation logic, user interactions, and visual elements of the application.
Data Layer components manage data persistence, storage operations, and data access patterns throughout the application.
Infrastructure components provide foundational utilities, system integrations, and supporting functionality for the application.