Introduction
The "GitHub Streak" has evolved from a fun gamification metric into a source of pressure for many developers. Missing a single day due to illness, travel, or researching (non-code work) can break a year-long chain.
DailyDiff acts as a fail-safe mechanism. It is an "Ethical Streak Maintainer" that ensures your profile remains active by automating legitimate, low-touch contributions (like documentation updates or log rotations) when you are unable to push code manually.
System Architecture
The application follows a decoupled client-server architecture to handle secure authentication and background scheduling.
Core Stack
- Frontend: React (Vite) for the dashboard and configuration.
- Backend: Node.js (Express) for API handling.
- Database: Supabase (PostgreSQL) for storing user tokens and preferences.
- Scheduler:
node-cronfor precise time-based execution.
Data Flow
- User Authorization: User logs in via GitHub OAuth.
- Token Storage: Access tokens are encrypted and stored in Supabase.
- Schedule Configuration: User sets a "Safety Window" (e.g., "Check activity at 11:00 PM").
- Cron Execution: The server wakes up, checks the user's activity for the day via GitHub API.
- Conditional Push: If (and only if) no contributions are found, a micro-commit is generated.
Technical Implementation
The Automation Engine
The heart of the system is the node-cron scheduler which orchestrates the checking process without constant server uptime requirements for the client.
GitHub API Integration
To determine if a commit is necessary, we query the GraphQL API to fetch the user's contribution calendar for the specific date.
Challenges & Solutions
1. Token Expiration
Challenge: GitHub OAuth tokens have finite lifespans.
Solution: Implemented a token refresh rotation strategy in Supabase. When a cron job encounters a 401 error, it flags the user profile for re-authentication and sends a notification email via Resend.
2. "Empty" Commit Ethics
Challenge: Creating empty commits can be seen as "cheating."
Solution: DailyDiff enforces an "Ethical Mode." Instead of blank commits, it updates a daily-log.md file in a specialized repository with a timestamp and a quote, ensuring the contribution represents actual data modification.
Future Roadmap
- AI Summaries: Integrate Gemini to generate a summary of the week's research papers read (instead of just a timestamp).
- Multi-Platform Support: Extend streak protection to GitLab and Bitbucket.