This backend system powers a fitness tracking application, leveraging AI to provide personalized fitness recommendations, track user activities, and monitor progress. It offers a robust API for managing users, logging workouts, setting fitness goals, and delivering AI-driven insights.
- User registration and login.
- Encrypted password storage.
- User profiles include age, weight, height, and fitness goals.
- Log fitness activities (e.g., running, cycling, weightlifting).
- Each activity includes:
- Activity Type: Exercise type.
- Duration: Time spent.
- Calories Burned: Estimated energy expenditure.
- Timestamp: Activity date and time.
- Set and update fitness goals (e.g., weight loss, muscle gain, distance running).
- Personalized workout recommendations.
- Progress tracking toward fitness goals.
- Motivational feedback based on user activity.
- Endpoints for retrieving activity data for visualization (e.g., charts of calories burned or workouts logged).
- Backend Frameworks:
- Node.js (Express) for core APIs.
- FastAPI (Python) for AI model inference.
- Database: MongoDB.
- Machine Learning Model: XGBoost for workout classification.
The AI model is built to classify workouts based on user activity data. Key details:
- Dataset:
fitness_tracker_dataset.csv
- Preprocessing:
- Features: Exclude
gender
,duration
,calories_burned
,intensity
,workout_type
, andcalories_intake
. - Target:
workout_type
. - Standardized using
StandardScaler
.
- Features: Exclude
- Model: XGBoost Classifier with hyperparameters:
n_estimators=100
max_depth=5
learning_rate=0.1
- Accuracy: Achieved significant training and testing accuracy after model evaluation.
Refer to the main.py
file for implementation details.
- Python 3.9+
- Node.js 14+
- MongoDB
- Clone the repository.
- Navigate to the backend folder:
cd backend
- Install Node.js dependencies:
npm install
- Navigate to the FastAPI service:
cd fastapi-service
- Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install Python dependencies:
pip install -r requirements.txt
- Start the Node.js backend:
npm start
- Start the FastAPI service:
uvicorn main:app --reload
- POST /users: Create a new user.
- GET /users/:id: Retrieve user profile.
- POST /activities: Log a fitness activity.
- GET /activities/:id: Retrieve activity logs.
- POST /goals: Set/update fitness goals.
- GET /insights/:id: Get AI-driven insights.
- POST /predict: Classify workout type using the AI model.
Contributions are welcome! Please ensure to follow standard practices when adding features or fixing issues.
This project is licensed under the MIT License. See the LICENSE
file for details.
Let me know if you'd like modifications!