Service Layer high complexity mobile
1
Dependencies
4
Dependents
2
Entities
0
Integrations

Description

Orchestrates all read and write operations for user profile data between the remote REST API and the local Drift cache. Applies optimistic mutations immediately and queues PATCH /api/v1/users/{id} in the mutation outbox when offline, with automatic rollback if the remote call fails. Exposes reactive Riverpod providers consumed by both profile screens.

Feature: Profile Data & Settings

profile-service

Responsibilities

  • Fetch profile from GET /api/v1/users/{id} and populate local Drift users table on success
  • Apply optimistic PATCH to local cache and enqueue mutation in offline outbox if device is offline
  • Rollback local optimistic update and surface error state when remote PATCH fails
  • Upload profile photo to backend object storage and persist returned URL to profile patch
  • Expose watchProfile stream via Riverpod so UI reactively reflects local and remote state changes

Interfaces

getProfile(userId: String): Future<UserProfile>
updateProfile(userId: String, patch: ProfilePatch): Future<UserProfile>
uploadProfilePhoto(userId: String, file: File): Future<String>
watchProfile(userId: String): Stream<UserProfile>
clearLocalProfile(userId: String): Future<void>

Relationships

Dependencies (1)

Components this component depends on

Dependents (4)

Components that depend on this component

Related Data Entities (2)

Data entities managed by this component