Skip to content

Full-stack fitness tracking app with Spring Boot & React. Track nutrition, workouts, weight & goals with USDA & WGER API integration.

License

Notifications You must be signed in to change notification settings

davidgeamanu/Fitness-Tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fitness Tracker App

A full-stack fitness tracking application built with Spring Boot and React/TypeScript.

Java Spring Boot PostgreSQL TypeScript React

Track your nutrition, workouts, weight, and fitness goals with real-time data from USDA FoodData Central and WGER Exercise databases

FeaturesTech StackGetting StartedAPI Docs


Table of Contents


Features

Nutrition Tracking

  • Search 300,000+ foods from USDA FoodData Central
  • Log meals with precise gram measurements
  • Track daily calorie intake vs goals
  • View macro breakdown (protein, carbs, fats)
  • Create custom personal foods

Exercise Management

  • Access 800+ exercises from WGER database
  • Create custom personal exercises
  • Log workouts with sets, reps, weight, duration
  • Support for cardio & strength training
  • Track calories burned per exercise

Smart Scale Integration

  • Simulated smart scale for weight tracking
  • Automatic BMI calculation
  • Weight trend analysis (up/down/stable)
  • Historical weight data visualization

Activity Calendar

  • Monthly calendar view of all activities
  • Current streak & longest streak tracking
  • Visual indicators for goals
  • Day-by-day breakdown of meals & exercises

Dashboard & Analytics

  • Real-time daily overview
  • Weekly statistics with charts
  • Progress tracking towards goals
  • Summary statistics

User Management

  • JWT-based authentication
  • User profile management
  • Biometrics tracking
  • Customizable fitness goals

Screenshots

Dashboard

Dashboard

Nutrition Page

Nutrition

Log Food

Log Food

Exercise Page

Exercise

Log Exercise

Log Exercise

Activity Calendar

Calendar

Profile

Profile


Tech Stack

Backend

  • Java 17 - Programming language
  • Spring Boot 3.2 - Application framework
  • Spring Security - JWT authentication
  • Spring Data JPA - Database access
  • Spring WebFlux - Reactive HTTP client
  • PostgreSQL - Relational database
  • Lombok - Reduce boilerplate
  • Maven - Build & dependency management

Frontend

  • React 19 - UI library
  • TypeScript 5.9 - Type-safe JavaScript
  • React Router 7 - Client-side routing
  • Axios - HTTP client
  • Tailwind CSS 3 - Utility-first styling
  • Radix UI - Accessible components
  • Recharts - Data visualization
  • Framer Motion - Animations
  • date-fns - Date utilities

External APIs

  • USDA FoodData Central - Nutrition data for 300,000+ foods
  • WGER Workout Manager - Exercise database

Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

Tool Version Download
Java 17+ Download
Maven 3.8+ Download
PostgreSQL 14+ Download
Node.js 18+ Download

Installation

1. Clone the Repository

git clone https://github.com/yourusername/fitness-tracker-app.git
cd fitness-tracker-app

2. Set Up the Database

CREATE DATABASE fitness_tracker;

Note: Tables are automatically created on first run via Spring Boot's auto-DDL feature.


3. Configure Environment Variables

Windows (PowerShell)
$env:DB_NAME="fitness_tracker"
$env:DB_USER="postgres"
$env:DB_PASS="your_password"
$env:JWT_SECRET="your_64_character_secret_key"
$env:USDA_API_KEY="your_usda_api_key"
$env:WGER_API_KEY="your_wger_api_key"
Linux/Mac
export DB_NAME=fitness_tracker
export DB_USER=postgres
export DB_PASS=your_password
export JWT_SECRET=your_64_character_secret_key
export USDA_API_KEY=your_usda_api_key
export WGER_API_KEY=your_wger_api_key

4. Run the Backend

mvn spring-boot:run

Backend starts on http://localhost:8080


5. Run the Frontend

cd frontend
npm install
npm run dev

Frontend starts on http://localhost:5173


Environment Variables

Variable Description How to Obtain
DB_NAME PostgreSQL database name Your PostgreSQL setup
DB_USER PostgreSQL username Your PostgreSQL setup
DB_PASS PostgreSQL password Your PostgreSQL setup
JWT_SECRET JWT signing key (64+ chars) Generate: -join ((65..90) + (97..122) + (48..57) | Get-Random -Count 64 | % {[char]$_})
USDA_API_KEY USDA FoodData Central API key Sign up here
WGER_API_KEY WGER API key Get key here

API Documentation

Authentication Required: All endpoints require JWT authentication (except register/login). Include token in header: Authorization: Bearer <token>


Authentication

POST /api/users/register - Register new user

Request:

{
  "username": "john_doe",
  "email": "john@example.com",
  "password": "SecurePass123!",
  "firstname": "John",
  "lastname": "Doe"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "user": {
    "id": 1,
    "username": "john_doe",
    "email": "john@example.com",
    "firstName": "John",
    "lastName": "Doe"
  }
}
POST /api/users/login - Authenticate user

Request:

{
  "usernameOrEmail": "john_doe",
  "password": "SecurePass123!"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "user": {
    "id": 1,
    "username": "john_doe",
    "email": "john@example.com",
    "firstName": "John",
    "lastName": "Doe"
  }
}

Dashboard

Method Endpoint Description
GET /api/dashboard Today's dashboard (calories, exercise, weight)
GET /api/dashboard/daily Alias for above
GET /api/dashboard/date?date=2024-01-15 Dashboard for specific date
GET /api/dashboard/weekly Weekly calories and exercise data
GET /api/dashboard/summary Overall statistics

