Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hukshh/FitFusionP

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

50 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ‹οΈ FitFusion - Gym-Fitness Tracking & E-commerce Platform

A full-stack fitness tracking and e-commerce application built with the MERN stack (MongoDB replaced with PostgreSQL/Supabase).
FitFusion connects fitness enthusiasts with workout tracking tools, progress monitoring, and a marketplace for fitness products.


🧩 Project Overview

FitFusion is a comprehensive fitness platform that combines:

  • Workout Tracking: Log exercises, sets, reps, and track progress over time
  • Gamification: XP points and streak system to keep users motivated
  • E-commerce: Browse and purchase fitness products (supplements, equipment, apparel)
  • Progress Analytics: Track body metrics (weight, body fat percentage)
  • Gym Attendance: Check-in/check-out system with duration tracking

The platform uses JWT-based authentication with Google OAuth integration and Supabase (PostgreSQL) for cloud database storage.


πŸš€ Key Features / Modules

πŸ” User Authentication & Authorization

  • JWT-based authentication with secure password hashing (bcrypt)
  • Google OAuth 2.0 integration for seamless login
  • Protected routes with middleware
  • Session management with token expiration

πŸ’ͺ Fitness Tracking System

  • Custom Exercise Library: Create and manage personal exercises
  • Workout Logging: Track sets, reps, weight, and RPE (Rate of Perceived Exertion)
  • Progress Tracking: Monitor weight and body fat percentage over time
  • Workout History: View past workouts with detailed set information
  • Gamification: Earn XP points and maintain workout streaks

πŸ“… Gym Attendance Management

  • Check-in/Check-out system
  • Automatic duration calculation
  • Attendance history tracking
  • Real-time status updates

πŸ›’ E-commerce Platform

  • Product catalog with categories (Supplements, Equipment, Apparel)
  • Shopping cart management
  • Order processing and history
  • Inventory tracking
  • Product search and filtering

πŸ“Š Analytics & Insights

  • Progress visualization
  • Workout frequency tracking
  • Body metrics trends
  • Purchase history

πŸ‘₯ User Roles

Role Description Permissions
User (Fitness Enthusiast) Tracks workouts, monitors progress, shops for products Create account, log workouts, track progress, purchase products, manage cart
Admin (Future) Manages platform, products, and users Manage products, categories, view analytics, moderate content

πŸ–₯️ Page / Screen List (Frontend)

πŸ” Authentication

  • Login / Register Page (Email/Password)
  • Google OAuth Login/Signup
  • Password Reset Page (Future)
  • Session Management & JWT Tokens

πŸ‘€ User Section

  • Dashboard: Overview of recent workouts, streak, XP, and recommendations
  • Workout Logger: Create and log new workouts
  • Exercise Library: Browse and create custom exercises
  • Progress Tracker: View body metrics over time
  • Attendance History: Check-in/check-out records
  • Profile Page: Edit user information and preferences

πŸ›’ E-commerce Section

  • Product Catalog: Browse all products with filters
  • Product Details: Detailed product information
  • Shopping Cart: Manage cart items
  • Checkout: Place orders with shipping details
  • Order History: View past purchases

πŸ“± General

  • Home Page: Landing page with features overview
  • About / Contact Page
  • Navigation: Responsive navbar with user menu


πŸ“Š Entity Relationship Diagram

