Skip to content

Shravan: add kitchen recipe model, controller, and substitute ingredient…#2174

Open
Shravan-neelamsetty wants to merge 1 commit into
developmentfrom
shravan-substitute-ingredient-backend
Open

Shravan: add kitchen recipe model, controller, and substitute ingredient…#2174
Shravan-neelamsetty wants to merge 1 commit into
developmentfrom
shravan-substitute-ingredient-backend

Conversation

@Shravan-neelamsetty
Copy link
Copy Markdown

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-ingredient frontend PR.

Main changes explained:

  • Create file src/models/kitchenRecipe.js for introducing the kitchen recipe Mongoose model with embedded ingredient subdocuments (name, quantity, isOnsite, isAvailable)
  • Create file src/controllers/kitchenRecipeController.js for introducing getRecipes, getRecipeById, and substituteIngredient controller functions
  • Create file src/routes/kitchenRecipeRouter.js for registering three endpoints: GET /kitchenandinventory/recipes, GET /kitchenandinventory/recipes/:recipeId, and PUT /kitchenandinventory/recipes/:recipeId/substitute
  • Update file src/startup/routes.js for adding the kitchenRecipe model require, router require, and app.use registration

How to test:

  1. Check into branch shravan-substitute-ingredient-backend
  2. Do npm install and npm start to run this PR locally
  3. Log in via POST /api/login with admin credentials to get a token
  4. Test GET /api/kitchenandinventory/recipes with the Authorization header and verify it returns all recipes
  5. Test GET /api/kitchenandinventory/recipes/:recipeId and verify it returns a single recipe
  6. Test PUT /api/kitchenandinventory/recipes/:recipeId/substitute with body {"ingredientId": "INGREDIENT_ID", "substituteName": "White Pepper", "quantity": "1 tsp"} and verify the ingredient name, quantity, and isAvailable fields are updated in the response
  7. Run GET /api/kitchenandinventory/recipes again and verify the substitution persisted
  8. Test with missing fields (no ingredientId, no substituteName, no quantity) and verify a 400 error is returned
  9. Test with an invalid recipeId and verify a 500 error is returned
  10. Test with a valid recipeId but invalid ingredientId and verify a 404 "Ingredient not found" error is returned

Screenshots or videos of changes

Get All Recipes

Screenshot 2026-04-18 at 12 31 30 AM

PUT substitute (success)

Screenshot 2026-04-18 at 12 34 33 AM

PUT substitute (validation error)

Screenshot 2026-04-18 at 12 37 10 AM

GET single recipe

Screenshot 2026-04-18 at 12 37 49 AM

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.

@Shravan-neelamsetty Shravan-neelamsetty changed the title feat: add kitchen recipe model, controller, and substitute ingredient… Shravan: add kitchen recipe model, controller, and substitute ingredient… Apr 18, 2026
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants