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:
- Retrieve streak data.
- Normalize dates to UTC day boundaries.
- Compare current day against lastActivityDate.
- Determine:
Same day:
Next consecutive day:
Gap greater than 1 day:
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:
-
First activity creates streak.
-
Multiple activities same day.
-
Consecutive day activity.
-
Missed day reset.
-
Long streak updates longest streak.
-
UTC boundary handling.
-
New users.
-
Existing users without streak data.
-
Duplicate activity submissions.
-
Edge cases around midnight.
Provide tests and ensure implementation is production-ready.
Deliverables
- Backend streak service.
- Database schema updates.
- API endpoints.
- Frontend dashboard integration.
- Unit tests.
- Integration tests.
- Documentation explaining how streak calculations work.
- Explanation of architectural decisions and tradeoffs.
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:
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:
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:
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:
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:
Same day:
Next consecutive day:
Gap greater than 1 day:
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:
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:
If appropriate.
Future Compatibility
Design the implementation so it can later support:
Avoid hardcoding assumptions that would block future expansion.
Testing Requirements
Create comprehensive tests for:
First activity creates streak.
Multiple activities same day.
Consecutive day activity.
Missed day reset.
Long streak updates longest streak.
UTC boundary handling.
New users.
Existing users without streak data.
Duplicate activity submissions.
Edge cases around midnight.
Provide tests and ensure implementation is production-ready.
Deliverables