Stats Store
Component Detail
Data Layer
medium complexity
mobile
0
Dependencies
2
Dependents
1
Entities
0
Integrations
Description
Local data layer that caches aggregated statistics for offline viewing and manages state via Riverpod. Stores pre-computed summaries fetched from the backend and synchronizes with the server when connectivity is restored via background sync. Ensures the dashboard remains functional and displays the most recent cached data even without network access.
stats-store
Responsibilities
- Cache aggregated statistics locally for offline access
- Manage stats state via Riverpod providers with loading, error, and data states
- Synchronize cached data with backend when connectivity is restored
- Persist last-known stats snapshot to local SQLite for instant dashboard rendering
Interfaces
getCachedStats(userId)
updateCachedStats(userId, statsData)
clearCache(userId)
getLastSyncTimestamp(userId)
markSyncRequired(userId)
isCacheStale(userId, maxAge)
getCachedTrendData(userId, periodType)
persistToLocalDb(userId, statsSnapshot)
loadFromLocalDb(userId)
Relationships
Dependents (2)
Components that depend on this component