This project is part of our capstone research at Northeastern University Vancouver, focused on increasing user retention in financial wellness platforms by introducing a gamified task page. Built on the principles of Self-Determination Theory (SDT), ElektraFi uses features like streaks, badges, and progress tracking to enhance user motivation and foster consistent financial habits such as saving, budgeting, and debt reduction.
Note: The code resides in ElekraFi's GitHub repository and is not available for external sharing
Table of Contents:
- Team Members
- Meet the Team & Explore Our Project
- Tech Stack Overview
- Main Features
- Frontend Development
- Backend Development
- Setup Instructions
- Demo Instructions
- Future Improvements
- Sophia Wang
- Haoyi Gao
- Yijia Cao
- Frontend: React (Vite), TypeScript, Tailwind CSS
- Backend: Node.js 22, GraphQL, MongoDB
- Dev Tools: Yarn, Apollo Client, GitHub Actions
- Visual display of weekly task completion
- Progress bar with weekly goals
- Organized task cards with points
- Quick completion buttons and categories
- Real-time points display
- Accumulated history and feedback
- Streaks for consistent logins
- Rewards and indicators
- Bronze/Silver/Gold badge milestones
- Progress and gallery display
- Responsive, intuitive task cards
- Navigation between task, progress, badges
- One-click interaction
- Immediate visual updates
- Friendly error messages
- Retry and fallback mechanisms
- React + TypeScript architecture
- Navigation, task UI components
- GraphQL tasks and mutations
- Progress + error handling UI
- Badge system, streak tracker
- Weekly progress, animation, notifications
- Progressive enhancement
- State management, feedback, responsive UI
- Real-time tracking, error tolerance
- Clean and scalable frontend logic
- User Interaction Layer
- Task completion initiated via UI
- Frontend Processing
- Prepares GraphQL mutation
- API Communication Layer
- Validates + handles request
- Backend Logic
- Verifies completion, updates streaks
- Data Management Layer
- Updates user task and badge data
- State Synchronization
- UI reflects success, shows feedback
- Error Handling
- Recovery strategies, rollback logic
- Persistence
- Saves to MongoDB
- Feedback Loop
- Updates frontend, shows achievements
# Clone the repository
git clone https://github.com/thisissophiawang/Sp25_Elektrafi.git
cd Sp25_Elektrafi
# Install dependencies
yarn install
# Set up environment variables
# For macOS/Linux:
cp ops/dev.env .env
# For Windows (Command Prompt):
copy ops/dev.env .env
# For Windows (PowerShell):
Copy-Item ops/dev.env -Destination .env
# Start the Backend Server
yarn develop
# Start the Frontend (open a second terminal)
yarn dev
# The React app will run at: http://localhost:3000
# Log in with the test account and explore the gamified features
The Task Streak System is a gamification feature that encourages users to maintain consistent financial habits through task completion and streak tracking. The system tracks user progress, awards points, and provides rewards for maintaining streaks.
Note: The code resides in ElekraFi's GitHub repository and is not available for external sharing
feat/sdt-gamification/
βββ frontend/ # React + Vite frontend
β βββ src/components/ # UI components mapped to SDT needs
β β βββ autonomy/ # User-directed components (TaskSelection, ChallengeCustomizer)
β β βββ competence/ # Feedback components (ProgressBar, StreakCounter, BadgeDisplay)
β β βββ relatedness/ # Social components (LeaderboardCard, AchievementSharing)
β βββ src/contexts/ # SDT-driven state management
β β βββ TaskStreakContext.tsx # Manages streak state and psychological feedback
β β βββ PsychologicalNeedsContext.tsx # Global SDT state provider
β βββ src/pages/ # User-facing views
β β βββ Tasks/ # TasksPage with SDT-aligned gamification
β βββ src/graphql/ # API communication
β βββ src/assets/ # Visual reward elements
β
βββ nest-backend/ # Node.js backend with GraphQL
β βββ src/ # Source directory
β β βββ task-streak/ # Core streak functionality
β β β βββ task-streak.service.ts # Streak calculation and points logic
β β β βββ config/ # Task configuration
β β β βββ available-tasks.config.ts # SDT-mapped task definitions
β β βββ motivation/ # SDT engine for aligning features with needs
β β βββ verification/ # Data validation services
β β βββ rewards/ # Points allocation and badge achievement
β βββ schema.gql # GraphQL schema definition
β βββ migrations/ # Database migration scripts
β
βββ docs/ # Documentation
β βββ architecture.md # SDT-based architecture overview
βββ README.md # Project documentation
-
TaskStreakContext (
frontend/src/contexts/taskStreakContext.tsx
)- Manages streak state and task completion logic
- Handles automatic login task completion
- Provides streak information to components
-
TasksPage (
frontend/src/pages/Tasks/TasksPage.tsx
)- Displays available tasks and their status
- Shows streak information and rewards
- Handles task completion UI
-
TaskStreakService (
nest-backend/src/task-streak/task-streak.service.ts
)- Core business logic for streak management
- Handles task completion and streak calculations
- Manages points and level progression
-
Database Schema
task_streaks
table: Stores user streaks and progresstask_completions
table: Records individual task completionsuser_badges
table: Tracks earned rewards
The system supports several task types:
LOGIN
: Weekly login task (50 points)BUDGET_CHECKIN
: Weekly budget review (300 points)EXPENSE_TRACKING
: Weekly expense tracking (500 points)- Additional financial tasks (SAVINGS_TRANSFER, EMERGENCY_FUND, etc.)
DAILY
: Tasks reset at midnightWEEKLY
: Tasks reset at midnight on MondayMONTHLY
: Tasks reset at midnight on the first of the month
Each task has three reward levels:
- Bronze: Complete 1 week
- Silver: Complete 8 weeks consecutively
- Gold: Complete 12 weeks consecutively
Points are awarded based on task completion and streak length:
- Base points per task completion
- Streak multiplier increases points earned
- Level progression based on total points
- Level 1: 0-999 points
- Level 2: 1000-2499 points
- Level 3: 2500-4999 points
- Level 4: 5000-9999 points
- Level 5: 10000-19999 points
- Level 6: 20000+ points
query GetUserStreaks($userId: String!) {
getUserStreaks(userId: $userId) {
id
userId
taskType
currentStreak
longestStreak
lastCompletionDate
frequency
updatedAt
totalPoints
currentPointThreshold
nextPointThreshold
level
}
}
query GetUserPointsInfo($userId: String!) {
getUserPointsInfo(userId: $userId) {
totalPoints
currentPointThreshold
nextPointThreshold
level
}
}
mutation CompleteTask($userId: String!, $taskType: TaskType!) {
completeTask(userId: $userId, taskType: $taskType) {
id
userId
taskType
currentStreak
longestStreak
lastCompletionDate
frequency
updatedAt
totalPoints
currentPointThreshold
nextPointThreshold
level
}
}
Run task streak context tests:
cd frontend
vitest taskStreakContext.spec.tsx
Run task streak service tests:
cd backend
npm run test:unit task-streak.service.spec.ts
frontend/src/contexts/taskStreakContext.tsx
: Frontend streak managementfrontend/src/pages/Tasks/TasksPage.tsx
: Task display and interactionnest-backend/src/task-streak/task-streak.service.ts
: Backend streak logicnest-backend/src/task-streak/config/available-tasks.config.ts
: Task configuration
- Task availability is checked based on:
- Last completion date
- Task frequency
- Reset period and time
- Points are calculated as:
basePoints * currentStreak
- Level progression is based on total points reaching thresholds
- Streak rewards are awarded automatically when conditions are met
1733500000000-CreateTaskStreakTables.ts
: Initial table creation1733500000001-add-points-to-task-streak.ts
: Added points and level tracking
Task settings can be modified in available-tasks.config.ts
:
- Points per task
- Required streak lengths for rewards
- Task frequency and reset times
- Task categories and descriptions
Each task has two types of levels:
-
Required Level (
requiredLevel
in TaskConfig)- This is the minimum user level needed to access the task
- Currently, all tasks have
requiredLevel: 1
, meaning they're available from the start - This is separate from the streak reward levels
-
Streak Reward Levels (
streakRewards
in TaskConfig)- These are achievement levels based on consecutive completions
- Each task has three reward levels:
- Level 1 (Bronze): 1 week of consecutive completion
- Level 2 (Silver): 8 weeks of consecutive completion
- Level 3 (Gold): 12 weeks of consecutive completion
- The level number in
streakRewards
corresponds to the achievement tier, not the required weeks
Example from the Login task:
streakRewards: [
{ level: 1, medal: 'π₯', name: 'Bronze', description: 'Complete 1 week of login' },
{ level: 2, medal: 'π₯', name: 'Silver', description: 'Complete 8 weeks of login consecutively' },
{ level: 3, medal: 'π₯', name: 'Gold', description: 'Complete 12 weeks of login consecutively' }
]
Note: The level
in streakRewards
is just an identifier for the achievement tier (1=Bronze, 2=Silver, 3=Gold) and doesn't need to match the number of weeks required. The actual streak requirements are defined in the descriptions.
- Start both servers using
yarn develop
andyarn dev
- Open http://localhost:3000
- Log in using the demo test account
- Explore:
- Weekly progress tracker
- Task card system with real-time feedback
- Badge collections and points dashboard