5.7 KiB
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/httporchi/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
- Set up Go project structure and dependencies
- Set up PostgreSQL via Docker
- Implement database migrations
- Create data models and repository layer
- Implement REST API handlers
- Add input validation and error handling
- Implement CORS for frontend communication
- (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
- Dashboard - Overview of recent sessions, quick actions
- Training Plan View - Display exercises for current session
- Session Logger - Form to enter weights/reps/duration during workout
- Strength: weight, sets, reps
- Cardio: duration, distance, heart rate (optional)
- History - View past sessions and progress
- Exercise Library - Browse and manage exercises
- (v2) Login/Register - Authentication screens
3.3 Frontend Tasks
- Create base HTML structure and navigation
- Implement responsive CSS (flexbox/grid)
- Build API client module (fetch wrapper)
- Create reusable UI components
- Implement session logging interface
- Add form validation
- 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)
Recommended Implementation Order
- Backend foundation - Go project setup, PostgreSQL via Docker, basic models
- Core API - Exercises and sessions endpoints (strength + cardio support)
- Frontend skeleton - HTML structure, CSS, navigation
- Session logging - The core feature (enter workout data)
- Training plans - Plan viewing and management
- Polish - Error handling, validation, UX improvements
- (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:
- Start PostgreSQL container and backend server
- Open frontend in browser (mobile viewport)
- Create a test exercise (e.g., "Bench Press" - strength type)
- Create a training plan with exercises
- Log a session with actual data entry
- View session history