Hi, I'm a big fan of the game and a hobby programmer so I won't pretend to know the specifics of what language or environment you develop in but would it not be possible to theoretically have an array of "attached parts" where each group of attached parts is an object with a constructor method containing parameters for grip, guard, and metalwork? You may need separate constructor methods if you want to make 2 specific parts mandatory in all the possible combinations, but the point being that you would take finished weapons out of this array when disassembled on the anvil or sold.
I have no idea what system you're using currently to attach and detach weapons but it is the most catching feature of this game (in my eyes) so I understand if it's a complex subject. I would love to see a post on the subject if you ever felt like writing about the systems you use to track that part of the game!