A comprehensive fitness management application built with Django REST Framework that helps users track their fitness journey, create workout plans, manage diet, and earn rewards.
Fitness Assistant is a web-based application designed to help users manage their fitness journey. It provides features for tracking workouts, creating personalized fitness plans, managing diet through food items and recipes, and earning rewards through achievements and badges.
The application is built using Django and Django REST Framework, providing a robust API for frontend applications to interact with.
- User Management: Create and manage user accounts with authentication
- Customer Profiles: Manage customer profiles with details like age, height, weight, and gender
- Exercise Library: Browse a collection of exercises with descriptions and difficulty levels
- Workout Plans: Create personalized workout plans based on fitness objectives
- Daily Plans: Track daily workout plans and mark them as completed
- Food and Recipe Database: Access a database of food items and recipes with nutritional information
- Rewards System: Earn points, achievements, and badges for completing workouts
- Filtering: Filter resources by various parameters like objective type, difficulty level, etc.
- Python 3.13+
- MySQL database
- Pipenv (for dependency management)
-
Clone the repository:
git clone https://github.com/yourusername/fitnessAssistant.git cd fitnessAssistant -
Install dependencies using Pipenv:
pipenv install -
Activate the virtual environment:
pipenv shell -
Set up the database:
python manage.py migrate -
Create a superuser:
python manage.py createsuperuser -
Run the development server:
python manage.py runserver
The application uses a MySQL database by default. You can configure the database settings in Fitness_Assistant/settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'fitness_assistant2',
'USER': 'root',
'PASSWORD': 'your_password',
'HOST': 'localhost',
'PORT': '3306',
}
}All API endpoints are prefixed with /api/.
The application provides a custom authentication endpoint:
- POST /api/authenticate/: Authenticate a user with username, email, and password
Example request:
{
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword"
}Example response:
{
"id": 1,
"username": "johndoe",
"first_name": "John",
"last_name": "Doe",
"email": "john@example.com"
}- GET /api/customers/: List all customers
- GET /api/customers/{id}/: Retrieve a specific customer
- POST /api/customers/: Create a new customer
- PATCH /api/customers/{id}/: Update a customer
- GET /api/customers/?gender=M: Filter customers by gender
- GET /api/customers/?kind=VG: Filter customers by kind (vegetarian/non-vegetarian)
- GET /api/customers/?user__id=1: Filter customers by user ID
- GET /api/exercises/: List all exercises
- GET /api/exercises/{id}/: Retrieve a specific exercise
- GET /api/exercises/?toughness_level=H: Filter exercises by toughness level (H, M, E)
- GET /api/exercises/?objective=WL: Filter exercises by objective type (WL, BB, FG)
- GET /api/jobs/: List all jobs
- GET /api/jobs/{id}/: Retrieve a specific job
- POST /api/jobs/: Create a new job
- DELETE /api/jobs/{id}/: Delete a job
- GET /api/jobs/?ordering=completed_at: Order jobs by completion time
- GET /api/plans/: List all plans
- GET /api/plans/{id}/: Retrieve a specific plan
- POST /api/plans/: Create a new plan
- PATCH /api/plans/{id}/: Update a plan
- GET /api/plans/?customer=1: Filter plans by customer ID
- GET /api/plans/?objective_type=WL: Filter plans by objective type (WL, BB, FG)
- GET /api/daily-plans/: List all daily plans
- GET /api/daily-plans/{id}/: Retrieve a specific daily plan
- POST /api/daily-plans/: Create a new daily plan
- PATCH /api/daily-plans/{id}/: Update a daily plan
- GET /api/daily-plans/?plan=1: Filter daily plans by plan ID
- GET /api/daily-plans/?completion_status=true: Filter daily plans by completion status
- GET /api/food-items/: List all food items
- GET /api/food-items/{id}/: Retrieve a specific food item
- GET /api/food-items/?objective_type=WL: Filter food items by objective type (WL, BB, FG)
- GET /api/food-items/?kind=VG: Filter food items by kind (VG, NVG)
- GET /api/recipes/: List all recipes
- GET /api/recipes/{id}/: Retrieve a specific recipe
- GET /api/recipes/?objective_type=WL: Filter recipes by objective type (WL, BB, FG)
- GET /api/recipes/?kind=VG: Filter recipes by kind (VG, NVG)
- GET /api/badges/: List all badges
- GET /api/badges/{id}/: Retrieve a specific badge
- POST /api/badges/: Create a new badge
- PATCH /api/badges/{id}/: Update a badge
- GET /api/achievements/: List all achievements
- GET /api/achievements/{id}/: Retrieve a specific achievement
- POST /api/achievements/: Create a new achievement
- PATCH /api/achievements/{id}/: Update an achievement
import requests
# Base URL
base_url = "http://localhost:8000/api"
# Create a customer with a user
response = requests.post(f"{base_url}/customers/", json={
"user": {
"username": "johndoe",
"email": "john@example.com",
"first_name": "John",
"last_name": "Doe"
},
"age": 30,
"height": 180.5,
"weight": 75.0,
"gender": "M",
"kind": "NVG"
})
print(response.json())import requests
# Base URL
base_url = "http://localhost:8000/api"
# Authenticate a user
response = requests.post(f"{base_url}/authenticate/", json={
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword"
})
print(response.json())import requests
# Base URL
base_url = "http://localhost:8000/api"
# Create a fitness plan
response = requests.post(f"{base_url}/plans/", json={
"objectiveType": "WL",
"customer": 1,
"duration_in_days": 14
})
print(response.json())import requests
# Base URL
base_url = "http://localhost:8000/api"
# Mark a daily plan as completed
response = requests.patch(f"{base_url}/daily-plans/1/", json={
"completion_status": True
})
print(response.json())Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request