Skip to content

blackbox24/Workout-Tracker-

Repository files navigation

https://roadmap.sh/projects/fitness-workout-tracker

WORKOUT TRACKER PROJECT

This project is a backend system for a workout tracker application where users get to login, signup, create workout plans and track their progress. This will include features like JWT authentication, CRUD operations for workouts and report generations on past workouts

REQUIREMENTS

  • Database Schema
  • API endpoints

Exercise data Schema

  • Name
  • Description
  • category (strength, cardio, flexibility)
  • muscle group ( legs, back, chest )

Authorization and Authentication

  • Sign Up: Create an account
  • login: Allow users to log into their accounts
  • JWT: use JWT for authentication

WORKOUT MANAGEMENT

  • Users create workout plans
  • Plans should consist of multiple exercises each with repetitions, sets and weights
  • Users delete and update with comments workout plans
  • Users schedule workouts for specific dates and times

PLAN

  • CREATE WORKOUT - Users create workout plans composed of multiple exercises
  • UPDATE WORKOUT - Users update works
  • COMMENT ON WORKOUTS
  • DELETE WORKOUT
  • SCHEDULE WORKOUT
  • LIST WORKOUTS
  • GENERATE REPORTS - Generate reports on past workouts and progress

CONSTRAINTS

  • USE RELATIONAL DB
  • USE RESTFUL API
  • IMPLEMENT JWT AUTHENTICATION TO SECURE ENDPOINTS
  • WRITE UNIT TESTS
  • DOCUMENTATION

DATABASE SCHEMA

CREATE TABLE IF NOT EXISTS users(
    id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    first_name VARCHAR(100) NOT NULL,
    middle_name VARCHAR(100) DEFAULT NULL,
    last_name VARCHAR(100) NOT NULL,
    password  VARCHAR(100) NOT NULL,
    role VARCHAR(20) CHECK (role IN ('admin','user')),
    username VARCHAR(50) UNIQUE,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS exercises(
    id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    description TEXT NOT NULL,
    
    category VARCHAR(100) CHECK (category IN ('Strength', 'Cardio', 'Flexibility', 'Plyometrics')),
    muscle_group VARCHAR(100) CHECK (muscle_group IN ('Chest', 'Back', 'Legs', 'Shoulders', 'Arms', 'Core', 'Full Body')),
    
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS workouts(
    id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    
    user_id BIGINT REFERENCES users(id),
    
    scheduled_date TIMESTAMP,
    completed_at TIMESTAMP,
    
    total_duration INT DEFAULT 0,
    
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS workout_sets(
    id BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
    
    user_id BIGINT REFERENCES users(id),
    
    workout_id BIGINT REFERENCES workouts(id),
    exercise_id BIGINT REFERENCES exercises(id)
    
    reps INT NOT NULL,
    
    weight_lifted NUMERIC(5,2) DEFAULT 0, -- Numeric allows for decimal weights (e.g., 22.5kg)
    rpe INT CHECK (rpe BETWEEN 0 AND 10), -- RPE is typically 1-10
    set_order INT DEFAULT 0,
    
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

BACKEND ENDPOINTS

  • POST "/api/auth/signup/"
  • POST "/api/auth/login/"

Headers Authorization: "Bearer token"

  • GET "/api/workouts/?limit=20&page=1" [ { "workout_id":1, "user_id":1, "scheduled_date":"12-01-2001", "completed_at":"12-12-2012", "total_duration":"12hours", "workout_sets":[ { "id":1, "exercise_id":1, "workout_id::1, "user_id": 1, "reps":1, "weight_lifted":1, "rpe": 1, "set_order": 1, }, ] }, ]

  • GET "/api/workouts/{id}"

  • PUT "/api/workouts/{id}"

  • DELETE "/api/workouts/{id}"

  • GET "/api/workouts/{id}/sets/"

  • POST "/api/workouts/{id}/sets/"

  • GET "/api/workouts/{id}/sets/{id}/"

  • PUT "/api/workouts/{id}/sets/{id}"

  • DELETE "/api/workouts/{id}/sets/{id}"

  • GET "/api/report" { "total_workouts": 1, "total_completed_workouts":1, "total_workout_sets":"20", }

PROJECT STRUCTURE

  • Models -> Database Schema
  • Data -> Backend Function logic
  • Service -> Implement backend logic
  • Routers -> Routes for each backend logic
  • config -> configuraiton of backend
  • test -> Unit tests and integrated test

About

This project is a backend system for a workout tracker application where users get to login, signup, create workout plans and track their progress. This will include features like JWT authentication, CRUD operations for workouts and report generations on past workouts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors