Blame

28a846 Tebby Dog 2025-08-08 19:55:24
init
1
# 📊 Employee Hour Tracker
2
3
> A comprehensive web application for tracking employee work time with real-time analytics, management features, and automated backups.
4
5
![Node.js](https://img.shields.io/badge/Node.js-18%2B-green)
6
![Express](https://img.shields.io/badge/Express-4.18-blue)
7
![SQLite](https://img.shields.io/badge/SQLite-3-orange)
8
![Docker](https://img.shields.io/badge/Docker-Ready-blue)
9
10
## ✨ Features
11
12
### 📅 **Time Tracking**
13
- Interactive weekly grid interface for tracking employee time entries
14
- Click-to-cycle through status states: Not Entered → Entered → Incorrect
15
- Week navigation with integrated calendar picker
16
- Configurable default week settings
17
- Auto-save functionality for all changes
18
19
### 📈 **Analytics Dashboard**
20
- **Visual Analytics**: Interactive charts powered by Chart.js
21
- **Date Filtering**: Preset ranges (Last Week, Last Month, Last 90 Days) or custom date selection
22
- **Status Distribution**: Pie chart showing overall entry patterns
23
- **Employee Comparison**: Bar chart for performance analysis
24
- **Summary Cards**: Quick statistics at a glance
25
26
### 👥 **Employee Management**
27
- Complete employee lifecycle management
28
- Add new employees with immediate tracking integration
29
- Inline editing for employee names
30
- Safe removal with confirmation dialogs
31
- Session-based authentication for secure access
32
33
### 💾 **Data Export & Backup**
34
- **Multiple Export Formats**:
35
- Colored Excel files maintaining visual status indicators
36
- JSON format for system integrations
37
- CSV for universal compatibility
38
- **Automated Backups**: Scheduled database backups with configurable retention
39
40
### 🎨 **Modern UI/UX**
41
- Responsive design optimized for all devices
42
- Cohesive purple gradient theme throughout
43
- Smooth animations and transitions
44
- Mobile-friendly touch interactions
45
- Clean, intuitive navigation
46
47
## 🚀 Quick Start
48
49
### Prerequisites
50
- Node.js 18+ and npm
51
- OR Docker and Docker Compose
52
53
### Installation Options
54
55
#### **Option 1: Node.js**
56
57
```bash
58
# Clone the repository
59
git clone https://github.com/tebwritescode/employee-hour-tracker.git
60
cd employee-hour-tracker
61
62
# Install dependencies
63
npm install
64
65
# Start the application
66
npm start
67
68
# For development with auto-reload
69
npm run dev
70
```
71
72
#### **Option 2: Docker Compose** (Recommended)
73
74
```bash
75
# Clone the repository
76
git clone https://github.com/tebwritescode/employee-hour-tracker.git
77
cd employee-hour-tracker
78
79
# Start with Docker Compose
80
docker-compose up -d
81
82
# View logs
83
docker-compose logs -f
84
85
# Stop the application
86
docker-compose down
87
```
88
89
#### **Option 3: Docker CLI**
90
91
```bash
92
# Build the image
93
docker build -t employee-hour-tracker .
94
95
# Run the container
96
docker run -d \
97
--name employee-tracker \
98
-p 3000:3000 \
99
-v employee-tracker-data:/app/data \
100
employee-hour-tracker
101
```
102
103
Access the application at `http://localhost:3000`
104
105
## 🔧 Configuration
106
107
### Environment Variables
108
109
| Variable | Default | Description |
110
|----------|---------|-------------|
111
| `PORT` | `3000` | Server port |
112
| `NODE_ENV` | `development` | Environment mode (`development` or `production`) |
113
| `DB_PATH` | `./employee_tracker.db` | Database file location |
114
| `SESSION_SECRET` | `employee-tracker-secret-key` | Session encryption key |
115
| `DEFAULT_ADMIN_USERNAME` | `admin` | Initial admin username |
116
| `DEFAULT_ADMIN_PASSWORD` | `admin123` | Initial admin password |
117
| `BACKUP_ENABLED` | `true` | Enable automated backups |
118
| `BACKUP_INTERVAL` | `86400000` | Backup interval in milliseconds (default: 24 hours) |
119
| `BACKUP_RETENTION_DAYS` | `30` | Number of days to keep backup files |
120
121
### Docker Compose Configuration
122
123
```yaml
124
version: '3.8'
125
services:
126
app:
127
image: employee-hour-tracker
128
environment:
129
- NODE_ENV=production
130
- SESSION_SECRET=your-secure-secret-here
131
- DEFAULT_ADMIN_USERNAME=admin
132
- DEFAULT_ADMIN_PASSWORD=change-this-password
133
ports:
134
- "3000:3000"
135
volumes:
136
- ./data:/app/data
137
- ./backups:/app/backups
138
```
139
140
## 📖 Usage Guide
141
142
### **Time Tracking** (`/tracking`)
143
1. Select the desired week using the date picker or arrow navigation
144
2. Click on any cell in the grid to cycle through status states
145
3. Changes are automatically saved to the database
146
4. Use the week selector to navigate between different time periods
147
148
### **Analytics** (`/analytics`)
149
1. Select a date range using preset options or custom dates
150
2. View status distribution in the pie chart
151
3. Compare employee performance in the bar chart
152
4. Export data using the export buttons
153
154
### **Management** (`/management`)
155
1. Login with admin credentials (default: `admin`/`admin123`)
156
2. Add new employees using the "Add Employee" form
157
3. Edit employee names by clicking the edit icon
158
4. Remove employees with the delete button (requires confirmation)
159
5. Access global settings and export options
160
161
## 🏗️ Architecture
162
163
```
164
employee-hour-tracker/
165
├── 📄 server.js # Express server and API endpoints
166
├── 📄 backup.js # Automated backup functionality
167
├── 📄 package.json # Dependencies and scripts
168
├── 📄 docker-compose.yml # Docker composition
169
├── 📄 Dockerfile # Container configuration
170
├── 📁 public/ # Frontend assets
171
│ ├── 📄 index.html # Main application HTML
172
│ ├── 📄 style.css # Styles and responsive design
173
│ ├── 📄 script.js # Frontend logic and interactions
174
│ └── 📄 chart.js # Analytics visualization
175
├── 📁 backups/ # Automated backup storage
176
└── 📗 employee_tracker.db # SQLite database
177
```
178
179
### Tech Stack
180
- **Backend**: Node.js + Express.js
181
- **Database**: SQLite3 with better-sqlite3
182
- **Frontend**: Vanilla JavaScript + Chart.js
183
- **Authentication**: Express-session + bcryptjs
184
- **Containerization**: Docker + Docker Compose
185
186
## 🔐 Security
187
188
- Password hashing using bcryptjs
189
- Session-based authentication
190
- CORS protection
191
- SQL injection prevention via parameterized queries
192
- Secure session management with configurable secrets
193
194
## 🛠️ Development
195
196
### Available Scripts
197
198
```bash
199
# Start development server with auto-reload
200
npm run dev
201
202
# Start production server
203
npm start
204
205
# Install all dependencies
206
npm run install-deps
207
```
208
209
### API Endpoints
210
211
| Method | Endpoint | Description | Auth Required |
212
|--------|----------|-------------|---------------|
213
| GET | `/api/employees` | List all employees | No |
214
| POST | `/api/employees` | Add new employee | Yes |
215
| PUT | `/api/employees/:id` | Update employee | Yes |
216
| DELETE | `/api/employees/:id` | Remove employee | Yes |
217
| GET | `/api/time-entries` | Get time entries | No |
218
| POST | `/api/time-entries` | Update time entry | No |
219
| GET | `/api/analytics` | Get analytics data | No |
220
| POST | `/api/login` | Admin authentication | No |
221
| POST | `/api/logout` | End admin session | Yes |
222
| GET | `/api/export/:format` | Export data | Yes |
223
224
## 🐛 Known Issues
225
226
- Week navigation may occasionally show incorrect dates when changing weeks rapidly
227
- Status markers might not update immediately in some edge cases with week transitions
228
229
## 📝 License
230
231
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
232
233
## 🤝 Contributing
234
235
Contributions are welcome! Please feel free to submit a Pull Request.
236
237
1. Fork the project
238
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
239
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
240
4. Push to the branch (`git push origin feature/AmazingFeature`)
241
5. Open a Pull Request
242
243
## 📧 Support
244
245
For issues, questions, or suggestions, please open an issue on the [GitHub repository](https://github.com/tebwritescode/employee-hour-tracker/issues).
246
247
---
248
249
<p align="center">Made with ❤️ by <a href="https://github.com/tebwritescode">tebwritescode</a></p>