Badge & Achievement Tracker

Core → Gold
💰 $2000

Gamified milestone system.

Technology iconTechnology iconTechnology icon

Badge & Achievement Tracker Overview

Purpose

The Badge & Achievement Tracker module is designed to enhance user engagement by implementing a gamified system that rewards users with badges for reaching specific milestones. This system fosters a sense of progression and accomplishment, encouraging continued interaction within the application.

By leveraging gamification principles, this module aims to increase user retention and satisfaction. It allows developers to create customizable achievements that align with their app’s goals, providing immediate feedback to users on their progress.

Key Features

Benefits

  1. Enhanced Engagement: Badges and achievements motivate users to return frequently, fostering loyalty.
  2. Personalized Experience: Tailored achievements cater to individual user behaviors and preferences, making the experience unique.
  3. Increased Retention: By rewarding milestones, users are encouraged to continue using the app to unlock more rewards.
  4. Improved User Experience: Visual feedback on progress adds a layer of satisfaction, enhancing overall UX.

Usage Scenarios

Integrations

The Badge & Achievement Tracker seamlessly integrates with various technologies and frameworks:

By incorporating the Badge & Achievement Tracker, developers can elevate their app’s engagement and satisfaction levels, ensuring a more dynamic and rewarding user experience.

Feature Name: Achievement Definitions

The module allows administrators or developers to define custom achievements and badges with specific criteria for earning them. Achievements can be created programmatically or via an admin interface.

Feature Name: Badge Earning Mechanisms

Users automatically earn badges based on predefined rules (e.g., completing tasks, reaching milestones) or manually by admins after reviewing user activity.

Feature Name: Visual Display of Badges

Earned badges are displayed in a visually appealing format on user profiles, dashboards, or public pages to encourage engagement and recognition.

Feature Name: Progress Tracking

Users can track their progress toward unlocking new achievements, with real-time updates and visual indicators showing how close they are to the next milestone.

Feature Name: Notifications & Alerts

Automated notifications inform users when they earn a badge or unlock an achievement. Admins can also be alerted for manual badge assignments.

Feature Name: System Integration

The module integrates with other core systems like user profiles, activity tracking, and leaderboards to provide a seamless gamified experience.

Module Name: Badge & Achievement Tracker

Category: Core

Summary: Gamified milestone system to track achievements and badges for users.

This module provides a gamified system to track user achievements, milestones, and badges. It includes endpoints to create, read, update, and delete achievements, as well as calculate progress towards earning badges.

Code Samples

1. FastAPI Endpoint (Create Achievement)

from fastapi import APIRouter, Depends, HTTPException
from typing import Optional
from pydantic import BaseModel
import schemas
import models

router = APIRouter()

@router.post("/achievements/", response_model=schemas.AchievementResponse)
async def create_achievement(
    achievement: schemas.AchievementCreate,
    db: Session = Depends(get_db),
):
    """
    Create a new achievement.
    
    Args:
        achievement (AchievementCreate): Achievement data to create.
        
    Returns:
        AchievementResponse: Created achievement with all fields.
        
    Raises:
        HTTPException(422): If validation fails.
    """
    try:
        db_achievement = models.Achievement(**achievement.dict())
        db.add(db_achievement)
        db.commit()
        db.refresh(db_achievement)
        return db_achievement
    except Exception as e:
        raise HTTPException(status_code=500, detail=str(e))

2. React UI Snippet (Achievement List)

import React, { useState } from 'react';
import { Badge } from 'components/ui/Badge';

interface Achievement {
  id: number;
  title: string;
  description: string;
  points: number;
  criteria: string[];
  status: 'unlocked' | 'locked' | 'in-progress';
}

