Referral Link Service
Component Detail
Service Layer
medium complexity
mobile
1
Dependencies
1
Dependents
1
Entities
0
Integrations
Description
Manages generation, retrieval, and lifecycle of personalized referral invite tokens and short URLs. Communicates with the backend REST API to create unique tokens scoped to the referring user and organization. Handles token expiry, refresh, and deep link construction.
referral-link-service
Responsibilities
- Request token generation from backend API (POST /api/v1/referrals/generate)
- Cache active invite token locally to avoid redundant API calls
- Construct full deep link URL from token (Firebase Dynamic Links or Universal Links)
- Detect and signal token expiry, triggering refresh
- Scope tokens to organization for multi-tenancy correctness
Interfaces
generateInviteLink(userId, organizationId): Future<ReferralLink>
getActiveInviteLink(userId): Future<ReferralLink?>
refreshInviteLink(userId, organizationId): Future<ReferralLink>
isTokenExpired(token): bool