Service Layer medium complexity backend
0
Dependencies
0
Dependents
1
Entities
0
Integrations

Description

Backend service responsible for generating unique referral tokens, resolving incoming referral links during sign-up, and recording attribution events. It enforces token validity, ties each token to the originating peer mentor, and exposes statistics used by the share screen.

Feature: Invite Link & QR Sharing

referral-service

Sources & reasoning

HLF named referral / member recruitment as a SHOULD HAVE requirement and the priority matrix assigns it Phase 3 (Fase 3), which maps to v1.1. The invite-link and QR sharing mechanism is the entry point of the referral flow - without it, recruitment tracking has nothing to count. Blueprint ID invite-link-qr-sharing is preserved exactly as specified.

Responsibilities

  • Generate a cryptographically unique referral token bound to a user ID
  • Validate and resolve a referral token presented during new-user registration
  • Record an attribution event linking the new account to the referring mentor
  • Return aggregated referral stats (total clicks, successful sign-ups) per mentor
  • Expire or invalidate tokens when the associated mentor account is deactivated

Interfaces

generateReferralToken(userId: string): ReferralToken
resolveToken(token: string): ReferralTokenRecord
recordSignUpAttribution(token: string, newUserId: string): void
getReferralStats(userId: string): ReferralStats
invalidateToken(token: string): void

Related Data Entities (1)

Data entities managed by this component