Skip to content

Shreyaaaaaak/workout-tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💪 Workout Tracker API

Project URL: https://roadmap.sh/projects/fitness-tracker

A production-ready RESTful API for tracking workouts, exercises, and fitness progress — built with FastAPI, MySQL, and JWT authentication.

🔗 Live API: https://workout-tracker-h6zn.onrender.com
📖 Swagger Docs: https://workout-tracker-h6zn.onrender.com/docs
📘 ReDoc: https://workout-tracker-h6zn.onrender.com/redoc


🛠️ Tech Stack

Layer Technology
Framework FastAPI (Python)
Database MySQL (Aiven Cloud)
ORM SQLAlchemy
Auth JWT (python-jose)
Password Hashing bcrypt (passlib)
Deployment Render
Testing pytest + httpx
Docs OpenAPI / Swagger

✨ Features

  • 🔐 JWT Authentication — signup, login, protected routes
  • 🏋️ Workout Management — create, read, update, delete workouts
  • 📅 Scheduling — schedule workouts for specific dates and times
  • 📊 Progress Reports — weekly summaries, volume tracking, exercise progress
  • 🌱 Exercise Library — 33 seeded exercises across strength, cardio, and flexibility
  • Unit Tests — 17 tests covering auth, workouts, and reports
  • 📖 Auto Docs — Swagger UI and ReDoc out of the box

📁 Project Structure

workout-tracker/

├── app/

│ ├── main.py # FastAPI app entry point

│ ├── database.py # DB connection & session

│ ├── models/ # SQLAlchemy models

│ ├── schemas/ # Pydantic schemas

│ ├── routers/ # API route handlers

│ │ ├── init.py # Auth routes

│ │ ├── workouts.py # Workout CRUD routes

│ │ └── reports.py # Report routes

│ ├── auth/ # JWT & password utils

│ └── utils/

├── tests/

│ ├── test_auth.py

│ └── test_workouts.py

├── seeder.py # Exercise data seeder

├── requirements.txt

├── render.yaml

└── .env # (not committed)


🗄️ Database Schema

users

├── id, username, email, hashed_password, created_at exercises

├── id, name, description, category, muscle_group workouts

├── id, user_id (FK), title, notes, scheduled_at, completed_at, created_at workout_exercises

├── id, workout_id (FK), exercise_id (FK), sets, reps, weight_kg


🚀 API Endpoints

Auth

Method Endpoint Description
POST /auth/signup Create a new account
POST /auth/login Login and get JWT token
GET /auth/me Get current user profile

Workouts

Method Endpoint Description
POST /workouts/ Create a new workout
GET /workouts/ List all your workouts
GET /workouts/{id} Get a single workout
PUT /workouts/{id} Update a workout
DELETE /workouts/{id} Delete a workout
GET /workouts/status/pending List pending workouts

Reports

Method Endpoint Description
GET /reports/summary Overall workout stats
GET /reports/weekly Last 7 days activity
GET /reports/exercises/most-used Top 5 exercises
GET /reports/progress/{exercise_id} Weight progress for an exercise

⚙️ Local Setup

1. Clone the repo:

git clone https://github.com/Shreyaaaaaak/workout-tracker.git
cd workout-tracker

2. Create virtual environment:

python -m venv venv
venv\Scripts\activate  # Windows

3. Install dependencies:

pip install -r requirements.txt

4. Create .env file:

DATABASE_URL=mysql+pymysql://user:password@host:port/dbname
SECRET_KEY=your-secret-key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=1440
SSL_CA=ca.pem

5. Run seeder:

python seeder.py

6. Start server:

uvicorn app.main:app --reload

Visit http://127.0.0.1:8000/docs 🚀


🧪 Running Tests

pytest tests/ -v

Expected: 17 tests passing


📝 Example Usage

Signup:

curl -X POST https://workout-tracker-h6zn.onrender.com/auth/signup \
  -H "Content-Type: application/json" \
  -d '{"username": "shreya", "email": "shreya@example.com", "password": "Test1234!"}'

Login:

curl -X POST https://workout-tracker-h6zn.onrender.com/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email": "shreya@example.com", "password": "Test1234!"}'

Create Workout:

curl -X POST https://workout-tracker-h6zn.onrender.com/workouts/ \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Morning Push Day",
    "scheduled_at": "2026-07-01T07:00:00",
    "exercises": [
      {"exercise_id": 1, "sets": 4, "reps": 10, "weight_kg": 60}
    ]
  }'

👩‍💻 Author

ShreyaGitHub


📄 License

MIT License

About

Production-ready workout tracker REST API built with FastAPI, MySQL & JWT auth — deployed on Render

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages