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

Description

Riverpod AsyncNotifier that fetches activity types on login and holds them in memory for the session. Serves cached data to UI and service layers, reducing redundant network calls during registration wizard flows. Exposes an invalidation method called after admin mutations.

Feature: Activity Type Configuration

activity-type-cache-provider

Summaries

The Activity Type Cache Provider directly improves the user experience during onboarding by eliminating repeated loading delays when users navigate through the registration wizard. By fetching activity type data once at login and reusing it throughout the session, the app feels faster and more responsive — reducing drop-off risk during critical first-time flows. For the business, this means higher registration completion rates and a smoother introduction to the platform. It also reduces infrastructure costs by cutting redundant API calls per session, which matters at scale across a large mobile user base.

Administrators benefit too: any changes they make to activity types are reflected immediately after cache invalidation, ensuring data consistency without requiring users to restart the app. This component underpins a seamless experience that builds user trust from the very first interaction.

This component has medium complexity and sits on the critical path for both the registration wizard and any admin-facing activity type mutation flows. It depends on the Activity Type Repository, so that repository must be stable and tested before this provider can be fully validated. The Riverpod state management pattern requires developers familiar with Flutter's reactive paradigm — factor this into team assignment. Testing must cover cache warm-up on login, correct serving of cached data to consumers, invalidation logic triggered by admin mutations, and refresh behavior after network failures.

Since this is a shared component consumed by multiple features, any regressions will have broad impact; allocate time for integration testing across all dependent screens. Deployment risk is low once stable, but initial implementation should include monitoring for stale data edge cases to avoid user-facing inconsistencies.

Implemented as a Riverpod `AsyncNotifier`, this provider manages the full lifecycle of activity type data for the authenticated session. On `build()`, it delegates to `activity-type-repository` to fetch the organisation's activity types and holds them in memory. `getActivityTypes()` and `watchActivityTypes()` expose the cached state reactively to widgets and services without triggering additional network requests. `invalidateCache()` is called by the service layer after any admin mutation, which internally triggers `refresh()` to re-fetch from the repository.

The reactive model ensures all watchers automatically receive updated data post-invalidation. Because this is a shared provider consumed across the registration wizard and other flows, care must be taken to avoid over-invalidation. Error states from the repository (network failures, auth errors) propagate through Riverpod's `AsyncValue` error channel and must be handled at each consumer site.

Responsibilities

  • Fetch and cache activity types for the authenticated organisation on app startup or login
  • Serve cached ActivityType list to widgets and services without triggering network calls
  • Invalidate and refetch when notified of mutations by the service layer

Interfaces

build()
getActivityTypes()
invalidateCache()
refresh()
watchActivityTypes()

Relationships

Dependencies (1)

Components this component depends on

Dependents (2)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/activity-types 4 endpoints
GET /api/v1/activity-types/cache
POST /api/v1/activity-types/cache/build
DELETE /api/v1/activity-types/cache
POST /api/v1/activity-types/cache/refresh