Skip to main content

SPEC 015 — Referrals


1. Feature Purpose

The referral system incentivizes user growth through a multi-layered reward mechanism. Users generate unique referral links, invite friends via email, and earn EquaCash (platform virtual currency) through scratch card rewards. The system supports both personal and organization-level referrals, invitation tracking, EquaCash transfers between users/organizations, and transaction history. Google Contacts integration for bulk invites was previously supported but has been deprecated.

2. Current State (Verified)

2.2 Reward Generation

2.3 Referral Registration Flow

2.4 Scratch Card Reveal

2.5 EquaCash Transfer

2.6 Transaction History

2.7 Invitation System

2.8 Google Contacts (Deprecated)

2.9 Company Info Collection


3. Data Model

Referrals

Rewards

Invitations

CompaniesInfo

UserCoupons

Transactions (EquaCash transfers)


4. API Endpoints


5. Frontend Components

Module: equa-web/src/modules/referrals/

Pages: Components: Modals: Google Sign-In:

6. Business Rules

  1. Referral link is a 6-character hex string, cryptographically random, guaranteed unique via recursive retry.
  2. Reward distribution uses weighted random: $10 (50%), $25 (25%), $50 (20%), $100 (5%).
  3. Signup reward: Every new user gets one scratch card at registration.
  4. Referral reward: The referrer gets one scratch card when their invitee registers.
  5. Organization info reward: User gets one scratch card for submitting company information.
  6. Scratch cards are one-time reveal — once scratched, the EquaCash is added to the user’s or org’s balance.
  7. IP rate limiting: Max REGISTRATION_IP_LIMIT (default 20) referral registrations per IP address.
  8. Email and domain blacklists prevent abusive registrations.
  9. EquaCash transfers require the sender to have a balance >= the transfer amount. Transfer is atomic: deduct, credit, record.
  10. Transaction history shows a running balance computed in reverse chronological order.
  11. Invitation upsert: Re-inviting the same email updates the existing record rather than creating a duplicate.
  12. Invitation statuses progress: invitedregistered or joined; bounced emails are tracked separately.
  13. Google Contacts import is deprecated — backend throws BadRequest if called.
  14. Dual referral paths: Personal referral link (?user={link}) and organization referral link (?organization={orgLink}&user={userLink}).

7. Acceptance Criteria

  • New user receives a unique 6-character referral link at registration
  • User can share referral link and track how many people registered through it
  • Signup generates one scratch card for the new user
  • Successful referral generates one scratch card for the referrer
  • Scratch card reveal animation works and adds correct EquaCash to balance
  • Reward amounts follow the weighted distribution (10/10/25/50/50/100)
  • User can send email invitations to multiple addresses
  • Invitation table shows status (invited, registered, joined, bounced) with daily/monthly stats
  • EquaCash transfers work between users and between user/org
  • Transfer fails gracefully when balance is insufficient
  • Transaction history shows all transfers, earned rewards, and subscription spends with running balance
  • IP rate limiting blocks excessive registrations from a single IP
  • Email and domain blacklists prevent blocked addresses from registering
  • Organization-level referral page shows org-specific rewards and invite tracking

8. Risks