Skip to content

Commit e9c8557

Browse files
authored
Merge branch 'main' into OriginBranch
2 parents 7ae99c7 + 36e32d4 commit e9c8557

13 files changed

+614
-48
lines changed

README.md

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,78 @@
1-
# Bon-Hack-tit
1+
2+
3+
4+
5+
6+
7+
8+
<a id="about"> </a>
9+
10+
# FoodMeets
11+
12+
13+
14+
15+
Plan your meals with ease, from weekly menus to random recipes and ingredient-based suggestions.
16+
17+
18+
iMage
19+
20+
21+
## How to Setup
22+
23+
1) Install [Node js](https://nodejs.org/en/download/)
24+
25+
2) Clone the repository
26+
```
27+
git clone https://github.com/coder12git/Bon-Hack-tit.git
28+
29+
```
30+
31+
3) To install dependencies run
32+
```
33+
npm i
34+
35+
```
36+
37+
4) To start the server run
38+
```
39+
npm start
40+
41+
```
42+
43+
44+
## Sample menu and recipe
45+
46+
Image
47+
48+
Image
49+
50+
51+
## What it does
52+
Our web application is designed to make meal planning more convenient and efficient for busy individuals. With three key features, users can easily create a weekly menu based on their dietary needs and preferences, generate recipes based on the ingredients they have on hand, and try something new with exciting recipe ideas.
53+
54+
The first feature,
55+
- **Create your weekly menu**: Allows users to customize their meal plan by inputting their diet details, target calories, preferred cuisines, and ingredients they want to include or exclude from recipes. This feature takes the stress out of meal planning by providing users with recipe ideas that meet their nutritional needs and taste preferences.
56+
57+
The second feature,
58+
- **What's in your fridge**: Allows users to make the most of the ingredients they already have at home. By inputting the ingredients they have on hand and the number of recipes they want to generate, users can easily access a variety of recipe ideas to inspire their meals and reduce food waste.
59+
60+
The third feature,
61+
- **Try something new today**: It is perfect for users looking to add some variety to their meal rotation. By selecting tags and the number of recipes they want, users can explore new recipes and expand their culinary horizons.
62+
63+
Additionally, we wanted to provide users with **a convenient way to access their meal plans and recipes without having to constantly log into our web application**. That's why we added a feature that allows users to **download their menus and recipe lists in a PDF file**. This way, users can easily access their meal plans and recipes offline, and even print them out if needed. We believe that this feature adds a lot of value to our application, making it even more convenient and user-friendly for busy people who are always on the go.
64+
65+
Overall, our web application provides a user-friendly and efficient solution for meal planning, recipe generation, and nutrient tracking to help busy individuals make healthier and more delicious meals every day.
66+
67+
68+
## How it works
69+
To use **FoodMeets**, start by navigating to the home page and selecting one of the three features available. For example, if you want to plan out your weekly menu, select the "Create Your Weekly Menu" feature. Next, enter details such as your dietary preferences, target calories, cuisine preferences, and any ingredients you want to include or exclude from your recipes. Once you've entered all the necessary information, click the submit button.
70+
71+
You will then be taken to a page where you can see your weekly menus. Click on any of the meals to see the complete recipe for that meal, including ingredients and instructions on how to prepare it. If you want to save the recipe for later, simply click on the download button to download the recipe as a .pdf file.
72+
73+
Similarly, you can use the other two features of FoodMeets, "What's In Your Fridge" and "Try Something New Today," by following the same process of entering the necessary details and clicking the submit button.
74+
75+
76+
77+
78+

app.js

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ app.set("view engine", "ejs");
1313
app.use(bodyParser.urlencoded({ extended: true }));
1414
app.use(express.static("public"));
1515

16-
const apiKey = "c7d40af634094a53a02a542268b9f073";
16+
const apiKey = "f8f19f5552fe4a64a5bd79038933bb05";
1717

18-
// All the get request to render differrent page.
18+
// All the get request to render different page.
1919

