# πŸ“Š Employee Hour Tracker

> A badass web app to monitor employees entering their time, serve up real-time analytics, and automate your backups β€” so you can stop worrying and focus on getting sh*t done.

![Node.js](https://img.shields.io/badge/Node.js-18%2B-green)
![Express](https://img.shields.io/badge/Express-4.18-blue)
![SQLite](https://img.shields.io/badge/SQLite-3-orange)
![Docker](https://img.shields.io/badge/Docker-Ready-blue)
![License](https://img.shields.io/badge/License-MIT-yellow)

---

<details>
  <summary><i>Click to show screenshots</i></summary>

## Screenshots
![Table View](./Screenshot_2025-08-08_at_4.03.27_PM.png)
[![Table View](./Screenshot_2025-08-08_at_4.03.27_PM.png?thumbnail)](./Screenshot_2025-08-08_at_4.03.27_PM.png)
[![Management](./Screenshot_2025-08-08_at_4.03.54_PM.png?thumbnail)](./Screenshot_2025-08-08_at_4.03.54_PM.png)
[![Analytics](./Screenshot_2025-08-08_at_4.05.46_PM.png?thumbnail)](./Screenshot_2025-08-08_at_4.05.46_PM.png)

</details>

---

## ✨ Features

### πŸ“… **Time Tracking (A.K.A. Keeping Tabs on Your Squad)**

- Weekly grid interface sharp enough to make spreadsheets cry  
- Click once? Log it. Twice? Flag it. Thrice? Fix-it mode, baby  
- Built-in calendar picker so you don't fat-finger the wrong week  
- Default week your way β€” past, present, or hell, even the future  
- No β€œSave” button needed β€” everything saves itself like grown-up software

### πŸ“ˆ **Analytics Dashboard**

- Sexy-ass charts courtesy of Chart.js  
- Date ranges? Yep. Choose from Last Week, Month, 90 Days, or freestyle 
- Pie charts of shame: See who's not entered a damn thing  
- Employee comparisons so you know who’s crushing it  
- Summary stats that slap you with truths at a glance

### πŸ‘₯ **Employee Management**

- Add, edit, and yeet employees in or out with full control  
- Inline editing β€” because popups can get bent  
- Confirmation dialogs keep you from rage-deleting poor Jim by mistake  
- Secure, session-based login β€” no freeloaders allowed

### πŸ’Ύ **Data Export & Backup**

- Export in:
  - Colored Excel (preserves all that green/yellow/red goodness)  
  - JSON (for the nerds and the APIs)  
  - CSV (because boring as hell = universal)  
- Auto-backups so you can sleep like a baby β€” configurable too

### 🎨 **Beautiful AF UI**

- Responsive as heck β€” use it on a tablet, a phone, or a potato  
- A glorious purple gradient worth showing off to design nerds  
- Smooth transitions that don’t make you nauseous  
- Touch support that'll make any mobile user say β€œdamn that’s clean”  
- You might actually enjoy navigating this one

---

## πŸš€ Quick Start

### Prerequisites (Don’t Skip This, Ya Animal)

- Node.js 18+  
- OR Docker & Docker Compose (we’re fancy)

---

### πŸ§ͺ Option 1: Raw Node.js
```bash
git clone https://github.com/tebwritescode/employee-hour-tracker.git
cd employee-hour-tracker
npm install
npm start  # Start like a regular ol' app
npm run dev  # If you want auto-reload magic
```

---

### 🐳 Option 2: Docker Compose (Recommended as Hell)

```bash
git clone https://github.com/tebwritescode/employee-hour-tracker.git
cd employee-hour-tracker
docker-compose up -d
docker-compose logs -f  # Because watching logs is oddly satisfying
docker-compose down  # When it’s time to kill it
```

---

### πŸ”¨ Option 3: Docker CLI (For Hardcore Terminal Nerds)

```bash
docker build -t employee-hour-tracker .
docker run -d \
  --name employee-tracker \
  -p 3000:3000 \
  -v employee-tracker-data:/app/data \
  employee-hour-tracker
```

App launches at `http://localhost:3000`  
Go ahead, open it. We dare you.

---

## πŸ”§ Configuration (Don't Screw These Up)

| Variable | Default | Description |
|----------|---------|-------------|
| `PORT` | `3000` | Where the hell the server listens |
| `NODE_ENV` | `development` | Pick your poison: `development` vs `production` |
| `DB_PATH` | `./employee_tracker.db` | Where your crucial time data lives |
| `SESSION_SECRET` | `employee-tracker-secret-key` | Hide this like it’s your banking password |
| `DEFAULT_ADMIN_USERNAME` | `admin` | The overlord’s default login |
| `DEFAULT_ADMIN_PASSWORD` | `admin123` | CHANGE THIS ASAP πŸ”₯ |
| `BACKUP_ENABLED` | `true` | Yeah, you want this on |
| `BACKUP_INTERVAL` | `86400000` | How often to save your backside (MS) |
| `BACKUP_RETENTION_DAYS` | `30` | How long to keep your safety net |

---

### πŸ‹ Docker Compose Config

```yaml
version: '3.8'
services:
  app:
    image: employee-hour-tracker
    environment:
      - NODE_ENV=production
      - SESSION_SECRET=your-secure-secret-here
      - DEFAULT_ADMIN_USERNAME=admin
      - DEFAULT_ADMIN_PASSWORD=change-this-password
    ports:
      - "3000:3000"
    volumes:
      - ./data:/app/data
      - ./backups:/app/backups
```

---

## πŸ“– Usage Guide

### ⏱️ Time Tracking `/tracking`

1. Pick your week and start clicking grid cells like a god  
2. Cycle statuses like a boss  
3. Sit back β€” auto-save’s doing the work for you  
4. Use arrows & selectors if you like jumping through time

### πŸ“Š Analytics `/analytics`

1. Choose your dates  
2. Interpret shame-slices in the pie chart  
3. Compare your team’s hustle in bar form  
4. Click Export and flex on your boss with pretty data

### πŸ‘¨β€πŸ’Ό Admin Stuff `/management`

1. Log in as admin (`admin` / `admin123`) β€” seriously, change that  
2. Add new employees like it’s HR day  
3. Click to edit names (typos won’t fix themselves)  
4. Boot off old names thoughtfully (confirmation included)  
5. Global settings & data export tools right at your manicured fingertips

---

## πŸ—οΈ Project Architecture

```
employee-hour-tracker/
β”œβ”€β”€ πŸ“„ server.js              # RESTful backend engine of doom
β”œβ”€β”€ πŸ“„ backup.js              # Makes sure your data doesn’t go *poof*
β”œβ”€β”€ πŸ“„ package.json           # Clearly you’ve heard of this
β”œβ”€β”€ πŸ“„ docker-compose.yml     # Container boyband orchestration
β”œβ”€β”€ πŸ“„ Dockerfile             # Turns your app into deployable magic
β”œβ”€β”€ πŸ“ public/                # Frontend good stuff
β”‚   β”œβ”€β”€ index.html            # Your glorious entry point
β”‚   β”œβ”€β”€ style.css             # Sharp purple swagger
β”‚   β”œβ”€β”€ script.js             # Grid logic + admin finesse
β”‚   └── chart.js              # Analytics eye-candy
β”œβ”€β”€ πŸ“ backups/               # This folder saves asses
└── πŸ“— employee_tracker.db    # Don't delete this... seriously
```

---

### βš™οΈ Tech Stack

- **Backend**: Node.js + Express  
- **Database**: SQLite3 + better-sqlite3 (the better part matters)  
- **Frontend**: Raw Vanilla JS (no extra calories) + Chart.js  
- **Auth**: express-session + bcryptjs (like a bouncer for your admin area)  
- **Containerization**: Docker & Docker Compose  

---

## πŸ” Security

- Hashed passwords (get rekt plain text)  
- Session-based login β€” no silly tokens  
- CORS-tight so outsiders can’t jack your data  
- SQL injection-proof β€” parameterized 'cause we’re not amateurs  
- Secrets optional but highly encouraged (you’ve been warned)

---

## πŸ”§ Dev Life

```bash
npm run dev           # Hot reload fixups
npm start             # Serious prod mode
npm run install-deps  # Just in case you skipped setup like a rebel
```

---

### πŸ”Œ API Endpoints

| Method | URL | What-It-Does | Auth |
|--------|-----|--------------|------|
| GET | `/api/employees`       | Fetch worker list | ❌ |
| POST | `/api/employees`      | Add a badass | βœ… |
| PUT | `/api/employees/:id`   | Update someone’s stuff | βœ… |
| DELETE | `/api/employees/:id`| Boot 'em | βœ… |
| GET | `/api/time-entries`    | Fetch time logs | ❌ |
| POST | `/api/time-entries`   | Save/correct logs | ❌ |
| GET | `/api/analytics`       | Data candy | ❌ |
| POST | `/api/login`          | Get in | ❌ |
| POST | `/api/logout`         | Peace out | βœ… |
| GET | `/api/export/:format`  | Download your victory proof | βœ… |

---

## 🐞 Known WTFs

- Week nav is a little moody if you click like a caffeinated squirrel  
- In rare cases, the status marker’s a lazy bastard and doesn’t update instantly  

(Fix coming soon. Or yell at us, that works too.)

## Support

Issues? Questions? Praise-singing?  
File an issue on GitHub or yell at [teb](https://github.com/tebwritescode).

---
πŸ‘‘ Created by: [tebbydog0605](https://github.com/tebwritescode)  
πŸ‹ Docker Hub: [tebwritescode](https://hub.docker.com/u/tebwritescode)  
πŸ’» Website: [teb.codes](https://teb.codes)
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9