erDiagram
    User ||--o{ Workout : creates
    User ||--o{ Exercise : creates
    User ||--o{ Attendance : has
    User ||--o{ ProgressLog : tracks
    User ||--o{ CartItem : has
    User ||--o{ Order : places
    
    Workout ||--o{ WorkoutSet : contains
    Exercise ||--o{ WorkoutSet : "used in"
    
    Category ||--o{ Product : contains
    Product ||--o{ CartItem : "added to"
    Product ||--o{ OrderItem : "ordered as"
    
    Order ||--o{ OrderItem : contains
    
    User {
        int user_id PK
        string user_name
        string user_email UK
        string user_password
        int xp
        int streak
    }
    
    Exercise {
        int id PK
        string name
        string muscleGroup
        int userId FK
    }
    
    Workout {
        int id PK
        int userId FK
        string title
        datetime date
    }
    
    Product {
        int id PK
        string name
        float price
        int stock
        int categoryId FK
    }
Loading

🧰 Tech Stack

Frontend

  • React 19.1.1 - UI library
  • React Router - Client-side routing
  • Vite - Build tool and dev server
  • TailwindCSS - Utility-first CSS framework
  • Google OAuth (@react-oauth/google) - OAuth integration

Backend

  • Node.js with Express 5.1.0 - Server framework
  • Prisma ORM 6.18.0 - Database ORM
  • Supabase - PostgreSQL cloud database
  • JWT (jsonwebtoken) - Authentication tokens
  • bcrypt - Password hashing
  • Zod - Schema validation

Database

  • PostgreSQL (via Supabase)
  • Prisma for migrations and queries

Authentication

  • JWT-based authentication
  • Google OAuth 2.0
  • bcrypt password hashing

πŸš€ Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/Dhruv-2403/FitFusion.git
    cd FitFusion
  2. Backend Setup

    cd backend
    npm install
  3. Configure Environment

    Copy .env.supabase to .env and add your Supabase credentials:

    DATABASE_URL="postgresql://..."  # Transaction pooler (port 6543)
    DIRECT_URL="postgresql://..."     # Direct connection (port 5432)
    JWT_SECRET_KEY="your-secret-key"
    GOOGLE_CLIENT_ID="your-google-client-id"  # Optional
  4. Initialize Database

    npx prisma db push
    npx prisma db seed

    This creates all tables and populates them with sample data!

  5. Start Backend

    npm run dev

    Server runs on http://localhost:3000

  6. Frontend Setup

    cd ../frontend
    npm install
    npm run dev

    Frontend runs on http://localhost:5173


πŸ”„ Workflow (Simplified)

[User] β†’ registers β†’ logs workouts β†’ tracks progress β†’ earns XP & streaks
       ↳ browses products β†’ adds to cart β†’ places order
       ↳ checks in to gym β†’ works out β†’ checks out

[System] β†’ calculates workout duration β†’ updates streak β†’ awards XP
         ↳ processes orders β†’ updates inventory β†’ sends confirmations

πŸ§ͺ Testing the APIs

Option 1: Use Seeded Data

After running npx prisma db seed, you can login with:

Email: [email protected]
Password: password123

Option 2: Postman/Thunder Client

Import and test all endpoints. See API_TESTING_GUIDE.md for detailed documentation.

Option 3: Prisma Studio

Visual database browser:

cd backend
npx prisma studio

Opens at http://localhost:5555


πŸ“‘ API Endpoints

Authentication

  • POST /api/users/signup - Register new user
  • POST /api/users/login - Login and get JWT token
  • GET /api/users/profile - Get user profile (protected)
  • POST /api/auth/google - Google OAuth login

Fitness Tracking

  • POST /api/exercises - Create custom exercise (protected)
  • GET /api/exercises - Get user exercises (protected)
  • POST /api/workouts - Log workout with sets (protected)
  • GET /api/workouts - Get workout history (protected)
  • POST /api/attendance/checkin - Check in to gym (protected)
  • POST /api/attendance/checkout - Check out from gym (protected)
  • GET /api/attendance - Get attendance history (protected)

E-commerce

  • GET /api/products - Get all products
  • GET /api/products/:id - Get product details
  • POST /api/cart - Add to cart (protected)
  • GET /api/cart - Get cart items (protected)
  • PUT /api/cart/:id - Update cart item (protected)
  • DELETE /api/cart/:id - Remove from cart (protected)
  • POST /api/orders - Create order (protected)
  • GET /api/orders - Get order history (protected)

Full API documentation: API_TESTING_GUIDE.md


πŸ“ Project Structure

FitFusion/
β”œβ”€β”€ frontend/              # React + Vite
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ pages/         # Page components
β”‚   β”‚   β”œβ”€β”€ context/       # React Context for state
β”‚   β”‚   └── App.jsx        # Main app component
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”‚
β”œβ”€β”€ backend/               # Express + Prisma
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ controllers/   # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ userController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ exerciseController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ workoutController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ attendanceController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ productController.js
β”‚   β”‚   β”‚   β”œβ”€β”€ cartController.js
β”‚   β”‚   β”‚   └── orderController.js
β”‚   β”‚   β”œβ”€β”€ routes/        # API routes
β”‚   β”‚   β”œβ”€β”€ middleware/    # Auth middleware
β”‚   β”‚   β”œβ”€β”€ validation/    # Zod schemas
β”‚   β”‚   └── index.js       # Server entry
β”‚   β”œβ”€β”€ prisma/
β”‚   β”‚   └── seed.js        # Sample data
β”‚   β”œβ”€β”€ schema.prisma      # Database schema
β”‚   └── package.json
β”‚
β”œβ”€β”€ API_TESTING_GUIDE.md   # Detailed API docs
└── README.md              # This file

🎯 Expected Outcomes

  • βœ… A fully functional MERN-based Fitness & E-commerce Platform
  • βœ… Multi-module application (Fitness + Shopping)
  • βœ… Live demo showcasing full-stack CRUD operations
  • βœ… Gamification system with XP and streaks
  • βœ… Responsive design with TailwindCSS
  • βœ… Secure authentication (JWT + OAuth)
  • βœ… Cloud database with Supabase
  • βœ… Real-world workflow demonstration
  • βœ… Portfolio-grade project for full-stack developer roles

πŸ”§ Environment Variables

# Supabase Database
DATABASE_URL="postgresql://..."      # Pooler connection
DIRECT_URL="postgresql://..."        # Direct connection

# Authentication
JWT_SECRET_KEY="your-secret-key"
JWT_EXPIRES_IN="7d"

# Google OAuth (optional)
GOOGLE_CLIENT_ID="your-google-client-id"

πŸ“Š Sample Data

The seed file (backend/prisma/seed.js) consists of sample data.

For any sample testing , take data from there and test it locally (Postman/ThunderClient) for API Testing.

Run npx prisma db seed anytime to reset with fresh sample data!


🌟 Future Enhancements

  • Social Features: Follow friends, share workouts
  • AI Workout Recommendations: Personalized workout plans based on history
  • Nutrition Tracking: Calorie and macro tracking
  • Workout Templates: Pre-built workout programs
  • Progress Photos: Upload and track transformation photos
  • Leaderboards: Compete with other users
  • Mobile App: React Native version
  • Wearable Integration: Sync with Fitbit, Apple Watch
  • Video Tutorials: Exercise demonstration videos
  • Community Forum: Discussion boards for fitness topics
  • Premium Subscription: Advanced features and analytics
  • Admin Dashboard: Manage users, products, and analytics
  • Real-time Notifications: Push notifications for achievements
  • Payment Gateway: Stripe/PayPal integration for e-commerce

πŸ“Š View Your Data

Supabase Dashboard

  1. Go to supabase.com
  2. Open your project
  3. Click Table Editor
  4. Browse all tables

Prisma Studio (Local)

npx prisma studio

Opens at http://localhost:5555


🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“š Additional Documentation

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 97.5%
  • CSS 2.2%
  • HTML 0.3%