Skip to content

GoodCommit Feature Request: Implement a Complete Habit Streak System #1

@CollinsC1O

Description

@CollinsC1O

Project Context

I am building GoodCommit, a Web3 habit accountability platform deployed on Celo Mainnet.

Users stake GoodDollar (G$) tokens on commitments and complete verified activities to earn points and grow a virtual plant.

Current features include:

  • Wallet connection
  • G$ staking
  • Workout verification
  • Quiz verification
  • Point rewards
  • Plant growth stages
  • Point decay system
  • Harvesting rewards
  • Backend verifier system
  • Smart contract integration

The application currently does NOT have a streak system.

The goal is to implement a robust streak tracking system that reinforces habit consistency and can later be used for:

  • Leaderboards
  • XP bonuses
  • Achievement badges
  • Social features
  • User statistics

Primary Objective

Implement a complete streak system that tracks consecutive days of verified activity.

A streak represents:

"How many consecutive days has a user successfully completed at least one verified activity?"

Examples:

Day 1 → Workout completed → Streak = 1

Day 2 → Quiz completed → Streak = 2

Day 3 → Workout completed → Streak = 3

Day 4 → No activity → Streak broken

Day 5 → Quiz completed → Streak = 1

The streak should be based on calendar days, not activity counts.

Multiple activities on the same day should NOT increase the streak multiple times.


Streak Rules

Rule 1

Only verified activities count.

Examples:

  • Verified workout
  • Verified quiz completion

Only activities that successfully pass backend validation should contribute.


Rule 2

A user can only gain ONE streak day per calendar day.

Examples:

5 workouts completed on the same day:

Current streak increases only once.


Rule 3

If the user completes an activity on the next consecutive day:

currentStreak += 1


Rule 4

If more than one day is missed:

currentStreak resets to 1

Example:

June 1 completed

June 2 completed

June 3 missed

June 4 completed

New streak = 1


Rule 5

Track both:

  • currentStreak
  • longestStreak

Example:

Current Streak: 12

Longest Streak: 34


Data Model Requirements

Create a streak profile for each user.

Suggested structure:

{
walletAddress: string,

currentStreak: number,

longestStreak: number,

lastActivityDate: Date,

streakStartDate: Date,

totalDaysActive: number,

createdAt: Date,

updatedAt: Date
}

Adapt to existing database structure if necessary.


Activity Processing Logic

Whenever a verified activity is recorded:

  1. Retrieve streak data.
  2. Normalize dates to UTC day boundaries.
  3. Compare current day against lastActivityDate.
  4. Determine:

Same day:

  • No streak increase

Next consecutive day:

  • Increase streak by 1

Gap greater than 1 day:

  • Reset streak to 1

Update longest streak when applicable.

Persist all changes.


Timezone Requirements

This is extremely important.

Do NOT compare raw timestamps.

Use normalized day values.

The system must avoid bugs caused by:

  • Different timezones
  • Activities completed near midnight
  • Server timezone differences

Implement using UTC dates or a clearly documented alternative.


API Requirements

Create backend endpoints:

GET /api/streak/:walletAddress

Returns:

{
currentStreak,
longestStreak,
totalDaysActive,
lastActivityDate,
streakStartDate
}


Frontend Requirements

Display streak information prominently on the user dashboard.

Suggested UI:

🔥 Current Streak: 12 Days

🏆 Longest Streak: 34 Days

Last Activity:
June 15, 2026


Dashboard Enhancements

Add streak indicators to:

  • User profile
  • Habit dashboard
  • Plant overview page

If appropriate.


Future Compatibility

Design the implementation so it can later support:

  • XP rewards
  • Achievement badges
  • Monthly leaderboards
  • Friend leaderboards
  • Streak milestone rewards

Avoid hardcoding assumptions that would block future expansion.


Testing Requirements

Create comprehensive tests for:

  1. First activity creates streak.

  2. Multiple activities same day.

  3. Consecutive day activity.

  4. Missed day reset.

  5. Long streak updates longest streak.

  6. UTC boundary handling.

  7. New users.

  8. Existing users without streak data.

  9. Duplicate activity submissions.

  10. Edge cases around midnight.

Provide tests and ensure implementation is production-ready.


Deliverables

  1. Backend streak service.
  2. Database schema updates.
  3. API endpoints.
  4. Frontend dashboard integration.
  5. Unit tests.
  6. Integration tests.
  7. Documentation explaining how streak calculations work.
  8. Explanation of architectural decisions and tradeoffs.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions