MealMetric is a comprehensive web application designed to serve as an intuitive and powerful nutrition calculator. It allows users to create, manage, and analyze recipes while tracking detailed nutritional information of ingredients. This tool is perfect for anyone looking to monitor their dietary intake and gain insights into the nutritional value of their meals.
- Nutritional Data Fetching: Utilizes the Natural Language for Nutrients API to fetch real-time nutritional data for ingredients.
- Recipe Management: Users can add, view, edit, and delete recipes with ease.
- Real-time Nutritional Overview: Dynamically calculates and displays comprehensive nutritional content for each recipe.
- Responsive Design: Optimized for both desktop and mobile devices.
- Backend: Node.js with Express.js
- Frontend: EJS (Embedded JavaScript templating)
- Database: PostgreSQL
- API Integration: Axios for making requests to the Natural Language for Nutrients API
-
Clone the Repository:
git clone https://github.com/strangely-true/MealMetric.git cd MealMetric
-
Install Dependencies:
npm install
-
Set up PostgreSQL Database:
- Install PostgreSQL: PostgreSQL Documentation
- Create a database named
mealmetric_db
- Run the SQL queries from
db/queries.sql
to set up the required tables
-
Configure Environment Variables: Create a
.env
file in the root directory with the following:DATABASE_URL=postgres://<your_username>:<your_password>@localhost:5432/mealmetric_db NUTRITIONIX_APP_ID=your_APP_ID NUTRITIONIX_API_KEY=your_API_KEY
-
Start the Application:
node app.js
The app will be available at
http://localhost:3000
- Registration and Login: New users can register and then log in to access the app's features.
- Creating Recipes: Add new recipes by specifying name, ingredients, and quantities.
- Managing Recipes: View, edit, or delete saved recipes.
- Nutritional Overview: See real-time updates of nutritional information as you modify recipes.
MealMetric/
├── db/
│ └── queries.sql
├── public/
│ ├── css/
│ └── js/
├── views/
│ ├── index.ejs
│ ├── edit_recipe.ejs
│ ├── landing.ejs
│ ├── login.ejs
│ ├── new_recipe.ejs
│ ├── signup.ejs
│ └── recipe.ejs
├── app.js
├── db.js
├── .gitignore
├── package.json
├── README.md
└── .env
-
app.js
:- Contains the core logic of the application, including routing, API calls, and interactions with the PostgreSQL database.
- Also handles user registration, login, and session management.
-
db.js
:- Contains all the database models for storing user information, recipes, and ingredient details.
-
views/
(templates):- This folder includes all the EJS files that render the web pages dynamically, such as the home page, recipe form, and individual recipe details.
-
public/
:- Contains static assets like CSS files, JavaScript files, and images for styling the application.
-
db/queries.sql
:- Contains the SQL queries to set up the database schema, including tables for users, recipes, ingredients, and nutritional information.
- Nutritional Calculation: The app fetches real-time nutritional data from an API based on user-inputted ingredients.
- Recipe Management: Users can create, update, and delete their recipes while tracking nutritional metrics.
- User Authentication: Includes a hashing-based login and signup system with user information securely stored in a PostgreSQL database.
- Dynamic Interface: Users can seamlessly add or remove ingredients on the recipe form, with immediate recalculation of nutritional totals.
- Responsive Design: The app is fully responsive and optimized for both desktop and mobile devices.
ℹ️ Note:
- All the nutritional data is fetched via the Natural Language for Nutrients API, and I do not own any of the data provided by the API.
For more information on the Natural Language for Nutrients API, visit their official documentation.
For PostgreSQL documentation, refer to the official PostgreSQL website.