Commit Graph

6 Commits

Author SHA1 Message Date
William Valentin
e7396c10d6 feat(backend): implement complete gamification system
Implement comprehensive points and badges system with MongoDB transactions:

Point System:
- Create PointTransaction model for transaction history
- Award points atomically using MongoDB transactions
- Point values: street adoption (+100), task completion (+50), post creation (+10), event participation (+75)
- Track balance after each transaction
- Support point deduction for reward redemption

Badge System:
- Create Badge and UserBadge models
- Define badge criteria types: street_adoptions, task_completions, post_creations, event_participations, points_earned
- Auto-award badges based on user achievements
- Badge rarity levels: common, rare, epic, legendary
- Track badge progress for users
- Prevent duplicate badge awards

Gamification Service:
- Implement gamificationService.js with 390 lines of logic
- awardPoints() with transaction support
- checkAndAwardBadges() for auto-awarding
- getUserBadgeProgress() for progress tracking
- getUserStats() for achievement statistics
- Atomic operations prevent double-awarding

Integration:
- Streets route: Award points and badges on adoption
- Tasks route: Award points and badges on completion
- Posts route: Award points and badges on creation
- Events route: Award points and badges on RSVP
- Rewards route: Deduct points on redemption
- Badges API: List badges, track progress, view earned badges

Updated User Model:
- Add points field (default 0)
- Add earnedBadges virtual relationship
- Add indexes for performance (points for leaderboards)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 10:42:51 -07:00
William Valentin
b3dc608750 feat(backend): implement comprehensive security and validation
Implement enterprise-grade security measures and input validation:

Security Features:
- Add Helmet.js for security headers (XSS, clickjacking, MIME protection)
- Implement rate limiting (5/15min for auth, 100/15min for API)
- Add Socket.IO JWT authentication middleware
- Fix JWT auth middleware (remove throw in catch, extend token to 7 days)
- Implement centralized error handling with AppError class
- Add CORS restrictive configuration

Input Validation:
- Add express-validator to all routes (auth, streets, tasks, posts, events, rewards, reports, users)
- Create comprehensive validation schemas in middleware/validators/
- Consistent error response format for validation failures

Additional Features:
- Add pagination middleware for all list endpoints
- Add Multer file upload middleware (5MB limit, image validation)
- Update .env.example with all required environment variables

Dependencies Added:
- helmet@8.1.0
- express-rate-limit@8.2.1
- express-validator@7.3.0
- multer@1.4.5-lts.1
- cloudinary@2.8.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 10:42:19 -07:00
William Valentin
8002406120 feat(frontend): update frontend submodule 2025-10-30 01:39:30 -07:00
William Valentin
e9a83d9ab7 refactor(backend): remove unused err variable in auth middleware 2025-10-30 01:38:51 -07:00
William Valentin
d75fa95371 feat: Add frontend submodule 2025-10-29 13:12:39 -07:00
William Valentin
999d37babb feat: Initial commit of backend services and AGENTS.md 2025-10-29 13:12:30 -07:00