Skip to content

yugal07/FitTrack-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

212 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

FitTrack - Comprehensive Fitness Tracking Application

Node.js React MongoDB

A modern, full-stack fitness tracking application built with the MERN stack (MongoDB, Express.js, React, Node.js) that helps users monitor their workouts, nutrition, and overall fitness progress in one centralized platform.

๐ŸŒŸ Features

๐Ÿ‹๏ธ Workout Management

  • Exercise Library: Comprehensive database of exercises with detailed instructions and muscle group targeting
  • Workout Creation: Create custom workout routines or choose from pre-built templates
  • Workout Logging: Track completed workouts with sets, reps, weights, and duration
  • Progress Tracking: Monitor workout frequency, intensity, and improvements over time
  • Smart Recommendations: workout suggestions based on fitness level and preferences

๐Ÿฅ— Nutrition Tracking

  • Meal Logging: Track daily meals with detailed nutritional information
  • Calorie Counting: Monitor daily caloric intake and macronutrient distribution
  • Water Intake: Keep track of daily hydration levels
  • Nutrition Statistics: Comprehensive reports on eating habits and nutritional goals
  • Food Database: Extensive nutrition database with common foods and custom entries

๐ŸŽฏ Goal Setting & Achievement

  • SMART Goals: Set specific, measurable fitness and nutrition goals
  • Progress Monitoring: Real-time tracking of goal completion
  • Achievement Notifications: Automated alerts when goals are reached
  • Goal Analytics: Detailed insights into goal performance and trends

๐Ÿ“Š Progress Visualization

  • Interactive Charts: Visual representation of fitness progress over time
  • Progress Photos: Before/after photo comparisons with timeline view
  • Body Measurements: Track weight, body fat percentage, and body measurements
  • Performance Analytics: Detailed statistics on workout performance and nutrition

๐Ÿ”” Smart Notifications

  • Workout Reminders: Automated daily workout notifications
  • Nutrition Alerts: Reminders to log meals and stay hydrated
  • Goal Milestones: Celebrations when fitness goals are achieved
  • System Announcements: Important updates and tips from administrators

๐Ÿ” Authentication & Security

  • Secure Registration: Multi-step user registration with email verification
  • JWT Authentication: Token-based authentication with refresh tokens
  • Password Reset: Secure password reset via email with time-limited tokens
  • Email Notifications: Professional HTML email templates for password reset and confirmations
  • Account Security: Password strength validation and secure password hashing

๐Ÿ‘ค User Management

  • Profile Customization: Personalized user profiles with preferences
  • Dark/Light Mode: Theme switching for optimal user experience
  • Measurement Units: Support for both metric and imperial units
  • Privacy Controls: Granular notification and privacy settings
  • Password Management: Change password functionality with current password verification

๐Ÿ›ก๏ธ Admin Dashboard

  • User Management: Monitor and manage user accounts
  • Content Management: Add/edit exercises, workouts, and nutrition items
  • Analytics Dashboard: Platform-wide statistics and user engagement metrics
  • System Announcements: Send targeted notifications to user groups

๐Ÿš€ Tech Stack

Frontend

  • React 19.1.0: Modern UI library with hooks and context
  • Tailwind CSS: Utility-first CSS framework for responsive design
  • React Router: Client-side routing and navigation
  • React Hook Form: Performant forms with easy validation
  • Chart.js: Interactive data visualization
  • Axios: HTTP client for API requests
  • Vite: Fast build tool and development server
  • Lucide React: Modern icon library

Backend

  • Node.js: JavaScript runtime environment
  • Express.js: Web application framework
  • MongoDB: NoSQL database for flexible data storage
  • Mongoose: MongoDB object modeling for Node.js
  • JWT: JSON Web Tokens for secure authentication
  • bcrypt: Password hashing and security
  • Nodemailer: Email sending for password reset functionality
  • Multer: File upload handling
  • node-cron: Scheduled task automation
  • crypto: Secure token generation for password reset

DevOps & Tools

  • Docker: Containerization for consistent deployments
  • ESLint: Code linting and quality assurance
  • Prettier: Code formatting standardization
  • Husky: Git hooks for pre-commit checks
  • Morgan: HTTP request logging

๐Ÿ“ Project Structure

