in reply to How do you name the possibilities?

what if there are more than 16 variants per an ingredient? We run out of digits.
No you don't. You aren't limited to base-16. You can use 0-9a-z as your "digits". You can also know when a particular component requires more than one digit space, and use as many as you need.

UpdateIf you need your system to be expandable, you can use _ as a field separator, so your keys for a three-component inventory might look like:

id_0_1c_z id_0_0_0

We're not really tightening our belts, it just feels that way because we're getting fatter.