Statistics Service
Component Detail
Service Layer
medium complexity
Shared Component
mobile
1
Dependencies
1
Dependents
2
Entities
0
Integrations
Description
Riverpod provider that calls the dedicated aggregation REST API endpoint and exposes a typed StatisticsSummary to the UI. Manages cache invalidation, optimistic loading from Drift, and error state. Designed for reuse by the Annual Summary (Wrapped) feature in the Achievements area.
statistics-service
Sources & reasoning
Riverpod service layer required to decouple UI from API and Drift. Marked shared because the implementation notes explicitly state the aggregation layer must be reusable by Annual Summary (Wrapped) in the Achievements area.
No source references — this artifact was included based on reasoning alone (see above).
Responsibilities
- Fetch per-user activity aggregates from the REST API aggregation endpoint
- Serve cached Drift aggregates when the network is unavailable
- Expose reactive StatisticsSummary state via Riverpod StateNotifier
- Provide a reusable aggregation interface consumable by the Annual Summary feature
Interfaces
fetchSummary(userId: String) → Future<StatisticsSummary>
getCachedSummary(userId: String) → StatisticsSummary?
invalidateCache(userId: String) → void
watchSummary(userId: String) → Stream<StatisticsSummary>
Relationships
Related Data Entities (2)
Data entities managed by this component