Managing inventory of variant SKUs comprised of standalone components

I have a product, let’s call it Product A, that has multiple different variant SKUs which we can call A1, A2, and A3. Each of the variant SKUs is essentially comprised of varying combinations of the same components which we can call X, Y, and Z. So for the sake of this example, product A1 is composed of 1 X and 2Y, product A2 is composed of 2X and 1Y, and product A3 is composed of 1X and 1Y.

Shopify allows me to create product A with variants A1, A2, and A3 however, since these are comprised of a varying number of other components I am unable to manage inventory of components X, Y, and Z. Is there a clever way of managing this in shopify or some app in the app store that will allow me to manage inventory of X, Y, and Z but still have the front end on my website show up as Product A with variants A1, A2, and A3?