Files
training-tracker/plans/001-initial-implementation-plan.md
2026-01-19 19:49:47 +01:00

5.7 KiB

Training Tracker - Implementation Plan

Project Overview

A mobile-friendly web application for tracking training activities with a Golang backend and SQL/NoSQL database.


Phase 1: Project Foundation

1.1 Project Structure

training-tracker/
├── backend/
│   ├── cmd/
│   │   └── server/
│   │       └── main.go
│   ├── internal/
│   │   ├── api/           # HTTP handlers
│   │   ├── models/        # Data structures
│   │   ├── storage/       # Database layer
│   │   └── service/       # Business logic
│   ├── go.mod
│   └── go.sum
├── frontend/
│   ├── index.html
│   ├── css/
│   │   └── styles.css
│   ├── js/
│   │   ├── app.js
│   │   ├── api.js
│   │   └── components/
│   └── assets/
├── docker-compose.yml
└── readme.md

1.2 Database Schema Design

Core entities:

  • users - User accounts (id, username, email, password_hash, created_at)
  • exercises - Exercise definitions (id, name, type, muscle_group, description)
  • training_plans - Training plan templates (id, user_id, name, description)
  • plan_exercises - Exercises in a plan (id, plan_id, exercise_id, sets, reps, duration, order)
  • sessions - Completed training sessions (id, user_id, plan_id, date, notes)
  • session_entries - Individual exercise entries (id, session_id, exercise_id, weight, reps, duration, sets_completed)

Choice: PostgreSQL (can use Docker for local development)


Phase 2: Backend Development (Golang)

2.1 Initial Setup

  • Initialize Go module
  • Set up HTTP router (standard library net/http or chi/gorilla/mux)
  • Configure environment variables
  • Set up database connection

2.2 API Endpoints

# Auth endpoints (deferred to v2)
# POST   /api/auth/register
# POST   /api/auth/login

Exercises:
  GET    /api/exercises          # List all exercises
  POST   /api/exercises          # Create exercise
  GET    /api/exercises/:id      # Get exercise
  PUT    /api/exercises/:id      # Update exercise
  DELETE /api/exercises/:id      # Delete exercise

Training Plans:
  GET    /api/plans              # List user's plans
  POST   /api/plans              # Create plan
  GET    /api/plans/:id          # Get plan with exercises
  PUT    /api/plans/:id          # Update plan
  DELETE /api/plans/:id          # Delete plan

Sessions:
  GET    /api/sessions           # List sessions (with filters)
  POST   /api/sessions           # Create/start session
  GET    /api/sessions/:id       # Get session details
  PUT    /api/sessions/:id       # Update session
  DELETE /api/sessions/:id       # Delete session
  POST   /api/sessions/:id/entries  # Add entry to session

2.3 Core Backend Tasks

  1. Set up Go project structure and dependencies
  2. Set up PostgreSQL via Docker
  3. Implement database migrations
  4. Create data models and repository layer
  5. Implement REST API handlers
  6. Add input validation and error handling
  7. Implement CORS for frontend communication
  8. (v2) Add authentication

Phase 3: Frontend Development (HTML/CSS/JS)

3.1 Mobile-First Design

  • Responsive CSS with mobile breakpoints
  • Touch-friendly UI elements
  • Offline-capable design (future PWA)

3.2 Core Views/Pages

  1. Dashboard - Overview of recent sessions, quick actions
  2. Training Plan View - Display exercises for current session
  3. Session Logger - Form to enter weights/reps/duration during workout
    • Strength: weight, sets, reps
    • Cardio: duration, distance, heart rate (optional)
  4. History - View past sessions and progress
  5. Exercise Library - Browse and manage exercises
  6. (v2) Login/Register - Authentication screens

3.3 Frontend Tasks

  1. Create base HTML structure and navigation
  2. Implement responsive CSS (flexbox/grid)
  3. Build API client module (fetch wrapper)
  4. Create reusable UI components
  5. Implement session logging interface
  6. Add form validation
  7. Implement local storage for offline data entry

Phase 4: Integration & Testing

4.1 Integration

  • Connect frontend to backend API
  • Test all CRUD operations
  • Handle loading states and errors
  • Implement authentication flow

4.2 Testing

  • Backend: Unit tests for handlers and services
  • Frontend: Manual testing on mobile devices
  • API: Integration tests

Phase 5: Deployment (Optional for v1)

  • Docker containerization
  • Docker Compose for local development
  • Basic deployment documentation

Future Enhancements (v2+)

  • Strava integration
  • Whoop integration
  • Progress charts and analytics
  • Workout timer
  • PWA with offline support
  • Export data (CSV/PDF)

  1. Backend foundation - Go project setup, PostgreSQL via Docker, basic models
  2. Core API - Exercises and sessions endpoints (strength + cardio support)
  3. Frontend skeleton - HTML structure, CSS, navigation
  4. Session logging - The core feature (enter workout data)
  5. Training plans - Plan viewing and management
  6. Polish - Error handling, validation, UX improvements
  7. (v2) Authentication - User accounts

Decisions Made

  • Database: PostgreSQL (via Docker for local dev)
  • Authentication: None initially (single-user mode), add in v2
  • Exercise types: Both strength (weight/sets/reps) and cardio (duration/distance/HR)

Verification

After implementation, verify by:

  1. Start PostgreSQL container and backend server
  2. Open frontend in browser (mobile viewport)
  3. Create a test exercise (e.g., "Bench Press" - strength type)
  4. Create a training plan with exercises
  5. Log a session with actual data entry
  6. View session history