Food

Method Endpoint Description
GET /api/foods All accessible foods
GET /api/foods/personal User's custom foods
GET /api/foods/external External/seeded foods
GET /api/foods/search/usda?q=chicken&limit=20 Search USDA database
POST /api/foods Create custom food
DELETE /api/foods/{id} Delete custom food

Food Logs

Method Endpoint Description
GET /api/food-logs All user's food logs
GET /api/food-logs/today Today's food logs
GET /api/food-logs/date/{date} Logs for specific date
POST /api/food-logs Log a personal food
POST /api/food-logs/external Log an external (USDA) food
DELETE /api/food-logs/{id} Delete a food log
Example: Log Personal Food
{
  "foodId": 123,
  "quantityGrams": 150
}
Example: Log External Food
{
  "foodName": "Chicken Breast",
  "calories": 165,
  "protein": 31,
  "fats": 3.6,
  "carbs": 0,
  "quantityGrams": 200
}

Exercise

Method Endpoint Description
GET /api/exercises All accessible exercises
GET /api/exercises/personal User's custom exercises
GET /api/exercises/external External/seeded exercises
GET /api/exercises/search/wger?q=bench&limit=20 Search WGER database
POST /api/exercises Create custom exercise
DELETE /api/exercises/{id} Delete custom exercise

Exercise Logs

Method Endpoint Description
GET /api/exercise-logs All user's exercise logs
GET /api/exercise-logs/today Today's exercise logs
GET /api/exercise-logs/week This week's exercise logs
GET /api/exercise-logs/date/{date} Logs for specific date
POST /api/exercise-logs Log a personal exercise
POST /api/exercise-logs/external Log an external (WGER) exercise
DELETE /api/exercise-logs/{id} Delete an exercise log
Example: Log Personal Exercise
{
  "exerciseId": 45,
  "durationMinutes": 30,
  "sets": 3,
  "reps": 10,
  "weightUsed": 50
}
Example: Log External Exercise
{
  "exerciseName": "Bench Press",
  "category": "Chest",
  "exerciseType": "STRENGTH",
  "caloriesBurntPerMinute": 8.0,
  "durationMinutes": 20,
  "sets": 4,
  "reps": 8,
  "weightUsed": 60
}

Smart Scale

Method Endpoint Description
POST /api/smart-scale/simulate Simulate weighing (generates reading)
GET /api/smart-scale/readings All weight readings
GET /api/smart-scale/readings/latest Latest weight reading
GET /api/smart-scale/readings/weekly-trend Last 7 days of readings
GET /api/smart-scale/readings/recent?limit=10 Recent readings

Calendar

Method Endpoint Description
GET /api/calendar/month/{year}/{month} Monthly activity data
GET /api/calendar/day/{date} Single day details
GET /api/calendar/streaks Current and longest streaks

Goals

Method Endpoint Description
GET /api/goals Get user's goals
POST /api/goals Create or update goals
Example: Set Goals
{
  "targetWeightKg": 75.0,
  "dailyCalorieGoal": 2000,
  "weeklyExerciseGoalMinutes": 150
}

Biometrics

Method Endpoint Description
GET /api/biometrics/latest Latest biometrics
GET /api/biometrics/history Biometrics history
POST /api/biometrics Create or update biometrics
Example: Update Biometrics
{
  "heightCm": 175,
  "weightKg": 80,
  "gender": "MALE",
  "age": 28
}

User Profile

Method Endpoint Description
GET /api/users/me Get current user
PUT /api/users/me Update profile

Database Schema

Key Entities

Entity Description
users User accounts and credentials
user_biometrics Height, weight, age, gender
user_goals Calorie and exercise goals
food Food items (personal and external)
food_logs Daily food intake records
exercise Exercises (personal and external)
exercise_logs Workout session records
smart_scale_readings Weight measurements
daily_summaries Aggregated daily statistics

Auto-Generation

Tables are automatically created using:

spring.jpa.hibernate.ddl-auto=update

Production Note: For production deployments, consider switching to database migration tools like Flyway or Liquibase and setting spring.jpa.hibernate.ddl-auto=validate.


Project Structure

fitness-tracker-app/
├── backend/
│   └── src/main/java/com/davidgeamanu/fitnesstrackerapp/
│       ├── controller/        # REST API endpoints
│       ├── service/           # Business logic
│       │   └── impl/          # Service implementations
│       ├── model/             # JPA entities
│       ├── repository/        # Data access layer
│       ├── dto/               # Request/response objects
│       ├── mapper/            # Entity-DTO mappers
│       ├── security/          # JWT authentication
│       └── config/            # App configuration
├── frontend/
│   └── src/
│       ├── components/        # React components
│       │   ├── layout/        # Navbar, PageTransition
│       │   ├── ui/            # Reusable UI components
│       │   └── profile/       # Profile components
│       ├── pages/             # Page components
│       ├── services/          # API service layer
│       ├── hooks/             # Custom React hooks
│       ├── types/             # TypeScript types
│       └── lib/               # Utilities
├── pom.xml                    # Maven configuration
├── LICENSE                    # MIT License
└── README.md

License

This project is licensed under the MIT License - see the LICENSE file for details.


Author

David Geamanu


Acknowledgments

Special thanks to:


About

Full-stack fitness tracking app with Spring Boot & React. Track nutrition, workouts, weight & goals with USDA & WGER API integration.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages