This example is what I personally use to create an item with a filter, where the filter is added to through crafting
It makes use of 1.21's Component system, specifically the "free storage" of CustomData
I've tried to comment every step of the way, to showcase how to use the Component system for crafting, but it is not a step-by-step tutorial to be copy/pasted
I would also like to point out that NBT can only be used to store very basic information, that means booleans, bytes, byte-arrays, doubles, floats, ints, int-arrays, longs, long-arrays, shorts & strings
If you have some other form of Object, you need to serialize it. Easiest would be to use KubeJS' JsonIO and convert it to/from string