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
-
Install dependencies:
go mod download -
Run the application:
go run main.go -
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
- Open your browser and go to
3. Docker Deployment
-
Build the Docker image:
docker build -t wellbeing-tracker . -
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
- Navigate to the application URL
- Login with your credentials
- Click "Take Assessment" to submit your wellbeing indicators
- Add comments to provide context for your ratings
For Administrators
- Access the application with an admin account
- Use the "Reports" link to view wellbeing charts and export data
- Use the "Manage Users" link to manage user accounts
- 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
- Create handlers in
internal/handlers/ - Add routes in
internal/app/app.go - Create templates in
templates/ - Update database schema if needed in
internal/database/
Troubleshooting
Common Issues
-
"Access denied" error:
- Ensure the user has the correct role (admin or user)
- Check that the JWT secret is properly configured
-
Database connection issues:
- Verify the database path is correct and writable
- Check that SQLite is properly installed
-
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
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
This project is licensed under the MIT License.