# Sales Tracker

> A modern-as-hell, playful web application for tracking sales and wrangling analytics — with an interactive login that's almost too clever for its own good.

![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
![](./Screenshot_2025-08-08_at_3.35.43_PM.png)
[![](./Screenshot_2025-08-08_at_3.36.48_PM.png?thumbnail)](./Screenshot_2025-08-08_at_3.36.48_PM.png)
[![](./Screenshot_2025-08-08_at_3.36.41_PM.png?thumbnail)](./Screenshot_2025-08-08_at_3.36.41_PM.png)
[![](./Screenshot_2025-08-08_at_3.36.30_PM.png?thumbnail)](./Screenshot_2025-08-08_at_3.36.30_PM.png)
[![](./Screenshot_2025-08-08_at_3.36.21_PM.png?thumbnail)](./Screenshot_2025-08-08_at_3.36.21_PM.png)
[![](./Screenshot_2025-08-08_at_3.35.43_PM.png?thumbnail)](./Screenshot_2025-08-08_at_3.35.43_PM.png)

</details>
    
## Features

- 📊 **Sales Analytics Dashboard** – Visualize sales like a data-driven badass  
- 👥 **User Management** – Multi-level permissions so your team doesn’t accidentally break stuff  
- 📈 **Data Entry & Export** – Input sales quickly and shoot that crap into Excel  
- 🎮 **Interactive Login** – Cursor-evasive Sign In button just to mess with people  
- 🔒 **Secure Authentication** – Password hashing that even your nosy-ass sysadmin can’t break  
- 📱 **Responsive Design** – Runs smooth on desktop, tablet, or that old phone you still won’t upgrade

### Core Functionality

- **Employee Management** – Add/edit employees, their commissions, draws — the whole damn deal  
- **Sales Data Entry** – Do it by hand or slam in a CSV like a pro  
- **Analytics Dashboard** – Filter and graph until the numbers make sense or you rage-quit  
- **Admin Panel** – Wrapped in password protection, because duh

### Database Schema

Your data’s not just dumped — we gave it structure like responsible grownups:

- **Employee Table**: Tracks the who, what, and when of your sales crew  
- **Sales Table**: Logs every dollar that rolls in  
- **Settings Table**: Keeps track of your system’s default working setup and toggles  
- **Goals Table**: Measure who's slaying and who's slacking

### Three Main Pages

#### 1. Management Tab (Locked Behind a Password Wall)

- Admin login with proper credentials (no password123 crap)  
- Employee configuration panel  
- Settings for system behavior and admin updates  
- Switch how commissions & draws are shown — % or actual bucks  
- **Epic theme picker with 8 presets for maximum visual hell yeah**

#### 2. Analytics Page (Wide Frickin’ Open)

- Tracks Year-to-Date stats, or whatever time range floats your fancy  
- Uses Chart.js because facts deserve pretty pictures  
- Bar, pie, line charts — you name it  
- Filter time ranges and export data like an absolute legend  
- Adaptive UI responds to theme like a mood ring for business

#### 3. Data Entry Page (Wide Open Like Your Inbox)

- Manual sales input  
- Commissions calculated automatically (no more math headaches)  
- Draw payment tracking — keep it drama-free  
- Upload CSVs and watch it handle bulk data like a champ  
- Validates your entries because your future self will thank you  
- Keeps the recent entries right where you can see them

## Technical Stack

Because building badass tools needs solid tech:

- 🧠 **Backend**: Flask + SQLAlchemy  
- 🐘 **Database**: SQLite, cause it just works  
- 🖋️ **Forms**: Flask-WTF with CSRF defense  
- 🔐 **Security**: Werk-f’ing-Zeug password hashing for locked-tight sessions  
- 💅 **Frontend**: Bootstrap 5, sexy in all screen sizes  
- 📊 **Charts**: Chart.js — clean, crisp, and fast AF  
- 🐳 **Deployment**: Dockerized and ready to ship

## Installation & Setup

### Quick Start with Docker (The Way Developers Actually Do It)

1. Clone this bad boy:
   ```bash
   git clone <repository-url>
   cd sales-tracker
   chmod +x setup.sh
   ./setup.sh
   ```

2. Manual Docker Compose (for control freaks):
   ```bash
   docker-compose up --build
   ```

3. Launch that sucker:
   - Visit http://localhost:5000  
   - Admin credentials: `admin` / `admin` (you’ll wanna change that ASAP)

### Setup Options

**Dev Mode** — a no-pressure playground:
```bash
./setup.sh --dev
```

**Production Mode** — the serious stuff:
```bash
./setup.sh --production
```

**Persistent Mode** — the one that doesn’t forget your data:
```bash
./setup.sh --persistent
```

Gives access at http://localhost:5001 if you're following recipes correctly.

### Got Database Problems? Let’s Kick Their Ass

1. Use in-container magic:
   ```bash
   docker run -p 5000:5000 -e DATABASE_URL=sqlite:///sales_tracker.db sales-tracker
   ```

2. Fix crappy host permissions:
   ```bash
   mkdir -p data uploads
   chmod 755 data uploads
   ```

3. Or go full persistent mode:
   ```bash
   ./setup.sh --persistent
   ```

### Local Dev Setup

1. Get your damn Python set up:
   ```bash
   python3 -m venv venv
   source venv/bin/activate
   pip install -r requirements.txt
   ```

2. Fire up the beast:
   ```bash
   python app.py
   ```

3. Open browser → http://localhost:5000  
   (Or don’t. Be a rebel.)

## Configuration

### Environment Sh*t You Shouldn’t Forget

- `SECRET_KEY` — don’t check this into Git, ya dingus  
- `FLASK_ENV` — development or production  
- `DATABASE_URL` — override the default if you like pain

### Defaults

- Admin: `admin`  
- Password: `admin` (again, change it dammit)  
- Database: `sales_tracker.db`

## Usage Guide

### First-Time Dance

1. Load up http://localhost:5000  
2. Smash that “Admin Login” button  
3. Change the password — your organization’s honor depends on it  
4. Add employees like a benevolent god

### Logging Sales (a.k.a. The Reason This Sh*t Exists)

1. Go to Data Entry  
2. Type in details  
3. Let auto-commission math do its thing  
4. Or bulk upload a fancy-ass CSV

### Viewing Analytics

1. Hit Analytics  
2. Filter stuff until it tells you something useful  
3. Export if your boss wants proof

### Managing the Team

1. Admin login  
2. Edit employees or set their goals  
3. Toggle display settings — % or flat amounts  
4. Yell at slackers (optional)

### Theme Customization (Because Vibes Matter)

1. Hit the palette icon in the navbar  
2. Choose one of the 8 eye-popping themes  
3. Watch the app change outfits instantly

Themes include:

- Default Blue  
- Dark Theme (work in the shadows, baby)  
- Nature Green (for tree-huggin’ teams)  
- Royal Purple (His Royal Freshness would approve)  
- Sunset Orange  
- Ocean Teal  
- Corporate Red (power tie vibes)  
- Modern Pink

Settings persist for admin; guests get localStorage (so they don’t ruin your vibe).

## File Structure

```
sales-tracker/
├── app.py                 # Main Flask beast
├── requirements.txt       # Python goodies
├── Dockerfile             # So your app works on my damn machine too
├── docker-compose.yml     # Stack orchestration magic

```

## API Endpoints

- `GET /api/sales_data?period=YTD` — give us that chart data  
- `GET /api/trends_data` — how the bloody hell are we doing?  
- `POST /bulk_upload` — shove an entire CSV down its throat

## Security Features

- Password hashing (locked tighter than grandma’s cookie jar)  
- CSRF protection — no cross-site BS allowed  
- Session-based ownership  
- Input validation so you don’t feed it junk  
- SQLAlchemy ORM to dodge SQL injection like Neo

## Performance

Fast as hell. Optimized frontend, backend, and everything in between. Ready to scale... maybe.

## Maintenance

### Backup the Damn DB

```bash
docker exec sales-tracker-app sqlite3 /app/sales_tracker.db ".backup /app/data/backup.db"
```

### Update This Beautiful Bastard

```bash
docker-compose down
docker-compose up --build
```

### Check Logs Like a Debugging Ninja

```bash
docker-compose logs -f sales-tracker
```

## Contributing

1. Fork it  
2. Branch it  
3. Make it better  
4. Pull request and bask in glory

## 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