Page cover image

For developers

Architecture for UNIAPT Referral System

1. System Components:

  • User Management Service: Handles user registration, authentication, and profile management.

  • Referral Tracking Service: Generates unique referral codes/links, tracks referral actions, and manages the attribution of rewards.

  • Rewards Management Service: Calculates and distributes rewards based on predefined milestones and user actions.

  • Analytics and Reporting Service: Provides insights into the referral program's performance, user engagement metrics, and predictive analytics for optimizing referral strategies.

  • Feedback Loop Mechanism: Collects and processes user feedback to continually refine and improve the referral program.

2. Data Model Example:

  • Users Table: Stores user details including a unique userID, email, and referralCode.

  • Referrals Table: Tracks referral links, the referring user, the referred user, timestamps, and status of referral actions.

  • Rewards Table: Records the rewards earned by each user, including type, amount, and redemption status.

3. Referral Reward Calculation:c

def calculate_rewards(referral_count):
    # Define reward milestones
    milestones = {5: 10%, 10: 15%, 20: 20%, 21: 25%}
    reward_percentage = 0
    
    # Determine the applicable reward percentage
    for milestone, percentage in milestones.items():
        if referral_count >= milestone:
            reward_percentage = percentage
        else:
            break
    
    # Calculate the reward based on the referral count and percentage
    reward = calculate_reward_amount(referral_count, reward_percentage)
    return reward

def calculate_reward_amount(referral_count, reward_percentage):
    # Assuming a fixed value per referral for demonstration
    base_value_per_referral = 10
    reward = referral_count * base_value_per_referral * reward_percentage
    return reward

4. How Developers Interact with the System:

  • API Integration: Developers can interact with the referral system through a set of APIs provided by the UNIAPT platform, allowing for the integration of referral functionalities directly into their applications.

  • SDKs and Libraries: UNIAPT provides SDKs for major programming languages, making it easier for developers to implement and customize the referral system within their projects.

  • Documentation and Guides: Comprehensive guides and documentation are available to help developers understand how to use the system, implement best practices, and optimize referral strategies.

5. Contribution to the Community: The referral system not only incentivizes users to promote UNIAPT's tools but also fosters a sense of community by rewarding contributions and engagement. Through gamification and milestones, it encourages users to actively participate in the growth of UNIAPT, leading to a more vibrant and collaborative ecosystem.

def calculate_cumulative_reward(referral_count):
    initial_reward = 5  # Initial reward for the first referral
    additional_reward_percentage = 0.1  # 10% increase for each additional referral
    total_reward = 0
    
    for i in range(1, referral_count + 1):
        if i == 1:
            total_reward += initial_reward
        else:
            # Each subsequent referral increases the reward by an additional 10%
            total_reward += initial_reward * additional_reward_percentage * (i - 1)
    
    return round(total_reward, 2)

Integration with User Accounts:

When a user makes a referral, the system needs to:

  • Generate a unique referral link.

  • Track link usage to count successful referrals.

  • Calculate rewards based on successful referrals.

Simplified Database Schema:

  • Users Table: UserID, Email, ReferralCode

  • Referrals Table: ReferralID, ReferrerUserID, ReferredUserID, Timestamp, Status

Reward Distribution Mechanism:

After calculating the rewards as per the pseudo-code, the system updates the user's rewards balance. This involves a simple database operation to increment the user's reward balance based on the calculation.

Community Impact Through Gamification:

The referral system can introduce gamification elements like leaderboards, badges, or additional non-monetary rewards for top referrers. These features encourage healthy competition and increase system engagement.

Last updated