Service Layer low complexity frontendmobile
0
Dependencies
1
Dependents
1
Entities
0
Integrations

Description

Pure service that derives a MentorStatus enum (active, expiring_soon, expired, paused) from a peer mentor's raw certification expiry date and pause flag stored in Supabase. Encapsulates HLF-specific business rules for certification validity windows and suppression logic.

Feature: Peer Mentor Profile & Status Screen

certification-status-service

Summaries

This service enforces the HLF certification compliance rules that protect both mentors and the organizations they serve. By centralizing validity logic, it ensures that expired or lapsing mentors are automatically surfaced to administrators and hidden from public listings before compliance violations occur. This reduces legal and reputational risk for partner organizations while improving the quality and trustworthiness of mentor listings visible to end users. The configurable warning window allows organizations to proactively re-certify mentors, reducing certification lapses and the disruption they cause to ongoing peer support relationships.

A low-complexity, zero-dependency pure service that can be built, tested, and delivered independently of any repository or UI work. No external dependencies means no scheduling risk from third-party delays. Unit test coverage is straightforward: boundary cases around the 30-day warning threshold, null expiry handling, pause flag override, and HLF-specific suppression logic. Because this service is stateless and pure, it can be reviewed and signed off early in the sprint, freeing capacity for higher-risk BLoC and repository work.

No deployment steps beyond including it in the app build.

A stateless pure Dart service with no constructor dependencies, making it trivially injectable and testable. Core method deriveStatus() evaluates isPaused first (short-circuit override), then computes days until expiry via computeDaysUntilExpiry() to classify as active, expiring_soon, or expired. The thresholdDays parameter on isWithinWarningWindow() defaults to 30 but is overridable per call site for future configurability. shouldSuppressFromPublicListing() gates on both MentorStatus and the isHlf flag, encoding the HLF-specific business rule explicitly rather than via generic conditions.

No async operations; all methods are synchronous for predictable performance in the UI render path.

Responsibilities

  • Derive MentorStatus from expiry date with configurable warning threshold (default 30 days)
  • Apply pause flag override regardless of certification state
  • Determine whether mentor should be suppressed from public-facing listings (HLF expired rule)
  • Return days-remaining value for UI countdown display

Interfaces

deriveStatus({DateTime? expiryDate, required bool isPaused})
shouldSuppressFromPublicListing({required MentorStatus status, required bool isHlf})
computeDaysUntilExpiry(DateTime expiryDate)
isWithinWarningWindow(DateTime expiryDate, {int thresholdDays = 30})

Relationships

Dependents (1)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/certification-status 5 endpoints
GET /api/v1/certification-status List derived certification statuses for all mentors in an org
GET /api/v1/certification-status/:mentor_id Get derived certification status for a specific mentor
POST /api/v1/certification-status/derive Derive status from supplied expiry date and paused flag (stateless computation)
PUT /api/v1/certification-status/:mentor_id Recompute and persist derived status for a mentor
DELETE /api/v1/certification-status/:mentor_id Clear cached derived status (forces recompute on next fetch)