This Ruby on Rails application provides a simple calorie calculator that helps users estimate their daily calorie needs and recommends a calorie intake for weight loss.
Demo: https://apb-kcal-e4f6df54a128.herokuapp.com
- Calculate Total Daily Energy Expenditure (TDEE) based on user input
- Provide recommended calorie intake for weight loss
-
Clone the repository:
git clone https://github.com/your-username/calorie-calculator.git cd calorie-calculator
-
Install dependencies:
bundle install
-
Set up the database:
rails db:setup
-
Start the Rails server:
./bin/dev
-
Visit
http://localhost:3000
in your browser to use the application.
app/controllers/calorie_calculator_controller.rb
: Contains the logic for calculating TDEE and weight loss calories.app/views/calorie_calculator/index.html.erb
: The main view with the calorie calculator form and results display.app/javascript/controllers/calorie_calculator_controller.js
: Stimulus controller for handling responses and updating the DOM.
The application uses the following formulas:
-
Basal Metabolic Rate (BMR):
- For men: 88.362 + (13.397 * weight) + (4.799 * height) - (5.677 * age)
- For women: 447.593 + (9.247 * weight) + (3.098 * height) - (4.330 * age)
-
Total Daily Energy Expenditure (TDEE): BMR * activity factor
Activity factors:
- Sedentary: 1.2
- Light Exercise: 1.375
- Moderate Exercise: 1.55
- Active: 1.725
- Very Active: 1.9
-
Weight Loss Calorie Recommendation: TDEE * 0.85 (15% calorie deficit)
This project is licensed under the MIT License - see the LICENSE.md file for details.