A REST API service designed to track and manage LeetCode streaks with timezone awareness and group collaboration features. This project solves the problem of LeetCode's official streak system not accounting for user timezones, which often causes users to lose their streaks unfairly.
LeetCode Streak API is an open-source backend service that stores LeetCode user data and maintains a comprehensive history of:
- Daily solving streaks (with timezone support)
- Solved problems history
- User statistics and profiles
- Group challenges with friends
The API fetches official user data directly from LeetCode's GraphQL API and provides enhanced features that the official platform doesn't offer.
- Timezone Problem: LeetCode's official streak system doesn't consider user timezones, making it easy to lose streaks even when solving problems daily in your local time.
- Group Streaks: Connect with friends and maintain group streaks together, creating a collaborative competitive environment.
- Historical Data: Keep a permanent record of your solving history and streak progress.
- ✅ User authentication via LeetCode username
- ✅ Automatic sync with LeetCode's official API
- ✅ Timezone-aware streak tracking
- ✅ Historical streak data
- ✅ Individual and group statistics
- ✅ Problem submission tracking
- ✅ Group creation and management
- ✅ RESTful API architecture
- Framework: NestJS (Node.js)
- Language: TypeScript
- Database: PostgreSQL
- ORM: Prisma
- Authentication: JWT
- Package Manager: pnpm
- Date Handling: date-fns, date-fns-tz
- Validation: class-validator, class-transformer
- Node.js (v18 or higher)
- PostgreSQL database
- pnpm (recommended) or npm
-
Clone the repository
git clone https://github.com/darwingtx/LeetCodeStreak-Backend.git cd leetcode-streak-backend -
Install dependencies
pnpm install
-
Configure environment variables
Create a
.envfile in the root directory:DATABASE_URL="postgresql://user:password@localhost:5432/leetcode_streak" JWT_SECRET="your-secret-key" PORT=3000
-
Run database migrations
pnpm prisma migrate dev
-
Generate Prisma Client
pnpm prisma generate
pnpm run start:devpnpm run build
pnpm run start:prodpnpm run start:debugThe API will be available at http://localhost:3000
GET /auth/login/:username- Login/Register with LeetCode username
GET /user/profile/:id- Get user profile by usernamePATCH /user/update/:username- Update user timezone{ "timezone": "America/New_York" }
GET /streak/:id- Get user streak dataPATCH /streak/update/:id- Update streak (with timezone){ "timezone": "America/New_York" }POST /streak/:id/reset- Reset user streakPATCH /streak/updateall/:id- Update all streak data for userPOST /streak/updatebd/:id- Sync streak data from database
[To be implemented]- Group creation and management endpoints are in development
[To be implemented]- Submission tracking endpoints are in development
[To be implemented]- Statistics endpoints are in development
The application uses Prisma ORM with the following main models:
- User: LeetCode user profiles and statistics
- UserSubmission: Individual problem submissions
- StreakHistory: Daily streak records
- Group: Study/challenge groups
- UserGroup: Group membership
- GroupStreakHistory: Group streak tracking
- SyncLog: API sync logs
For detailed schema, check /prisma/schema.prisma
# Unit tests
pnpm run test
# E2E tests
pnpm run test:e2e
# Test coverage
pnpm run test:covWe welcome contributions from the community! This is an open-source project and we'd love your help to make it better.
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m 'Add some amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- 🐛 Bug fixes
- ✨ New features (submissions tracking, statistics, etc.)
- 📝 Documentation improvements
- 🎨 UI/Frontend development
- 🧪 Test coverage
- 🌐 Internationalization
- ⚡ Performance optimizations
- Complete group management functionality
- Implement submission tracking endpoints
- Add statistics and analytics endpoints
- Create scheduled tasks for automatic syncs
- Build notification system for streak reminders
- Develop frontend application
- Implement achievement/badge system
- Report bugs: GitHub Issues
- Discussions: GitHub Discussions
Darwin Castaño
- GitHub: @darwingtx
Made with ❤️ by developers, for developers
Keep your streak alive, no matter your timezone! 🌍⏰
