Track your nutrition, workouts, weight, and fitness goals with real-time data from USDA FoodData Central and WGER Exercise databases
- Features
- Screenshots
- Tech Stack
- Getting Started
- API Documentation
- Database Schema
- Project Structure
- License
- Acknowledgments
|
|
|
|
|
|
|
|
- USDA FoodData Central - Nutrition data for 300,000+ foods
- WGER Workout Manager - Exercise database
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 |
git clone https://github.com/yourusername/fitness-tracker-app.git
cd fitness-tracker-appCREATE DATABASE fitness_tracker;Note: Tables are automatically created on first run via Spring Boot's auto-DDL feature.
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_keymvn spring-boot:runBackend starts on http://localhost:8080
cd frontend
npm install
npm run devFrontend starts on http://localhost:5173
| 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 |
Authentication Required: All endpoints require JWT authentication (except register/login). Include token in header:
Authorization: Bearer <token>
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"
}
}| 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 |
| 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 |
| 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
}| 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 |
| 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
}| 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 |
| 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 |
| 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
}| 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
}| Method | Endpoint | Description |
|---|---|---|
GET |
/api/users/me |
Get current user |
PUT |
/api/users/me |
Update profile |
| 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 |
Tables are automatically created using:
spring.jpa.hibernate.ddl-auto=updateProduction Note: For production deployments, consider switching to database migration tools like Flyway or Liquibase and setting
spring.jpa.hibernate.ddl-auto=validate.
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
This project is licensed under the MIT License - see the LICENSE file for details.
David Geamanu
Special thanks to:
- USDA FoodData Central - Comprehensive nutrition database
- WGER Workout Manager - Open-source exercise database
- Spring Boot - Java framework
- React - Powerful UI library
- Tailwind CSS - Utility-first CSS framework
- Radix UI - Accessible component primitives