Wellbeing Tracker

A web application for tracking employee wellbeing indicators with secure authentication and comprehensive reporting.

Features

  • 🔐 Secure Authentication: JWT-based login system with password hashing
  • 📊 Individual Wellbeing Charts: Separate charts for each wellbeing indicator
  • 🌙 Dark Mode: Toggle between light and dark themes
  • 👨‍💼 Admin Dashboard: User management and comprehensive reports
  • 📈 Data Export: Export data in CSV, Excel, and PDF formats
  • 💬 Comments System: Add comments to each wellbeing indicator
  • 📱 Responsive Design: Works on desktop, tablet, and mobile devices

Prerequisites

  • Go 1.23 or higher
  • SQLite (for local development)
  • Docker (optional, for containerized deployment)

Setup Instructions

1. Environment Variables

Create a .env file in the project root with the following variables:

# JWT Configuration
JWT_SECRET=your-jwt-secret-key-here

# Server Configuration
PORT=8080
DB_PATH=./wellbeing.db

2. Installation and Running

  1. Install dependencies:

    go mod download
    
  2. Run the application:

    go run main.go
    
  3. Access the application:

    • Open your browser and go to http://localhost:8080
    • Login with the default admin credentials (admin/admin) or create new users
    • The application will create the database automatically on first run

3. Docker Deployment

  1. Build the Docker image:

    docker build -t wellbeing-tracker .
    
  2. Run with environment variables:

    docker run -p 8080:8080 \
      -e JWT_SECRET=your-jwt-secret \
      -e PORT=8080 \
      -e DB_PATH=/app/wellbeing.db \
      wellbeing-tracker
    

Usage

For Users

  1. Navigate to the application URL
  2. Login with your credentials
  3. Click "Take Assessment" to submit your wellbeing indicators
  4. Add comments to provide context for your ratings

For Administrators

  1. Access the application with an admin account
  2. Use the "Reports" link to view wellbeing charts and export data
  3. Use the "Manage Users" link to manage user accounts
  4. Export data in CSV, Excel, or PDF formats with date range filtering

Security Features

  • JWT Authentication: Secure session management with JWT tokens
  • Password Hashing: Bcrypt-based password hashing for security
  • Role-based Access Control: Admin and user role separation
  • Environment Variables: Sensitive configuration stored in environment variables
  • HTTPS Ready: Configured for secure communication

Development

Project Structure

wellbeing/
├── internal/
│   ├── app/          # Application setup and routing
│   ├── database/     # Database models and operations
│   ├── handlers/     # HTTP request handlers
│   └── middleware/   # Authentication and authorization middleware
├── templates/        # HTML templates
├── main.go          # Application entry point
└── Dockerfile       # Docker configuration

Adding New Features

  1. Create handlers in internal/handlers/
  2. Add routes in internal/app/app.go
  3. Create templates in templates/
  4. Update database schema if needed in internal/database/

Troubleshooting

Common Issues

  1. "Access denied" error:

    • Ensure the user has the correct role (admin or user)
    • Check that the JWT secret is properly configured
  2. Database connection issues:

    • Verify the database path is correct and writable
    • Check that SQLite is properly installed
  3. Export functionality not working:

    • Ensure all required dependencies are installed
    • Check that the application has write permissions for temporary files

Logs

The application logs authentication attempts and errors. Check the console output for debugging information.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

This project is licensed under the MIT License.

Created: 25 April 2026 Last updated: 25 April 2026