Data Structure Design of E-commerce Freight Template

  node.js, question

I want to design a data structure similar to the one that praised YouShop for calculating freight by region, but my design always has various defects.

The logic is as follows

1. A freight template can be generated and used for multiple commodities.
2. The template can add specific areas to the area and set the corresponding freight.
3. When the user inquires about a given region, only the commodities in that region are displayed in the distribution range.

May I ask how a great god should realize this logic?
Is there a ready-made third-party library? Js environment)

Sincerely ask for help, thank you! ! !

I am also doing this, referring to Taobao