Peer Mentor
Data Entity
Description
Extended profile entity for users who serve as peer mentors, capturing operational attributes including current status, area, assignment count, and certification summary. Peer mentors are the primary service-delivery resource and their data drives all coordinator management workflows.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Unique identifier for the peer mentor profile record | PKrequiredunique |
user_id |
uuid |
Foreign key to users table. One-to-one relationship: each peer mentor has exactly one user account. UNIQUE constraint enforced at database level. | requiredunique |
organization_id |
uuid |
Foreign key to the primary organization this peer mentor belongs to. Determines RLS scope, Bufdir reporting attribution, and coordinator assignment. | required |
local_association_id |
uuid |
Foreign key to the local association (lokallag) within the org hierarchy. Used for activity attribution and coordinator scoping in NHF's 1400-lokallag structure. | - |
status |
enum |
Current operational availability status. Drives assignment pool inclusion, map visibility, and coordinator notifications. 'paused' is set mentor-initiated or auto-triggered on certificate expiry (HLF policy). 'inactive' is a terminal state requiring coordinator reactivation. | required |
area |
string |
Human-readable label for the geographic or service area where this peer mentor primarily operates. Used in contact list display, coordinator search/filter, and map view labelling. Organization-specific terminology applies via the Labels system (e.g., 'fylke', 'region', 'distrikt'). | - |
assignment_count |
integer |
Denormalized running total of assignments completed by this peer mentor. Maintained exclusively by a database trigger on the assignments table (increment on insert, decrement on cancellation/delete). Never written directly by application code. Used by Blindeforbundet's honorarium threshold logic: 3rd assignment triggers base honorarium, 15th triggers elevated rate. | required |
honorarium_rate |
decimal |
Current applicable honorarium rate in NOK per assignment, determined by assignment_count threshold tier. Blindeforbundet-specific: rate changes at threshold crossings (0→3 and 3→15 assignments). Recalculated by Honorarium Calculation Service on threshold events. Null before first threshold is crossed. | - |
is_driver |
boolean |
Whether this peer mentor has registered as a volunteer driver. When true, triggers NDA signing requirements and unlocks driver honorarium eligibility at Blindeforbundet. | required |
location_consent_granted |
boolean |
GDPR opt-in flag for home area centroid storage in peer_mentor_locations. Must be explicitly set to true via Privacy Consent Service before any location data is stored. Required for Blindeforbundet geographic matching feature. | required |
certification_summary |
json |
Cached JSON snapshot of active certifications for fast list rendering without join queries. Schema: {has_valid_cert: boolean, expiring_soon: boolean, expired_count: integer, next_expiry_date: string|null}. Invalidated and refreshed by Certificate Service on any certification lifecycle event. | - |
profile_notes |
text |
Coordinator-visible operational notes about this peer mentor. Not surfaced to the mentor themselves. RLS restricts read/write to coordinator and admin roles only. | - |
last_activity_date |
datetime |
Timestamp of the most recently registered activity. Denormalized for fast inactivity detection in coordinator dashboards without aggregating the activities table. Updated on successful activity submission. | - |
created_at |
datetime |
Timestamp when the peer mentor profile was first created. Set automatically on insert by Supabase default. | required |
updated_at |
datetime |
Timestamp of the most recent write to any field in this row. Maintained by a database trigger (moddatetime extension) to support cache invalidation and audit trail. | required |
Database Indexes
idx_peer_mentors_user_id
Columns: user_id
idx_peer_mentors_organization_id
Columns: organization_id
idx_peer_mentors_org_status
Columns: organization_id, status
idx_peer_mentors_local_association_id
Columns: local_association_id
idx_peer_mentors_status
Columns: status
idx_peer_mentors_assignment_count
Columns: assignment_count
idx_peer_mentors_last_activity_date
Columns: last_activity_date
Validation Rules
user_id_references_valid_user
error
Validation failed
organization_id_references_valid_organization
error
Validation failed
assignment_count_non_negative
error
Validation failed
honorarium_rate_non_negative
error
Validation failed
status_transition_validity
error
Validation failed
area_max_length
error
Validation failed
certification_summary_json_schema
warning
Validation failed
unique_user_peer_mentor_mapping
error
Validation failed
Business Rules
one_peer_mentor_profile_per_user
Each user account can have at most one peer mentor profile. Enforced by UNIQUE constraint on user_id at the database level. Attempts to create a second profile for the same user are rejected.
auto_pause_on_certificate_expiry
For HLF, when all active certifications expire, status is automatically set to 'paused' and the mentor is removed from active assignment pools. Certificate Expiry Scheduler runs daily checks; Certificate Service handles real-time expiry events. The mentor also disappears from HLF's public-facing local association listings.
honorarium_threshold_triggers_rate_update
For Blindeforbundet, when assignment_count crosses the 3rd or 15th threshold, honorarium_rate is recalculated by Honorarium Calculation Service and coordinator is notified via Threshold Notification Trigger. Application code must not manually increment assignment_count.
paused_or_inactive_excluded_from_pools
Mentors with status != 'active' must be excluded from assignment target lists, geographic matching results, bulk registration selection, and active mentor card lists. All consumer queries must filter status = 'active' explicitly.
coordinator_notification_on_status_change
When status transitions to 'paused' or 'inactive', the coordinator assigned to that mentor receives a push notification containing the mentor's name and optional pause reason. Ensures coordinators maintain real-time awareness of their active pool size.
driver_requires_valid_nda
A mentor with is_driver = true must have a signed, non-expired NDA on file before receiving driver honorariums or transport assignments at Blindeforbundet. NDA Validation Service gates all driver-specific operations.
location_data_requires_consent
A peer_mentor_locations record may only be created or updated for a mentor where location_consent_granted = true. Privacy Consent Service must record explicit opt-in before Location Repository stores any centroid data. Revoking consent must delete existing location records.
assignment_count_owned_by_trigger
The assignment_count field is a denormalized value managed exclusively by the database-level assignment-count-trigger. No application service or repository may write directly to this field. This is the single source of truth for threshold and dashboard calculations.
CRUD Operations
Storage Configuration
Entity Relationships
Each assignment targets a specific peer mentor as the encrypted payload recipient
Each pairing references the experienced peer mentor acting as the guide in the mentorship scheme
Each pairing references the newer peer mentor receiving guidance as the mentee
A peer mentor may hold multiple certifications for different courses, with HLF policy gating availability on active certificates
Each peer mentor profile is associated with a primary organization for scoping and reporting
A peer mentor has a history of availability status changes tracked for audit and coordinator alerts
A peer mentor may have location records with GDPR consent flags for geographic matching at Blindeforbundet
Each peer mentor has exactly one extended peer mentor profile linked to their user account