Referral Engine v2: Design & Implementation Blueprint
This is a complete blueprint for Referral Engine v2, optimized for viral growth in a subscription-based SaaS product (e.g., 10−50/motiers).Itbuildsonv1assumptions(basicinvitelinks+flat10 credit reward) by introducing sustainable incentives math (ROI-positive), multi-layer fraud defenses, PMF validation loops, and real-time reporting.
Key goals:
- Achieve viral coefficient (K) > 1.2 for 3x faster CAC payback.
- Fraud rate < 0.5%.
- 20%+ PMF lift via referred user retention.
- Plug-and-play with Stripe, Auth0, Postgres, and Mixpanel.
1. Incentives Math
Rewards are tiered, time-bound, and LTV-aligned. Assumes avg LTV = 300(24mo@12.5 ARPU), CAC target = $50.
Core Formulas
-
Viral Coefficient (K): K = i * c * p * f
| Factor | Definition | Target | Calc Example |
|---|
i (Invites/user/mo) | Avg invites sent | 1.5 | A/B test CTAs |
c (Conversion) | % invited who sign up | 25% | Landing page opt. |
p (Payout) | Fraction of LTV paid out | 10% ($30) | Reward cap |
f (fv) | Referred user retention factor | 1.1x | 90-day retention bonus |
Target K = 1.5 → 50% MoM growth.
-
Reward Value: Dynamic based on referee LTV projection.
referrer_reward = min(0.1 * projected_ltv(referee), $50)
referee_reward = min(0.05 * projected_ltv(referee), $20) // Double-sided for PMF
projected_ltv = arpu * (1 - churn_rate) * avg_lifetime_mo
- ARPU = 12.5,churn=5250 base.
- Tiered: +20% bonus if referee hits 3mo retention.
-
ROI Check: roi = (referred_ltv - total_rewards) / total_rewards
- Gate rewards: Only pay if ROI > 2x after 90 days.
- Caps: Max $200/user lifetime; 10 referrals/mo.
Reward Tiers (v2 Upgrade)
| Tier | Referee Action | Referrer Gets | Referee Gets | Unlock Cond. |
|---|
| Basic | Signup | $10 credit | $10 off first mo | Instant |
| Activate | 7-day login streak | $20 credit | $5/mo x3 | Behavioral |
| Retain | 90-day retention | $30 bonus | Free mo | Cohort-tracked |
| Power | 5+ successful refers | 20% rev share (1yr) | Tier upgrade | Viral leader |
Implementation:
# Pseudocode (FastAPI + SQLAlchemy)
def calculate_reward(referee_id: int, milestone: str) -> float:
ltv = get_projected_ltv(referee_id) # ML model or avg cohort
if milestone == "signup": return min(0.1 * ltv, 50)
# ... tier logic
if get_roi(referee_id) < 2: return 0 # Holdback
return reward_amount
2. Fraud Defenses
Multi-layer: Prevention (90%), Detection (9%), Manual (1%). Target fraud <0.5% of rewards.
Layers
-
Entry Gates (Block 80% fraud):
- Unique referral codes: UUID + user_id hash (no self-ref via email/IP match).
- Device Fingerprint:
fp = hash(user_agent + ip + screen_res + timezone).
- OTP via Twilio SMS on signup (Sybil block).
-
Behavioral Heuristics (Real-time):
- Rate limits: 20 invites/day/user; 5 signups/IP/hr.
- Graph Analysis: Flag if >30% refers within same IP/network (K-core algo).
- Anomaly Scores:
score = w1*invite_rate + w2*self_loop + w3*ltv_drop
- Threshold >0.8 → Hold reward 30 days.
-
ML Detection (Daily batch):
- Model: XGBoost on features (signup velocity, geo mismatch, retention drop).
- Train on labeled v1 fraud (e.g., VPN farms).
- Auto-ban: Score >0.95.
-
Post-Payout Audit:
- Clawback: Refund if fraud detected <90 days.
- Human queue: Top 1% anomalies → Ops Slack.
Implementation:
# Fraud check middleware
async def fraud_check(referral: Referral):
fp = generate_fingerprint(request)
if Referral.query.filter(ip=fp.ip, created_at__gt=now-1hr).count() > 5:
raise FraudError("Rate limit")
anomaly_score = fraud_model.predict([features(referral)])
if anomaly_score > 0.8:
queue_for_review(referral.id)
return True
Metrics: Fraud attempts tracked; auto-alert if >1%.
3. PMF Fit
Ensure referrals amplify core value prop (e.g., "collaborative tool" → team invites).
Validation Framework
-
Cohort Testing:
| Cohort | Test | Success Metric |
|---|
| Organic | Baseline | 30-day ret=40%, ARPU=$12 |
| Referred | A/B rewards | Ret>45%, ARPU>=$12 (lift) |
| Viral | Unlimited invites | K>1.2, NPS>50 |
-
Fit Signals:
- Referee Activation: Must complete onboarding → unlock reward.
- Retention Multiplier: Referred users 1.2x stickier (social proof).
- Product Hooks: "Share project" CTAs in high-engagement flows.
-
Iteration Loop:
- Launch MVP to 10% users.
- If referee churn > organic +10% → Pause & tweak incentives.
- A/B: Single vs double-sided rewards.
PMF Guardrails:
- Only active users (7-day streak) can refer.
- Kill-switch if K<0.8 after 2wks.
4. Reporting
Real-time dashboards (Metabase + Amplitude) + API exports.
User Dashboard (Self-serve)
/referrals: Table of invites (status, rewards earned).
- Leaderboard: Top referrers (anonymized).
- Payout history: CSV export.
Admin Dashboards
| Report | Metrics | Cadence | Alerts |
|---|
| Viral | K-factor, i/c/p/f breakdown, growth attribution | Real-time | K<1 |
| Fraud | Attempts blocked, anomaly scores, clawbacks | Hourly | >0.5% |
| Incentives | Total rewards paid, ROI/cohort, LTV lift | Daily | ROI<2x |
| PMF | Referee retention curve, ARPU delta | Weekly | Churn lift>10% |
Key Queries (SQL):
-- Viral K
SELECT
AVG(invites_sent) as i,
COUNT(completed_signups)/SUM(invites_sent) as c,
SUM(rewards_paid)/SUM(projected_ltv) as p,
AVG(referee_retention) as f
FROM referrals WHERE created_at > NOW() - INTERVAL '30 days';
API Endpoints:
GET /api/referrals/dashboard → JSON metrics.
- Webhooks: Stripe payout + Mixpanel events.
Rollout Plan
- Week 1: DB schema + backend (FastAPI/Postgres).
- Week 2: Fraud/ML + frontend (React).
- Week 3: Beta to 1k users; monitor K/ROI.
- Week 4: Full launch; A/B tiers.
Tech Stack: FastAPI, Postgres (referrals table: id, referrer_id, referee_id, status, reward_amt, fraud_score), Celery (async payouts), Sentry (errors).
Cost Est: $500/mo (Twilio + ML inference). ROI: Breakeven at 1k new users/mo.
This v2 turns referrals into a growth flywheel. Ping for code repo, wireframes, or customizations! 🕵️♂️