Modularity

This project is based on the idea of modules that contain functionality inside of them. These modules must be:

  • Standalone - modules must only be responsible for a single feature. An example: shopify-product are responsible for pure product and product-listing pages, while modules like shopify-product-tags and shopify-product-variants build upon them by providing additional feature scope.

  • Isolated - modules must follow the principle of Inversion of control which means, they must inject their functionality into other modules, instead of being imported and manually used. In order to achieve this the "plugin system" is used.

  • Pluggable - modules must allow for further extension. It is allowed to use enclosed, non-extensible patterns like React's functional components, but their usage highly restricts application extensibility, thus is recommended to avoid them. The module functionality must be split into as many parts as possible in order to allow for more selective and precise extension.

To be "pluggable" and "isolated" modules are using the application plugin system, which allows for selective namespace-based plugging.

Plugin system

To create a plugin - means to create a programmable proxy between the original function and the function caller. The plugin can modify original function arguments and return values.

Modules might contain plugin declaration files, which, in turn, must contain plugin declarations. They must keep to the following rules:

  • Each module may contain multiple plugin declaration files, each declaration file must serve unique functional purpose. For example: shopify-product the module contains 2 plugin declaration files, each with its own purpose: one for registration of product page, and another, for product-listing page registration.

  • Each plugin declaration file may contain multiple plugin declarations. These plugin declarations must serve a common functional purpose. For example: shopify-product-variants inject four plugins into the ProductsProvider – one per each function of ProductsProvider it aims to modify. These declarations are located in a single plugin declaration file because they serve a single purpose of injecting the product variants information into the ProductsProvider.

Last updated