export function AchievementList() {
  const [achievements, setAchievements] = useState<Achievement[]>([]);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);

  React.useEffect(() => {
    fetch('/api/achievements/')
      .then(res => res.json())
      .then(data => setAchievements(data))
      .catch(err => setError(err))
      .finally(() => setLoading(false));
  }, []);

  if (loading) return <div>Loading achievements...</div>;
  if (error) return <div>Error loading achievements: {error}</div>;

  return (
    <div className="space-y-4">
      {achievements.map((achievement) => (
        <div key={achievement.id} className="bg-white p-4 rounded-lg shadow-sm">
          <div className="flex items-center justify-between mb-2">
            <h3 className="text-lg font-semibold">{achievement.title}</h3>
            <Badge status={achievement.status}>
              {achievement.status === 'unlocked' ? (
                'Unlocked'
              ) : achievement.status === 'locked' ? (
                'Locked'
              ) : (
                'In Progress'
              )}
            </Badge>
          </div>
          <p className="text-sm text-gray-600 mb-2">{achievement.description}</p>
          <ul className="list-disc pl-5 space-y-1">
            {achievement.criteria.map((criteria, index) => (
              <li key={index} className="text-sm">
                {criteria}
              </li>
            ))}
          </ul>
        </div>
      ))}
    </div>
  );
}

3. Pydantic Data Schema (Achievement)

from pydantic import BaseModel, Field, validator
from typing import Optional, List
from enum import Enum

class AchievementStatus(Enum):
    UNLOCKED = "unlocked"
    LOCKED = "locked"
    IN_PROGRESS = "in-progress"

class AchievementBase(BaseModel):
    title: str
    description: str
    points: int
    criteria: List[str]
    status: AchievementStatus
    
class AchievementCreate(AchievementBase):
    id: Optional[int] = None

class AchievementResponse(AchievementBase):
    id: int
    created_at: datetime
    updated_at: datetime

Description

Usage

  1. Use the FastAPI endpoint to create new achievements.
  2. Display achievements in your React application using the AchievementList component.
  3. Track progress and update achievement statuses as users complete milestones.

Badge & Achievement Tracker Module Documentation

Summary

The Badge & Achievement Tracker module is a gamified milestone system designed to track user achievements and award badges based on predefined criteria. This module is ideal for adding engagement and motivation to user interactions by recognizing milestones and accomplishments.

Target User


  1. User Profiles Module

    • Manages user data and preferences, essential for tracking achievement progress per user.
  2. Activity Tracking Module

    • Logs user actions and events, providing the foundation for triggering achievements and badges.
  3. Notifications Module

    • Sends alerts or rewards when users earn badges or achieve milestones.
  4. Analytics Module

    • Provides insights into achievement completion rates and badge redemption trends.
  5. Rewards System Module

    • Integrates with external reward systems, such as points, discounts, or virtual currency.

Use Cases

1. Track User Progress in Learning Platforms

2. Reward First-Time Purchasers

3. Recognize Fitness Milestones


Integration Tips

  1. Event Listeners for Achievement Tracking

    • Use the trackEvent function to log user actions (e.g., completing a task, reaching a milestone).
    // Example: Track purchase completion
    BadgeTracker.trackEvent('purchase_completed', { userId: 'user_123' });
    
  2. Automated Badges

    • Configure rules for automatic badge issuance based on user activity or predefined criteria.
    achievement_rules:
      - rule_name: "FirstPurchase"
        condition: event == "purchase_completed"
        award_badge: true
        badge_id: "welcome-badge"
    
  3. UI Integration

    • Display badges and achievements in user profiles or leaderboards using the provided API endpoints.
    <!-- Example: Show achievement progress -->
    <div class="achievement-container">
      <span class="achievement-name">Welcome Badge</span>
      <span class="progress-bar" style="width: 75%"></span>
    </div>
    
  4. API Integration for Custom Use Cases

    • Use the REST or GraphQL API to fetch achievement data and update user progress programmatically.

Configuration Options

Option NameDescriptionDefault ValueExample Usage
enable_achievementsEnable or disable the achievement tracking feature.trueSet to false to disable achievements.
badge_level_thresholdDefine thresholds for badge levels (e.g., bronze, silver, gold).[100, 250, 500]Custom thresholds: [50, 100, 200].
track_event_typesList of events to track for achievements.["login", "purchase"]Add custom events like "task_completed".
notification_typeType of notification for achievement alerts (e.g., email, in-app, push)."in-app"Set to "email" for email notifications.
points_per_badgePoints awarded per badge (optional if using a rewards system).0Set to 100 for premium badges.
api_accessEnable or disable API access for third-party integrations."disabled"Set to "enabled" for custom integrations.

Conclusion

The Badge & Achievement Tracker module is a powerful tool for enhancing user engagement and motivation by recognizing milestones and accomplishments. By leveraging its integration tips, configuration options, and related modules, developers can seamlessly incorporate gamification into their applications.