It might be worth taking a look at this app? https://apps.shopify.com/ready-pantry
It was built for restaurants initially, but the main goal is to keep track of raw ingredient count and link a Shopify product to these raw ingredients, with insights on your costs, etc.
Let me know if it helps! In any case, there is a 28-day free trial so you can see if it's suited for you @tasuku