Skip to main content

Documentation Index

Fetch the complete documentation index at: https://grantmaster.dev/llms.txt

Use this file to discover all available pages before exploring further.

Engineering reference: For service contracts, EventBus events, and data-layer details see src/features/mission/mission.md.

last_updated: 2026-03-08

Mission & Referral Program

Overview

The Mission & Referral system is a two-part feature: a Mission Impact dashboard for strategic impact alignment, and a Referral Credit program that rewards users for bringing new organizations to GrantMaster.

Architecture

The feature spans frontend components under src/features/mission/, shared services in src/shared/partnerships/ and src/shared/referrals/, and a Firebase Cloud Function trigger in functions/src/referralCreditHandler.ts.

Pages & Tabs

Page ComponentRouteTabs
MissionPage/mission/:tabStrategic Pillars, Targets, Impact Tracking
ReferralDashboard/referral/:tabOverview, Refer Peers, Redeem Credits, Achievements, Activity
Both pages follow the standard UI pattern: PageLayoutPageHeaderPageTabs with external tab content rendering.

Referral Program

How It Works

  1. User shares a referral link (copy, email, QR code, WhatsApp, LinkedIn).
  2. A new organization signs up via the referral link.
  3. If the referred organization subscribes to Growth Tier or higher, the referrer earns €100 Mission Credits.
  4. The referred organization receives a 20% discount for one year.
  5. Credits can be redeemed for organization invoice discounts or gift cards (Visa, Mastercard, Amazon).

Constants

SettingValue
Default reward€100 per Growth Tier referral
Minimum redemption€50
Eligible tiersGrowth, Professional, Ultimate
Referred org discount20% (expires 1 year)

Credit Types

Mission Credits and Agent Credits are separate systems:
AspectMission CreditsAgent Credits
CurrencyEUR (€)Units
ScopePer userPer organization
SourceReferral rewardsSubscription allocation + top-ups
UseInvoice discounts, gift cardsAI agent execution
ServiceReferralCreditServicecreditService

Tab Components

TabComponentPagePurpose
OverviewReferralOverviewTabReferralDashboardCredit balance, stats, impact metrics
Refer PeersReferPeersTabReferralDashboardSharing tools (link, email, QR, social)
Redeem CreditsRedeemCreditsTabReferralDashboardOrg discount or gift card redemption
AchievementsGamificationTabReferralDashboardBadges and milestone tracking
ActivityActivityHistoryTabReferralDashboardTransaction and redemption log

Backend Trigger

onEmployeeCreated (Firestore trigger in functions/src/referralCreditHandler.ts):
  1. Detects new employee with a pending referral-code signup.
  2. Validates the referred organization’s subscription tier.
  3. Awards €100 credit to the referrer via awardCredit().
  4. Creates a referral record with status Converted.
  5. Applies 20% discount to the referred organization.
  6. Sends Postmark emails: “Mission Credit Awarded” to referrer, “Mission Launch Welcome” to referred org admin.
SuperAdmins can also trigger manual awards via manuallyAwardReferralCredit().

Firestore Collections

CollectionPurpose
missionCreditsUser credit wallets (keyed by userId)
creditTransactionsTransaction log (earned / redeemed)
creditRedemptionsRedemption records (org_discount, gift_card)
referralsReferral records (referrer → referred org)
referralConfigProgram configuration (config/referralProgram)
campaignsActive promotional campaigns with multipliers

Key Services

ServiceLocationPurpose
ReferralCreditServicesrc/shared/partnerships/Wallet CRUD, award, redeem, stats
referralDataAccesssrc/shared/referrals/Referral record CRUD
referralCreditHandlerfunctions/src/Cloud Function triggers and email

Phase 2 (Planned)

ReferralCreditService includes stubs for:
  • transferCredits() — user-to-user credit transfer
  • checkTieredBonuses() — escalating rewards for high-volume referrers
  • applyCampaignMultiplier() — promotional credit multipliers
  • getActiveCampaign() — retrieve current campaign configuration