2025-12-04 18:00:43 +00:00
# 🏋️ Fitness Tracker
2025-12-04 17:49:19 +00:00
2025-12-04 18:00:43 +00:00
A lightweight, self-hosted fitness tracking application designed for StrongLifts 5× 5 powerlifting programs. Built with Go and SQLite for simplicity, privacy, and performance.
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## ✨ Features
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
- **Workout Logging**: Track exercises with start and finish times
- **A/B Templates**: StrongLifts-style alternating workout plans
- **Automatic Rest Tracking**: Monitor recovery time between sets
- **Volume Analytics**: Daily, weekly, and monthly training volume statistics
- **Self-Hosted**: Complete data ownership with SQLite backend
- **Docker Support**: Containerized deployment with proper UID/GID handling
- **Persistent Storage**: External database mounting for easy backups
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 📋 Table of Contents
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
- [Quick Start ](#-quick-start )
- [Local Development ](#-local-development )
- [Docker Deployment ](#-docker-deployment )
- [Production Setup ](#-production-setup )
- [Backup Strategy ](#-backup-strategy )
- [Project Structure ](#-project-structure )
- [License ](#-license )
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 🚀 Quick Start
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Prerequisites
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
- Go 1.21+ (for local development)
- Docker & Docker Compose (for containerized deployment)
- Linux/macOS environment recommended
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Clone the Repository
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
git clone https://forgejo.rozic-dev.com/Dejan/Fitnes-tracker.git
cd Fitnes-tracker
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 💻 Local Development
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### 1. Install Go
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
**Ubuntu/Debian:**
```bash
2025-12-04 17:57:36 +00:00
sudo apt update
sudo apt install -y golang-go
go version
2025-12-04 18:00:43 +00:00
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### 2. Run the Application
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
2025-12-04 17:57:36 +00:00
DATABASE_URL=./fitness.db go run main.go
2025-12-04 18:00:43 +00:00
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
The application will be available at `http://localhost:8080`
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
The SQLite database will be created as `./fitness.db` in the project directory.
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 🐳 Docker Deployment
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### 1. Prepare the Environment
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
Create the data directory with proper permissions:
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
2025-12-04 17:57:36 +00:00
mkdir -p fitness-data
sudo chown -R 1000:1000 fitness-data
sudo chmod 775 fitness-data
2025-12-04 18:00:43 +00:00
```
### 2. Build and Start
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
# Build the Docker image
2025-12-04 17:57:36 +00:00
docker compose build
2025-12-04 18:00:43 +00:00
# Start the application
2025-12-04 17:57:36 +00:00
docker compose up -d
2025-12-04 18:00:43 +00:00
# View logs
2025-12-04 17:57:36 +00:00
docker compose logs -f
2025-12-04 18:00:43 +00:00
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### 3. Verify Installation
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
The application should now be running at `http://localhost:8080`
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
Check the logs for confirmation:
```
2025-12-04 17:57:36 +00:00
Using database file: /data/fitness.db
Listening on :8080 ...
2025-12-04 18:00:43 +00:00
```
### 4. Managing the Container
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
# Stop the application
docker compose down
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
# Restart the application
docker compose restart
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
# Rebuild after code changes
docker compose build
docker compose up -d
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 🔧 Docker Configuration
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
The `docker-compose.yml` configuration:
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```yaml
2025-12-04 17:57:36 +00:00
services:
fitness:
build: .
container_name: fitness-tracker
restart: unless-stopped
environment:
- DATABASE_URL=/data/fitness.db
volumes:
- ./fitness-data:/data
ports:
- "8080:8080"
2025-12-04 18:00:43 +00:00
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
**Key Features:**
- **Volume Mount**: `./fitness-data` → `/data` (persistent storage on host)
- **Database Location**: `fitness-data/fitness.db`
- **Auto-restart**: Container restarts automatically unless manually stopped
- **Non-root User**: Runs as UID 1000 for security
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Verify Container User
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
docker exec -it fitness-tracker id
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
Expected output:
```
uid=1000(appuser) gid=1000(appuser)
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 🌐 Production Setup
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Reverse Proxy with Traefik
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
Add these labels to your `docker-compose.yml` :
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```yaml
services:
fitness:
# ... existing configuration ...
labels:
- "traefik.enable=true"
- "traefik.http.routers.fitness.rule=Host(`fitness.yourdomain.com`)"
- "traefik.http.routers.fitness.entrypoints=websecure"
- "traefik.http.routers.fitness.tls.certresolver=letsencrypt"
- "traefik.http.services.fitness.loadbalancer.server.port=8080"
networks:
- traefik_default
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
networks:
traefik_default:
external: true
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 💾 Backup Strategy
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Manual Backup
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
# Copy data directory
cp -r fitness-data fitness-data-backup-$(date +%Y%m%d)
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
# Create compressed archive
tar -czvf fitness-backup-$(date +%Y%m%d).tar.gz fitness-data/
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Automated Backup Script
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
Create a cron job to back up daily:
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
# Edit crontab
crontab -e
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
# Add daily backup at 2 AM
0 2 * * * tar -czvf ~/backups/fitness-$(date +\%Y\%m\%d).tar.gz ~/Fitnes-tracker/fitness-data/
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 📁 Project Structure
```
Fitnes-tracker/
├── main.go # Application entry point
├── go.mod # Go module dependencies
├── go.sum # Dependency checksums
├── Dockerfile # Container build instructions
├── docker-compose.yml # Docker Compose configuration
├── readme.md # This file
├── .gitignore # Git ignore rules
└── fitness-data/ # Persistent data directory (not in git)
└── fitness.db # SQLite database
```
## 🛠️ Troubleshooting
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Permission Issues
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
If you encounter database permission errors:
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
sudo chown -R 1000:1000 fitness-data
sudo chmod 775 fitness-data
docker compose restart
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Port Already in Use
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
Change the port mapping in `docker-compose.yml` :
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```yaml
ports:
- "8081:8080" # Use port 8081 instead
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Database Locked
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
Ensure only one instance is running:
```bash
docker compose down
# Wait a few seconds
docker compose up -d
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 🤝 Contributing
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
1. Fork the repository
2. Create a feature branch: `git checkout -b feature-name`
3. Commit your changes: `git commit -m 'Add feature'`
4. Push to the branch: `git push origin feature-name`
5. Open a pull request
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
### Git Configuration
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
```bash
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
```
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 📝 License
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
This project is private and proprietary.
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
## 🔗 Links
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
- Repository: [https://forgejo.rozic-dev.com/Dejan/Fitnes-tracker ](https://forgejo.rozic-dev.com/Dejan/Fitnes-tracker )
- Issues: [Report a bug ](https://forgejo.rozic-dev.com/Dejan/Fitnes-tracker/issues )
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
---
2025-12-04 17:57:36 +00:00
2025-12-04 18:00:43 +00:00
**Built with ❤️ for the StrongLifts community**