2020
app.get("/", (req, res) => {
2121
res.render("home");
@@ -29,6 +29,10 @@ app.get("/inputIngredient", (req, res) => {
2929
res.render("inputIngredient");
3030
});
3131

32+
app.get("/inputRandom", (req, res) => {
33+
res.render("inputRandom");
34+
});
35+
3236
// POST request to render menus for a week based on user input
3337

3438
app.post("/mealList", async (req, res) => {
@@ -98,20 +102,71 @@ app.post("/ingredientList", async (req, res) => {
98102
const recipesData = await generateRecipesByIngredients.json();
99103

100104
// Generate recipe information
105+
const recipeInfoPromises = recipesData.map(async (recipe) => {
106+
const recipeInfo = await fetch(
107+
`https://api.spoonacular.com/recipes/${recipe.id}/nutritionWidget.json?apiKey=${apiKey}`
108+
);
109+
const infoData = await recipeInfo.json();
110+
return {
111+
...recipe,
112+
nutrients: infoData,
113+
};
114+
});
101115

102-
const recipeInfo = await fetch(
103-
`https://api.spoonacular.com/recipes/complexSearch?apiKey=c7d40af634094a53a02a542268b9f073`
104-
);
105-
const results = recipeInfo.json();
116+
// Wait for all recipe nutrient information to be fetched
117+
const recipesWithNutrients = await Promise.all(recipeInfoPromises);
106118

107119
res.render("planMealsByIngredients", {
108-
recipes: recipesData,
109-
results: results,
120+
recipes: recipesWithNutrients,
110121
});
111122

112-
// res.send(recipesData);
123+
// res.send(recipesWithNutrients);
113124
} catch (error) {
114-
res.send(error);
125+
res.send("Sorry! Some error occurred. Please try again!");
126+
console.log(error);
127+
}
128+
});
129+
130+
//POST request to generate random list of recipes based on tags provided by user
131+
132+
app.post("/randomList", async (req, res) => {
133+
// Tags and number provided by user
134+
135+
const number = req.body.number;
136+
let tags = req.body.tags;
137+
if (typeof tags === "strings") {
138+
tags = req.body.tags.split(",");
139+
}
140+
141+
try {
142+
const { default: fetch } = await import("node-fetch");
143+
const generateRandomRecipes =
144+
await fetch(`https://api.spoonacular.com/recipes/random?number=${number}&tags=${tags}&apiKey=${apiKey}
145+
`);
146+
147+
const randomData = await generateRandomRecipes.json();
148+
149+
// Generate Recipe information including nutrients
150+
151+
const recipeInfoPromises = randomData.recipes.map(async (recipe) => {
152+
const recipeInfo = await fetch(
153+
`https://api.spoonacular.com/recipes/${recipe.id}/nutritionWidget.json?apiKey=${apiKey}`
154+
);
155+
const infoData = await recipeInfo.json();
156+
return {
157+
...recipe,
158+
nutrients: infoData,
159+
};
160+
});
161+
162+
// Wait for all recipe nutrient information to be fetched
163+
const recipesWithNutrients = await Promise.all(recipeInfoPromises);
164+
165+
res.render("randomMeals", {
166+
recipes: recipesWithNutrients,
167+
});
168+
} catch (error) {
169+
res.send("Sorry! Some error occurred. Please try again!");
115170
console.log(error);
116171
}
117172
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Meal Planning Web App",
55
"main": "server.js",
66
"scripts": {
7-
"start": "nodemon server.js"
7+
"start": "node server.js"
88
},
99
"repository": {
1010
"type": "git",

public/css/styles.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
body * {
2+
23
font-family: 'Montserrat', sans-serif;
34
}
45
.homeBody {
@@ -129,4 +130,6 @@ h3.homeTitle {
129130
height: 300px;
130131
width: 300px;
131132
}
133+
=======
134+
font-family: "Montserrat", sans-serif;
132135
}

public/images/favicon.ico

1.37 KB
Binary file not shown.

views/home.ejs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>FoodMeets</title>
8+
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
89
<link rel="preconnect" href="https://fonts.googleapis.com">
910
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
1011
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
@@ -36,10 +37,20 @@
3637
<!-- Row -->
3738
<div class="w-full xl:w-3/4 lg:w-11/12 flex">
3839
<!-- Col -->
40+
3941
<div class="w-full optionsWrapper">
4042
<h3 class="text-center homeTitle">Welcome - Let's plan some meals!</h3>
4143
<form class="menuWrapper">
4244
<a href="/inputWeekPlanMeals" class="weeklyMenu component">
45+
<div
46+
class="w-full h-auto bg-gray-400 hidden lg:block lg:w-5/12 bg-cover rounded-l-lg"
47+
style="background-image: url('/images/food.png')"
48+
></div>
49+
<!-- Col -->
50+
<div class="w-full lg:w-7/12 bg-white p-5 rounded-lg lg:rounded-l-none">
51+
<h3 class="pt-4 text-2xl text-center">Welcome - Let's plan some meals!</h3>
52+
<form class="px-8 pt-6 pb-8 mb-4 bg-white rounded">
53+
<a href="/inputWeekPlanMeals">
4354
<button
4455
class="textBackground"
4556
type="button"> Create your weekly menu
@@ -51,12 +62,20 @@
5162
type="button">What's in your fridge?
5263
</button>
5364
</a>
54-
<a href="file:///C:/Users/tulsa/OneDrive/Documents/GitHub/Bon-Hack-tit/views/inputIngredient.html" class="somethingNew component">
65+
<a href="/inputRandom" class="somethingNew component">
5566
<button
5667
class="textBackground"
5768
type="button">Try something new today
5869
</button>
5970
</a>
71+
<br> <br>
72+
<a href="/inputRandom">
73+
<button
74+
class="w-full px-4 py-2 font-bold text-white bg-blue-500 rounded-full hover:bg-blue-700 focus:outline-none focus:shadow-outline"
75+
type="button">Try something new today
76+
</button>
77+
</a>
78+
<br> <br>
6079

6180

6281
</div>

views/inputIngredient.ejs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
<meta charset="UTF-8" />
55
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Meal Planning App</title>
7+
<title>FoodMeets</title>
8+
<link rel="icon" type="image/x-icon" href="/images/favicon.ico">
89
<link
910
href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
1011
rel="stylesheet"
1112
/>
12-
<link href="css/styles.css" rel="stylesheet" />
13+
<link href="/css/styles.css" rel="stylesheet" />
1314
</head>
1415

1516
<body class="font-mono bg-gray-400">
@@ -19,7 +20,7 @@
1920
class="flex items-center justify-between flex-wrap bg-orange-600 p-6"
2021
>
2122
<div class="flex items-center flex-shrink-0 text-white mr-6">
22-
<span class="font-semibold text-xl tracking-tight">Plan Your Meal</span>
23+
<span class="font-semibold text-xl tracking-tight">FoodMeets</span>
2324
</div>
2425
<div class="block md:hidden">
2526
<button

0 commit comments

Comments
 (0)