Data Layer medium complexity mobile
0
Dependencies
1
Dependents
2
Entities
0
Integrations

Description

Data access layer that abstracts the source of statistics data, routing reads to the REST API when online and to the local Drift/SQLite cache when offline. Persists fetched snapshots for offline access and exposes typed query methods consumed by the Statistics Service.

Feature: Personal Activity Statistics

statistics-repository

Responsibilities

  • Query the REST API /api/v1/statistics/personal endpoint with filter params
  • Persist API responses into the local statistics_cache table via Drift
  • Serve cached data for offline reads
  • Expire and evict stale cache entries

Interfaces

fetchFromApi({required String userId, required DateRange range, String? activityTypeId}): Future<StatsSnapshot>
fetchFromCache({required String userId, required DateRange range}): Future<StatsSnapshot?>
saveToCache(StatsSnapshot snapshot): Future<void>
clearCache(String userId): Future<void>
fetchActivityBreakdown({required String userId, required DateRange range}): Future<List<ActivityTypeStat>>
fetchTrendSeries({required String userId, required DateRange range, required StatsPeriod period}): Future<List<DataPoint>>

Relationships

Dependents (1)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component