fittrack/
โ”œโ”€โ”€ client/                      # React frontend application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/          # Reusable UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ admin/           # Admin-specific components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth/            # Authentication components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/       # Dashboard widgets
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ goals/           # Goal management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ nutrition/       # Nutrition tracking
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ profile/         # User profile management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ progress/        # Progress visualization
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/              # Shared UI components
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ workout/         # Workout management
โ”‚   โ”‚   โ”œโ”€โ”€ contexts/            # React Context providers
โ”‚   โ”‚   โ”œโ”€โ”€ services/            # API service functions
โ”‚   โ”‚   โ””โ”€โ”€ utils/               # Utility functions
โ”‚   โ”œโ”€โ”€ public/                  # Static assets
โ”‚   โ””โ”€โ”€ package.json             # Frontend dependencies
โ”‚
โ”œโ”€โ”€ server/                      # Node.js backend application
โ”‚   โ”œโ”€โ”€ controllers/             # Request handlers and business logic
โ”‚   โ”œโ”€โ”€ models/                  # Mongoose database models
โ”‚   โ”œโ”€โ”€ routes/                  # API route definitions
โ”‚   โ”œโ”€โ”€ middleware/              # Custom middleware functions
โ”‚   โ”œโ”€โ”€ services/                # Background services and schedulers
โ”‚   โ”œโ”€โ”€ utils/                   # Server utility functions
โ”‚   โ”œโ”€โ”€ seeder/                  # Database seeding scripts
โ”‚   โ”œโ”€โ”€ uploads/                 # File upload storage
โ”‚   โ””โ”€โ”€ documentation/           # API and technical documentation
โ”‚
โ”œโ”€โ”€ docker-compose.yml           # Docker container orchestration
โ”œโ”€โ”€ .env.example                 # Environment variables template
โ””โ”€โ”€ README.md                    # Project documentation

๐Ÿ› ๏ธ Installation & Setup

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • MongoDB (local installation or MongoDB Atlas)
  • Git
  • Gmail Account (for email functionality, optional for development)

๐Ÿ”ง Development Setup

  1. Clone the Repository

    git clone https://github.com/yourusername/fittrack.git
    cd fittrack
  2. Install Root Dependencies

    # Install root dependencies (Husky, lint-staged, etc.)
    npm install
  3. Backend Setup

    cd server
    npm install
  4. Environment Configuration

    # Copy the example environment file
    cp .env.example .env

    Edit the .env file with your configuration:

    # Server Configuration
    PORT=8001
    NODE_ENV=development
    
    # Database
    MONGODB_URI=mongodb://localhost:27017/fittrack
    
    # JWT Secrets (Generate secure random strings for production)
    JWT_SECRET=your_super_secure_jwt_secret_key_here
    REFRESH_TOKEN_SECRET=your_refresh_token_secret_key_here
    
    # Email Configuration (Optional for development)
    EMAIL_SERVICE=gmail
    EMAIL_FROM=your-email@gmail.com
    EMAIL_PASSWORD=your-gmail-app-password
    FROM_NAME=FitTrack Pro
    
    # Client URL for password reset links
    CLIENT_URL=http://localhost:5173
  5. Email Setup (Optional)

    For password reset functionality with real emails:

    • Enable 2-Factor Authentication on your Gmail account
    • Generate an App Password in Google Account settings
    • Use the App Password (not your regular password) in EMAIL_PASSWORD

    For development without real emails, the system will use Ethereal Email for testing.

  6. Database Seeding (Optional)

    # Seed database with sample data
    npm run seed
    
    # Reset all seed data
    npm run seed:destroy
  7. Start Backend Server

    # Development mode with auto-reload
    npm run dev
    
    # Production mode
    npm start
  8. Frontend Setup

    cd ../client
    npm install
  9. Frontend Environment Configuration

    Create a .env file in the client directory:

    VITE_API_URL=http://localhost:8001/
  10. Start Frontend Development Server

    npm run dev
  11. Access the Application

๐Ÿณ Docker Setup

For a containerized setup using Docker:

# Build and start all services
docker-compose up --build

# Run in detached mode
docker-compose up -d

# Stop all services
docker-compose down

The application will be available at http://localhost:80

๐Ÿ” Default Login Credentials

After seeding the database, you can use these credentials:

Admin Account:

  • Email: admin@fittrack.com
  • Password: password123

