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