Shravan: add kitchen recipe model, controller, and substitute ingredient…#2174
Open
Shravan-neelamsetty wants to merge 1 commit into
Open
Shravan: add kitchen recipe model, controller, and substitute ingredient…#2174Shravan-neelamsetty wants to merge 1 commit into
Shravan-neelamsetty wants to merge 1 commit into
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Implements Phase 6 - Kitchen Inventory Management - Backend support for the Recipes module and substitute ingredient functionality.
Adds the kitchen recipe Mongoose model, controller with three endpoints, and route registration. The substitute ingredient endpoint allows the frontend to replace unavailable ingredients in a recipe with available alternatives from inventory, persisting the change to MongoDB.
Related PRs (if any):
This backend PR is related to the frontend PR in the HighestGoodNetworkApp repository on branch
shravan-substitute-ingredient.To test this backend PR you need to checkout the
shravan-substitute-ingredientfrontend PR.Main changes explained:
src/models/kitchenRecipe.jsfor introducing the kitchen recipe Mongoose model with embedded ingredient subdocuments (name, quantity, isOnsite, isAvailable)src/controllers/kitchenRecipeController.jsfor introducing getRecipes, getRecipeById, and substituteIngredient controller functionssrc/routes/kitchenRecipeRouter.jsfor registering three endpoints:GET /kitchenandinventory/recipes,GET /kitchenandinventory/recipes/:recipeId, andPUT /kitchenandinventory/recipes/:recipeId/substitutesrc/startup/routes.jsfor adding the kitchenRecipe model require, router require, and app.use registrationHow to test:
shravan-substitute-ingredient-backendnpm installandnpm startto run this PR locallyPOST /api/loginwith admin credentials to get a tokenGET /api/kitchenandinventory/recipeswith the Authorization header and verify it returns all recipesGET /api/kitchenandinventory/recipes/:recipeIdand verify it returns a single recipePUT /api/kitchenandinventory/recipes/:recipeId/substitutewith body{"ingredientId": "INGREDIENT_ID", "substituteName": "White Pepper", "quantity": "1 tsp"}and verify the ingredient name, quantity, and isAvailable fields are updated in the responseGET /api/kitchenandinventory/recipesagain and verify the substitution persistedScreenshots or videos of changes
Get All Recipes
PUT substitute (success)
PUT substitute (validation error)
GET single recipe
Note:
This is the first backend PR for the Kitchen and Inventory portal. The kitchenRecipes collection needs to be populated with recipe data for the endpoints to return results. The frontend PR includes a fallback to mock data if the backend is unavailable. The substitute endpoint updates the ingredient name, quantity, and sets isAvailable to true. The Reorder endpoint will be implemented in a future deliverable.