Test User Accounts:

  • Email: john@example.com | Password: password123
  • Email: jane@example.com | Password: password123

๐Ÿ“š API Documentation

Authentication Endpoints

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/refresh-token - Token refresh
  • GET /api/auth/me - Get current user
  • PUT /api/auth/password - Change password (authenticated users)
  • POST /api/auth/forgot-password - Request password reset
  • POST /api/auth/verify-reset-token - Verify reset token
  • POST /api/auth/reset-password - Reset password with token

Core Features

  • Workouts: /api/workouts - CRUD operations for workouts
  • Exercises: /api/exercises - Exercise library management
  • Nutrition: /api/nutrition - Nutrition logging and tracking
  • Goals: /api/goals - Goal setting and progress tracking
  • Profile: /api/profiles - User profile and measurements
  • Notifications: /api/notifications - Notification management

Admin Features

  • User Management: /api/admin/users - User administration
  • Analytics: /api/admin/analytics - Platform statistics
  • Content Management: Various admin endpoints for content

For detailed API documentation, see the API Documentation.

๐Ÿ”ง Key Features Implemented

Password Reset Flow

  1. Request Reset: User enters email on forgot password page
  2. Email Sent: System sends professional HTML email with reset link
  3. Token Verification: Frontend verifies token before showing reset form
  4. Password Reset: User sets new password with validation
  5. Confirmation: Confirmation email sent after successful reset

Email System

  • Professional Templates: Beautiful HTML email templates
  • Development Testing: Ethereal Email for development testing
  • Production Ready: Gmail SMTP for production use
  • Security: Time-limited tokens (10 minutes expiry)
  • Error Handling: Graceful fallbacks and detailed logging

Authentication Security

  • Password Hashing: bcrypt with salt rounds
  • JWT Tokens: Access and refresh token system
  • Token Validation: Comprehensive token verification
  • Password Strength: Client and server-side validation
  • Secure Reset: Cryptographically secure reset tokens

๐Ÿงช Testing

# Run backend tests
cd server
npm test

# Run frontend tests
cd client
npm test

# Run linting
npm run lint

# Format code
npm run format

# Test password reset flow
# 1. Register a new user
# 2. Use forgot password feature
# 3. Check email (or console logs for Ethereal)
# 4. Complete password reset
# 5. Login with new password

๐Ÿš€ Deployment

Production Build

Backend:

cd server
npm run build
npm start

Frontend:

cd client
npm run build
npm run preview

Environment Variables for Production

Ensure the following environment variables are set in production:

NODE_ENV=production
MONGODB_URI=your_production_mongodb_uri
JWT_SECRET=your_production_jwt_secret
REFRESH_TOKEN_SECRET=your_production_refresh_secret
EMAIL_SERVICE=sendgrid
SENDGRID_USERNAME=apikey
SENDGRID_PASSWORD=your_sendgrid_api_key
CLIENT_URL=https://your-production-domain.com

Email Service for Production

For production, consider using:

  • SendGrid: Reliable email delivery service
  • AWS SES: Amazon's email service
  • Mailgun: Developer-friendly email API
  • Postmark: Transactional email service

๐Ÿค Contributing

We welcome contributions! Please follow these steps:

  1. Fork the Repository
  2. Create a Feature Branch
    git checkout -b feature/amazing-feature
  3. Make Your Changes
  4. Commit Your Changes
    git commit -m 'Add some amazing feature'
  5. Push to the Branch
    git push origin feature/amazing-feature
  6. Open a Pull Request

Development Guidelines

  • Follow the existing code style and linting rules
  • Write comprehensive tests for new features
  • Update documentation for API changes
  • Use meaningful commit messages
  • Ensure all tests pass before submitting
  • Test email functionality with both Ethereal and real email services

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Join our community discussions

๐Ÿ”ฎ Roadmap

  • Password reset functionality with email
  • Professional email templates
  • Multi-step user registration
  • Mobile application (React Native)
  • Social features and community
  • Integration with fitness wearables
  • Advanced AI-powered recommendations
  • Meal planning and recipe suggestions
  • Workout video integration
  • Multi-language support
  • Two-factor authentication
  • Social login (Google, Facebook)

Built with โค๏ธ by the FitTrack Team

Start your fitness journey today with FitTrack - where every workout counts and every goal is achievable!

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages