Skip to content

gajendra-ingle/Fitness-Application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’ͺ FitnessAI

AI-Powered Fitness & Nutrition Tracker

A full-stack application that delivers personalised workout plans, tracks nutrition, monitors body progress, and uses Spring AI + GPT-4o to generate intelligent fitness coaching β€” all backed by a production-grade Spring Boot REST API and a modern React frontend.


Spring Boot Spring AI React Java MySQL JWT License


✨ Features

Module Description
πŸ” Authentication JWT-based register / login with BCrypt password hashing
πŸ‘€ User Profile Age, height, weight, gender, fitness goal & activity level
πŸ‹οΈ Workout Tracker Log sessions with type, duration, calories, and exercise details
πŸ₯— Nutrition Logger Track meals with full macro breakdown (protein / carbs / fats)
πŸ“ˆ Progress Tracker Log weight entries, auto-calculate BMI, view historical trends
πŸ€– AI Coach GPT-4o generates personalised 7-day workout plans and daily meal plans via Spring AI
πŸ“‹ Exercise Library Searchable and filterable exercise database seeded at startup
πŸ“– Swagger UI Full interactive API documentation at /swagger-ui.html

πŸ›  Tech Stack

Backend

Layer Technology
Framework Spring Boot 3.2 Β· Java 17
AI Integration Spring AI 1.0.0-M6 Β· OpenAI GPT-4o
Security Spring Security Β· JJWT 0.12.3 (JWT) Β· BCrypt
Persistence Spring Data JPA Β· Hibernate Β· MySQL 8
Validation Jakarta Bean Validation
Documentation SpringDoc OpenAPI 2.3 (Swagger UI)
Utilities Lombok Β· MapStruct
Build Maven 3.9

Frontend

Layer Technology
Framework React 18.2 (Create React App)
Styling CSS-in-JS with centralised design token system
Charts Pure SVG (no external chart library)
Fonts Syne (display) Β· DM Sans (body) via Google Fonts
State React useState / useReducer hooks

πŸš€ Getting Started

Prerequisites

Tool Version
Java 17+
Maven 3.9+
Node.js 18+
npm 9+
MySQL 8.0+
OpenAI API Key Get one here

1 Β· Clone the repository

git clone https://github.com/gajendra-ingle/Fitness-Application.git
cd fitnessai

2 Β· Database setup

CREATE DATABASE fitness_ai_db;

Hibernate's ddl-auto: update will create all tables automatically on first run. To seed the exercise library, run:

mysql -u root -p fitness_ai_db < backend/database/schema.sql

3 Β· Backend setup

cd backend

# 1. Copy and fill in the environment file
cp .env.example .env
#    β†’ Set DB_PASSWORD, SPRING_AI_OPENAI_API_KEY, JWT_SECRET

# 2. Build and run
mvn clean install -DskipTests
mvn spring-boot:run

API starts at http://localhost:8080 Swagger UI: http://localhost:8080/swagger-ui.html


4 Β· Frontend setup

cd frontend

# 1. Copy and fill in the environment file
cp .env.example .env
#    β†’ REACT_APP_API_BASE_URL is already set to http://localhost:8080/api

# 2. Install and start
npm install
npm start

Opens at http://localhost:3000


πŸ“ Project Structure

fitnessai/
β”œβ”€β”€ backend/                                        Spring Boot API
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   └── schema.sql                              DDL + seed data
β”‚   β”œβ”€β”€ .env.example                                Environment variable template
β”‚   └── src/main/
β”‚       β”œβ”€β”€ resources/
β”‚       β”‚   └── application.yml                     Config (reads from .env)
β”‚       └── java/com/fitnessai/
β”‚           β”œβ”€β”€ FitnessAiApplication.java
β”‚           β”œβ”€β”€ ai/
β”‚           β”‚   β”œβ”€β”€ AiFitnessRecommendationService.java   GPT-4o via Spring AI
β”‚           β”‚   β”œβ”€β”€ WorkoutPlanResponse.java
β”‚           β”‚   └── DietPlanResponse.java
β”‚           β”œβ”€β”€ config/
β”‚           β”‚   β”œβ”€β”€ ChatClientConfig.java            Spring AI ChatClient bean
β”‚           β”‚   └── OpenApiConfig.java               Swagger JWT config
β”‚           β”œβ”€β”€ controller/
β”‚           β”‚   β”œβ”€β”€ AuthController.java
β”‚           β”‚   β”œβ”€β”€ ProfileController.java
β”‚           β”‚   β”œβ”€β”€ WorkoutController.java
β”‚           β”‚   β”œβ”€β”€ NutritionController.java
β”‚           β”‚   β”œβ”€β”€ ProgressController.java
β”‚           β”‚   └── AiController.java
β”‚           β”œβ”€β”€ dto/
β”‚           β”‚   β”œβ”€β”€ request/                         RegisterRequest, LoginRequest,
β”‚           β”‚   β”‚                                    ProfileRequest, WorkoutRequest,
β”‚           β”‚   β”‚                                    NutritionLogRequest, ProgressRequest
β”‚           β”‚   └── response/                        AuthResponse, ProfileResponse,
β”‚           β”‚                                        WorkoutResponse, NutritionResponse,
β”‚           β”‚                                        ProgressResponse
β”‚           β”œβ”€β”€ entity/
β”‚           β”‚   β”œβ”€β”€ User.java
β”‚           β”‚   β”œβ”€β”€ UserProfile.java                 FitnessGoal, ActivityLevel, Gender enums
β”‚           β”‚   β”œβ”€β”€ Workout.java                     WorkoutType enum
β”‚           β”‚   β”œβ”€β”€ WorkoutExercise.java
β”‚           β”‚   β”œβ”€β”€ Exercise.java                    Difficulty enum
β”‚           β”‚   β”œβ”€β”€ NutritionLog.java                MealType enum
β”‚           β”‚   └── Progress.java
β”‚           β”œβ”€β”€ exception/
β”‚           β”‚   β”œβ”€β”€ ResourceNotFoundException.java
β”‚           β”‚   β”œβ”€β”€ BadRequestException.java
β”‚           β”‚   └── GlobalExceptionHandler.java
β”‚           β”œβ”€β”€ repository/
β”‚           β”‚   β”œβ”€β”€ UserRepository.java
β”‚           β”‚   β”œβ”€β”€ UserProfileRepository.java
β”‚           β”‚   β”œβ”€β”€ WorkoutRepository.java
β”‚           β”‚   β”œβ”€β”€ ExerciseRepository.java
β”‚           β”‚   β”œβ”€β”€ NutritionLogRepository.java
β”‚           β”‚   └── ProgressRepository.java
β”‚           β”œβ”€β”€ security/
β”‚           β”‚   β”œβ”€β”€ JwtUtils.java
β”‚           β”‚   β”œβ”€β”€ JwtAuthFilter.java
β”‚           β”‚   β”œβ”€β”€ UserDetailsServiceImpl.java
β”‚           β”‚   └── SecurityConfig.java
β”‚           └── service/
β”‚               β”œβ”€β”€ AuthService.java (+ impl)
β”‚               β”œβ”€β”€ ProfileService.java (+ impl)
β”‚               β”œβ”€β”€ WorkoutService.java (+ impl)
β”‚               β”œβ”€β”€ NutritionService.java (+ impl)
β”‚               └── ProgressService.java (+ impl)
β”‚
└── frontend/                                       React SPA
    β”œβ”€β”€ .env.example                                Environment variable template
    β”œβ”€β”€ public/
    β”‚   └── index.html
    └── src/
        β”œβ”€β”€ App.js                                  Root β€” router + layout
        β”œβ”€β”€ index.js
        β”œβ”€β”€ styles/
        β”‚   └── globals.css                         Reset, animations, scrollbar
        β”œβ”€β”€ constants/
        β”‚   β”œβ”€β”€ theme.js                            Design tokens (colors, fonts, radius…)
        β”‚   └── navigation.js                       Nav config & page metadata
        β”œβ”€β”€ utils/
        β”‚   └── formatters.js                       Pure helper functions (BMI, duration…)
        β”œβ”€β”€ hooks/
        β”‚   β”œβ”€β”€ useLocalStorage.js
        β”‚   └── useToggle.js
        β”œβ”€β”€ components/
        β”‚   β”œβ”€β”€ Sidebar/                            Collapsible nav + streak badge
        β”‚   β”œβ”€β”€ Topbar/                             Fixed header, search, notifications
        β”‚   β”œβ”€β”€ charts/
        β”‚   β”‚   β”œβ”€β”€ SparkLine/                      SVG sparkline
        β”‚   β”‚   β”œβ”€β”€ DonutChart/                     SVG donut
        β”‚   β”‚   β”œβ”€β”€ BarChart/                       SVG grouped bar chart
        β”‚   β”‚   └── MacroBar/                       Horizontal macro progress bar
        β”‚   └── ui/
        β”‚       β”œβ”€β”€ StatCard/                       KPI metric card
        β”‚       β”œβ”€β”€ Badge/                          Pill label
        β”‚       β”œβ”€β”€ Button/                         primary / secondary / ghost / danger
        β”‚       β”œβ”€β”€ FormField/                      input / select / textarea wrapper
        β”‚       β”œβ”€β”€ Modal/                          Accessible overlay (ESC + backdrop)
        β”‚       └── PageCard/                       Section card wrapper
        └── pages/
            β”œβ”€β”€ Dashboard/     (components/ + data/)
            β”œβ”€β”€ Workouts/      (components/ + data/)
            β”œβ”€β”€ Nutrition/     (components/ + data/)
            β”œβ”€β”€ Progress/      (components/ + data/)
            β”œβ”€β”€ AICoach/       (components/ + data/)
            └── Exercises/     (components/ + data/)

🌐 API Reference

All endpoints except /api/auth/** require the header:

Authorization: Bearer <your_jwt_token>

Auth

Method Endpoint Description
POST /api/auth/register Register a new user
POST /api/auth/login Login β†’ returns JWT token

Profile

Method Endpoint Description
GET /api/profile Get current user's profile
PUT /api/profile/update Update profile (goal, weight, height…)

Workouts

Method Endpoint Description
GET /api/workouts/user/{userId} Get all workouts for a user
GET /api/workouts/{id} Get a single workout
POST /api/workouts Log a new workout
PUT /api/workouts/{id} Update a workout
DELETE /api/workouts/{id} Delete a workout

Nutrition

Method Endpoint Description
POST /api/nutrition/log Log a food entry
GET /api/nutrition/history All nutrition entries
GET /api/nutrition/today Today's entries
DELETE /api/nutrition/{id} Delete a log entry

Progress

Method Endpoint Description
POST /api/progress/log Log weight / body metrics (BMI auto-calculated)
GET /api/progress/history All progress entries

AI Coach

Method Endpoint Description
GET /api/ai/my-workout-plan GPT-4o personalised 7-day workout plan
GET /api/ai/my-diet-plan GPT-4o personalised daily meal plan

πŸ“– Full interactive docs with request/response schemas at http://localhost:8080/swagger-ui.html

About

A full-stack fitness tracking application with AI-generated workout and diet plans.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors