A simple fitness tracker with gamification: XP, streaks, badges, and leaderboards. Built with Node.js, Express, MongoDB, EJS, and JWT auth.
- User auth (register/login/logout) with hashed passwords and JWT tokens (cookie + Bearer)
- Log workouts (type, duration, calories, date)
- XP: 10 XP per 30 minutes (rounded up)
- Streaks: consecutive workout days tracked automatically
- Badges: Bronze (100), Silver (500), Gold (1000), Platinum (2500), Diamond (5000)
- Leaderboards by XP and current streak
- Node.js, Express.js
- MongoDB (Mongoose)
- JWT (stateless auth)
- EJS templating
- Prerequisites: Node 18+ and MongoDB running locally.
- Environment:
.envis included with defaults. AdjustPORT,MONGODB_URI,JWT_SECRET,JWT_EXPIRES_INas needed. - Install and run:
cd c:\Users\Manan\Desktop\Backend
npm install
npm run devServer: http://localhost:3001
/Home/auth/registerRegister/auth/loginLogin/dashboardDashboard (add workout, view stats + recent workouts)/leaderboardLeaderboards (top XP, top streaks)
- Stateless JWT auth; token also set as httpOnly cookie for server-rendered pages.
- DELETE forms use method-override via
?_method=DELETE. - Static assets served under
/static.
- Add Chart.js graphs to
dashboard.ejs. - Provide JSON API endpoints.
- Simulate wearable sync by generating random workouts.
- Add pagination/filters to workouts list.
MIT