Task Trek - Employee Productivity Tracking & Rewards System
A comprehensive web application for tracking employee productivity, generating monthly rankings, and managing a credit-based voucher rewards system.
๐ Features
Core Functionality
- Employee Management: Complete CRUD operations for employee profiles
- Productivity Tracking: Track various metrics including tasks, hours, quality scores, and attendance
- Monthly Rankings: Automated ranking system based on productivity scores
- Credit System: Award credits to top performers (1st: 1000, 2nd: 750, 3rd: 500)
- Voucher Store: Brand vouchers that employees can redeem using earned credits
- Role-Based Access: Different access levels for employees, managers, and admins
User Roles
- Employee: View personal dashboard, productivity history, redeem vouchers
- Manager: All employee features + manage team productivity, view department rankings
- Admin: Full system access including employee management and voucher creation
๐๏ธ Technical Architecture
Backend (Node.js + Express)
- Framework: Express.js with MongoDB
- Authentication: JWT-based authentication system
- Database: MongoDB with Mongoose ODM
- API: RESTful API design with comprehensive error handling
- Security: Helmet, CORS, input validation, password hashing
Frontend (React + Vite)
- Framework: React 18 with functional components and hooks
- Routing: React Router v6 for navigation
- State Management: React Query for server state + Context API
- Styling: Tailwind CSS with responsive design
- Forms: React Hook Form with validation
- Notifications: React Hot Toast for user feedback
Database Schema
- Employee: User profiles, credentials, credits
- Productivity: Monthly performance metrics
- Ranking: Monthly employee rankings
- Voucher: Brand rewards catalog
- VoucherRedemption: Redemption tracking
๐ Quick Start
Prerequisites
- Node.js (v16 or higher)
- MongoDB (local or cloud instance)
- npm or yarn package manager
Installation
Clone and navigate to project
cd task-trekInstall dependencies
npm run install-allEnvironment Setup
cp .env.example .envUpdate
.envwith your configuration:MONGODB_URI=mongodb://localhost:27017/task-trek JWT_SECRET=your-super-secret-key PORT=5000 CLIENT_URL=http://localhost:3000Start the application
npm run devThis will start:
- Backend server on
http://localhost:5000 - Frontend development server on
http://localhost:3000
- Backend server on
๐ Project Structure
task-trek/
โโโ server/ # Backend application
โ โโโ controllers/ # Request handlers
โ โโโ middleware/ # Custom middleware
โ โโโ models/ # MongoDB schemas
โ โโโ routes/ # API endpoints
โ โโโ utils/ # Helper functions
โ โโโ server.js # Main server file
โโโ client/ # Frontend application
โ โโโ src/
โ โ โโโ components/ # Reusable UI components
โ โ โโโ pages/ # Route components
โ โ โโโ contexts/ # React contexts
โ โ โโโ services/ # API services
โ โ โโโ hooks/ # Custom React hooks
โ โ โโโ utils/ # Helper functions
โ โโโ public/ # Static assets
โ โโโ index.html # HTML template
โโโ config/ # Configuration files
โโโ docs/ # Documentation
โโโ tests/ # Test files
๐ง Available Scripts
Root Level
npm run dev- Start both frontend and backend in development modenpm run server- Start only the backend servernpm run client- Start only the frontend development servernpm run install-all- Install dependencies for both frontend and backendnpm run build- Build the frontend for production
Backend (server/)
npm start- Start production servernpm run dev- Start development server with nodemon
Frontend (client/)
npm run dev- Start Vite development servernpm run build- Build for productionnpm run preview- Preview production build
๐ API Endpoints
Authentication
POST /api/auth/register- Register new employeePOST /api/auth/login- Employee loginGET /api/auth/me- Get current user profilePOST /api/auth/refresh-token- Refresh JWT token
Employees
GET /api/employees- List all employees (Admin/Manager)GET /api/employees/:id- Get employee by IDPUT /api/employees/:id- Update employeeDELETE /api/employees/:id- Deactivate employeePOST /api/employees/:id/credits- Award credits
Productivity
POST /api/productivity- Create/update productivity recordGET /api/productivity- Get productivity recordsGET /api/productivity/:id- Get specific recordGET /api/productivity/employee/:id/summary- Get employee summaryDELETE /api/productivity/:id- Delete record
Rankings
POST /api/rankings/generate- Generate monthly rankingsPOST /api/rankings/:id/publish- Publish rankings and award creditsGET /api/rankings- Get published rankingsGET /api/rankings/:id- Get specific rankingGET /api/rankings/employee/:id/history- Get employee ranking history
Vouchers
POST /api/vouchers- Create voucher (Admin/Manager)GET /api/vouchers- List available vouchersGET /api/vouchers/:id- Get voucher detailsPOST /api/vouchers/:id/redeem- Redeem voucherGET /api/vouchers/redemptions/my- Get user redemptionsGET /api/vouchers/redemptions- Get all redemptions (Admin)GET /api/vouchers/stats/overview- Get voucher statistics
๐ Authentication & Authorization
The system uses JWT tokens for authentication with role-based access control:
- Public: Login, health check
- Employee: Personal dashboard, profile, voucher redemption
- Manager: Employee role + team management, department analytics
- Admin: Full system access
Token expires in 7 days by default and includes employee ID, role, and email.
๐ Productivity Scoring
The system calculates overall productivity scores using weighted metrics:
- Task Completion Rate (30%): Tasks completed รท Tasks assigned ร 100
- Quality Score (25%): Direct input (0-100)
- Attendance (20%): Attendance percentage
- Deadline Performance (25%): Deadlines met รท Total deadlines ร 100
๐ Ranking & Credits System
Monthly Rankings
- Collect productivity data for all active employees
- Calculate overall scores using weighted formula
- Sort employees by score (highest first)
- Generate rankings with positions
Credit Awards
- 1st Place: 1000 credits
- 2nd Place: 750 credits
- 3rd Place: 500 credits
Voucher System
- Employees spend credits to redeem brand vouchers
- Vouchers have expiration dates and usage limits
- Track redemption history and status
๐ก๏ธ Security Features
- Password hashing with bcrypt
- JWT token authentication
- Input validation and sanitization
- Rate limiting on sensitive endpoints
- CORS configuration
- Helmet.js security headers
- Role-based access control
- Environment variable protection
๐ Deployment
Development
npm run dev
Production Build
npm run build
npm start
Environment Variables for Production
NODE_ENV=production
MONGODB_URI=your-production-mongodb-uri
JWT_SECRET=your-production-jwt-secret
CLIENT_URL=https://your-domain.com
๐งช Testing
# Run backend tests
cd server && npm test
# Run frontend tests
cd client && npm test
๐ Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฎ Future Enhancements
- Real-time notifications
- Advanced analytics dashboard
- Mobile application
- Integration with HR systems
- Automated report generation
- Goal setting and tracking
- Team collaboration features
- Multi-language support
๐ Support
For support or questions, please contact the development team or create an issue in the repository.
Task Trek - Empowering employee productivity through effective tracking and rewards! ๐