Infrastructure low complexity mobile
0
Dependencies
1
Dependents
1
Entities
0
Integrations

Description

Thin wrapper around Flutter's local storage (SharedPreferences) for persisting the last-used distance per user. Keeps the prefill mechanism functional offline and eliminates a Supabase round-trip on every form load.

Feature: Mileage Reimbursement Entry

local-distance-cache

Summaries

This component meaningfully improves the day-to-day experience for peer mentors by remembering their most recently entered travel distance, so the claim form is pre-filled on subsequent submissions without requiring them to re-enter the same value. For mentors who regularly travel the same route, this reduces friction and speeds up the submission process, directly supporting higher adoption and consistent usage of the reimbursement workflow. It also ensures the prefill feature remains functional when the device is offline, making the app reliable in low-connectivity environments where peer mentors often operate.

A low-complexity, zero-dependency utility component that can be built and tested in isolation early in the project timeline. Its only integration point is the Flutter `SharedPreferences` plugin, which is a stable, well-documented package requiring no backend coordination. Testing should cover the null-return path for first-time users, correct key isolation between multiple user accounts on a shared device, and cache removal on logout. Given its simplicity, this component presents minimal delivery risk and can be assigned to a junior developer or completed alongside other lightweight tasks without impacting the critical path.

A thin wrapper around Flutter's `SharedPreferences` package, storing distance values as `double` keyed by a namespaced `userId` string (e.g., `distance_cache_`) to prevent cross-user data leakage on shared devices. The `read()` method returns `Future`, making the null case explicit for callers to trigger the no-prefill fallback. The `remove()` call should be invoked from the logout handler and any explicit cache invalidation flow. No serialisation complexity exists as `SharedPreferences` natively supports `double`.

This component has no reactive surface — it is read once per form load and written once per successful claim submission.

Responsibilities

  • Write a distance value keyed by user ID to SharedPreferences
  • Read and return the stored distance or null if absent
  • Remove the entry on logout or explicit cache invalidation

Interfaces

write(String userId, double distanceKm) → Future<void>
read(String userId) → Future<double?>
remove(String userId) → Future<void>
clear() → Future<void>

Relationships

Dependents (1)

Components that depend on this component

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/distance-cache 5 endpoints
GET /api/v1/distance-cache
GET /api/v1/distance-cache/:userId
POST /api/v1/distance-cache
PUT /api/v1/distance-cache/:userId
DELETE /api/v1/distance-cache/:userId