Service Layer medium complexity frontendmobile
4
Dependencies
1
Dependents
2
Entities
0
Integrations

Description

BLoC state management controller for the peer mentor detail screen. Coordinates data fetching from profile, activity log, certification, and assignment repositories into a unified screen state. Handles loading, error, and success states with proper event-driven transitions.

Feature: Peer Mentor Profile & Status Screen

peer-mentor-detail-bloc

Summaries

The Peer Mentor Detail BLoC delivers a unified, fast-loading mentor profile experience that builds trust with users seeking peer support. By consolidating data from four distinct sources into a single coherent view, it eliminates the fragmented, slow experiences that drive user abandonment. Organizations benefit from higher mentor engagement rates and reduced support overhead, as users can independently verify mentor credentials, activity history, and availability. The built-in error resilience means partial data outages never result in blank screens, protecting user retention and organizational reputation for reliability.

This medium-complexity BLoC depends on four repositories: peer-mentor, certification-record, mentor-activity-log, and assignment-history. All four must be stable before integration testing can begin, making repository delivery the critical path dependency. Allocate buffer for parallel data-fetch orchestration testing, especially around partial failure scenarios where one repository is unavailable. QA must cover loading, error, success, and pull-to-refresh states.

Deployment is frontend/mobile only with no backend changes required. Regression risk is contained to the peer mentor detail screen.

Implements the BLoC pattern (flutter_bloc) with event-driven state transitions across PeerMentorDetailLoading, PeerMentorDetailSuccess, and PeerMentorDetailError states. Constructor injection of four repositories enables straightforward unit testing with mocks. The LoadMentorDetail event triggers parallel fetches via the aggregation service layer; RefreshMentorDetail re-emits loading and repeats the fetch cycle. State combines PeerMentorProfile, CertificationRecord?, MentorActivitySummary, and List into a single immutable state object.

Graceful degradation per data source is delegated to the aggregation service, keeping BLoC logic clean and focused on state emission only.

Responsibilities

  • Emit loading state on screen mount and trigger parallel data fetches
  • Combine mentor profile, certification, activity summary, and assignments into single state
  • Handle fetch errors per data source with graceful degradation
  • Expose refresh event for pull-to-refresh support

Interfaces

PeerMentorDetailBloc({required PeerMentorRepository mentorRepo, required CertificationRepository certRepo, required ActivityLogRepository activityRepo, required AssignmentRepository assignmentRepo})
add(PeerMentorDetailEvent event)
LoadMentorDetail({required String mentorId})
RefreshMentorDetail()
Stream<PeerMentorDetailState> stream

Relationships

Dependencies (4)

Components this component depends on

Dependents (1)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/peer-mentor-bloc 5 endpoints
GET /api/v1/peer-mentor-bloc/:mentor_id Load full BLoC-driven mentor detail state (profile + certs + activity + assignments merged)
GET /api/v1/peer-mentor-bloc List BLoC-resolved mentor states for org dashboard
POST /api/v1/peer-mentor-bloc Dispatch LoadMentorDetail event — returns initial loading state
PUT /api/v1/peer-mentor-bloc/:mentor_id Dispatch RefreshMentorDetail event — forces re-fetch of all sub-resources
DELETE /api/v1/peer-mentor-bloc/:mentor_id Clear BLoC state cache for a mentor (next GET will reload)