Can we store and load product variants from an external database?

Hello

i would like to know if we can store our product variants in an external database outside of Shopify and post it when a product page is loaded is loaded?

example:

product ID 1245667 (Shopify ID) has variants color: black sizes: 123456 in our outside database saved for same product id. When this product page is loaded the variants will be pulled from our database and posted for this product for customer to choose from and add to cart

we can add code in the theme on product page to post variants for products

is this something possible to do?

it can be done with custom cart properties