high priority low complexity frontend pending frontend specialist Tier 1

Acceptance Criteria

GranularityMode enum defines exactly 3 values: day, week, month
ChartDataPoint freezed class has fields: double x (position on X axis), double y (metric value), DateTime date (the calendar date this point represents), and String label (display label for the X axis tick)
ChartSeries freezed class has fields: String seriesId, String seriesLabel, List<ChartDataPoint> points, and Color color (design token color passed from outside — not hardcoded)
ActivityChartData freezed class has fields: GranularityMode granularity, List<ChartSeries> series, double maxY (pre-computed max for Y axis scaling), String yAxisLabel, String xAxisLabel
All freezed classes generate without errors via build_runner
A static factory ActivityChartData.fromRepositoryResponse(StatsTimeRange range, GranularityMode mode, List<Map<String,dynamic>> rows) correctly maps raw repository data to the chart model without any Flutter or UI imports
fromRepositoryResponse produces ChartDataPoint.label values matching the granularity: 'Mon', 'Tue',… for day; 'W1', 'W2',… for week; 'Jan', 'Feb',… for month
maxY is computed as the maximum y value across all series, rounded up to the nearest 5 (e.g., 23 → 25)
Empty series list results in maxY = 10 (safe default to avoid division-by-zero in chart rendering)
Models exported from a single barrel file alongside stats_types.dart

Technical Requirements

frameworks
Flutter
freezed
build_runner
fl_chart
data models
ChartDataPoint
ChartSeries
ActivityChartData
GranularityMode
StatsTimeRange
performance requirements
fromRepositoryResponse must process up to 365 data points in under 5ms
No unnecessary list copies — use List.unmodifiable for the points field
security requirements
No PII in chart data — only aggregate counts and hours

Execution Context

Execution Tier
Tier 1

Tier 1 - 540 tasks

Can start after Tier 0 completes

Implementation Notes

Place models in lib/features/stats/domain/chart_models.dart. The Color field on ChartSeries should be typed as dart:ui Color — import 'dart:ui' only, not package:flutter/material.dart, so this domain file has zero Flutter framework dependency and can be tested in pure Dart VM. The fromRepositoryResponse factory should accept a List> matching the raw Supabase row format from the stats query (columns: date string ISO-8601, session_count int, total_hours double). Use intl DateFormat for label generation.

The maxY rounding helper should be a private top-level function _roundUpToNearest5(double v).

Testing Requirements

Unit tests only in test/stats/activity_chart_data_test.dart. Required scenarios: (1) fromRepositoryResponse with day granularity produces correct 'Mon'–'Sun' labels; (2) fromRepositoryResponse with month granularity produces correct abbreviated month labels in Norwegian ('jan', 'feb',…) via intl; (3) maxY rounds up to nearest 5 correctly for several input values; (4) maxY defaults to 10 for empty series; (5) equality of two ActivityChartData with identical fields; (6) fromRepositoryResponse with null or missing y-value rows treats missing as 0.0 (no exception thrown). Target 100% branch coverage on fromRepositoryResponse.

Component
Activity Chart Widget
ui medium
Epic Risks (4)
high impact high prob technical

fl_chart renders chart elements on a Canvas, making individual bars and data points invisible to the Flutter Semantics tree by default. Without explicit Semantics wrappers, VoiceOver and TalkBack users receive no chart information, violating the WCAG 2.2 AA requirement mandated by all three partner organizations.

Mitigation & Contingency

Mitigation: Wrap the fl_chart widget in a Semantics node with a dynamically generated textual description of the chart data (e.g., 'Bar chart: January 12, February 8, March 15 sessions'). Implement a collapsible data table alternative beneath the chart that screen readers can navigate row by row. Validate with VoiceOver on iOS and TalkBack on Android before the epic is marked complete.

Contingency: If fl_chart's Canvas rendering cannot be made accessible within the epic timeline, ship the chart hidden from the Semantics tree with ExcludeSemantics and promote the data table alternative to first-class UI so screen reader users have full access to the information. Log a tech-debt item to revisit native chart accessibility in a future sprint.

medium impact medium prob scope

Coordinators managing up to 5 chapters (NHF requirement) require the PeerMentorStatsList to display chapter affiliation labels for each row. With large chapter lists and many peer mentors, the list could become overwhelming and cause layout overflow or scrolling performance issues on lower-end Android devices.

Mitigation & Contingency

Mitigation: Implement chapter filtering as a segmented control above the list so coordinators can scope the list to one chapter at a time. Use ListView.builder (lazy rendering) rather than a Column of all rows. Profile scroll performance on a low-end Android device (Pixel 4a equivalent) with 50 peer mentors in scope during development.

Contingency: If multi-chapter display causes unacceptable performance, ship with single-chapter scope as the default view and a chapter switcher dropdown, deferring the combined cross-chapter list to a follow-up sprint.

low impact low prob technical

Summary cards and the chart widget rebuilding simultaneously on provider state change could cause a visible jank frame on slower devices, degrading perceived quality especially since this screen is intended to feel motivating and polished for gamification purposes.

Mitigation & Contingency

Mitigation: Use AnimatedSwitcher with a short fade transition (150ms) on the stats cards and chart so that data replacement feels intentional rather than jarring. Profile with Flutter DevTools on a mid-range device and ensure no frame exceeds 16ms during a time-window switch.

Contingency: If animation introduces complexity that delays delivery, ship without animation and use a loading skeleton (shimmer effect) during re-fetch instead, which is simpler and equally effective at masking the data swap.

high impact low prob security

If the role-based screen dispatch is misconfigured, a peer mentor could navigate to the coordinator stats screen and see aggregated chapter data for all peer mentors, which is a data privacy violation and a compliance risk for all three organizations.

Mitigation & Contingency

Mitigation: Implement role guard at the router level using an existing role-route-guard component so the coordinator screen route is unreachable for peer mentor roles. Add a widget test that mounts the coordinator screen with a peer mentor session token and asserts that the guard redirects to the no-access screen.

Contingency: If a bypass is found in QA, add a secondary in-screen role assertion in the coordinator screen's initState that throws an AuthorizationException and navigates to the error screen, ensuring defence in depth regardless of router configuration.