Data Layer medium complexity mobile
0
Dependencies
0
Dependents
4
Entities
0
Integrations

Description

Data access layer responsible for querying and caching computed statistics for a peer mentor. Calls the Statistics Calculation Service (edge function or RPC) and caches results with a TTL to avoid redundant computation on repeated dashboard loads. Manages cache invalidation when new activities are recorded.

Feature: Personal Activity Statistics

statistics-repository

Responsibilities

  • Fetch aggregated statistics from Supabase RPC or edge function
  • Cache results with configurable TTL to reduce redundant API calls
  • Invalidate cache entries when new activities or logs are created
  • Expose typed Dart models for all statistics response shapes

Interfaces

getStatsSummary(userId, dateRange)
getChartData(userId, chartType, dateRange)
invalidateCache(userId)
getCachedStats(cacheKey)
setCachedStats(cacheKey, data, ttl)
clearAllCaches()