File size: 9,094 Bytes
59de848 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# 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
1. **Clone and navigate to project**
```bash
cd task-trek
```
2. **Install dependencies**
```bash
npm run install-all
```
3. **Environment Setup**
```bash
cp .env.example .env
```
Update `.env` with your configuration:
```env
MONGODB_URI=mongodb://localhost:27017/task-trek
JWT_SECRET=your-super-secret-key
PORT=5000
CLIENT_URL=http://localhost:3000
```
4. **Start the application**
```bash
npm run dev
```
This will start:
- Backend server on `http://localhost:5000`
- Frontend development server on `http://localhost:3000`
## ๐ 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 mode
- `npm run server` - Start only the backend server
- `npm run client` - Start only the frontend development server
- `npm run install-all` - Install dependencies for both frontend and backend
- `npm run build` - Build the frontend for production
### Backend (server/)
- `npm start` - Start production server
- `npm run dev` - Start development server with nodemon
### Frontend (client/)
- `npm run dev` - Start Vite development server
- `npm run build` - Build for production
- `npm run preview` - Preview production build
## ๐ API Endpoints
### Authentication
- `POST /api/auth/register` - Register new employee
- `POST /api/auth/login` - Employee login
- `GET /api/auth/me` - Get current user profile
- `POST /api/auth/refresh-token` - Refresh JWT token
### Employees
- `GET /api/employees` - List all employees (Admin/Manager)
- `GET /api/employees/:id` - Get employee by ID
- `PUT /api/employees/:id` - Update employee
- `DELETE /api/employees/:id` - Deactivate employee
- `POST /api/employees/:id/credits` - Award credits
### Productivity
- `POST /api/productivity` - Create/update productivity record
- `GET /api/productivity` - Get productivity records
- `GET /api/productivity/:id` - Get specific record
- `GET /api/productivity/employee/:id/summary` - Get employee summary
- `DELETE /api/productivity/:id` - Delete record
### Rankings
- `POST /api/rankings/generate` - Generate monthly rankings
- `POST /api/rankings/:id/publish` - Publish rankings and award credits
- `GET /api/rankings` - Get published rankings
- `GET /api/rankings/:id` - Get specific ranking
- `GET /api/rankings/employee/:id/history` - Get employee ranking history
### Vouchers
- `POST /api/vouchers` - Create voucher (Admin/Manager)
- `GET /api/vouchers` - List available vouchers
- `GET /api/vouchers/:id` - Get voucher details
- `POST /api/vouchers/:id/redeem` - Redeem voucher
- `GET /api/vouchers/redemptions/my` - Get user redemptions
- `GET /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
1. Collect productivity data for all active employees
2. Calculate overall scores using weighted formula
3. Sort employees by score (highest first)
4. 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
```bash
npm run dev
```
### Production Build
```bash
npm run build
npm start
```
### Environment Variables for Production
```env
NODE_ENV=production
MONGODB_URI=your-production-mongodb-uri
JWT_SECRET=your-production-jwt-secret
CLIENT_URL=https://your-domain.com
```
## ๐งช Testing
```bash
# Run backend tests
cd server && npm test
# Run frontend tests
cd client && npm test
```
## ๐ Contributing
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](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! ๐
|