bitcart/bitcart

Plugins support

MrNaif2018 opened this issue ยท 2 comments

To make BitcartCC core light but be able to add any functionality, we need a plugin system

Plugins should be able to customize almost everything: add new routes, possibly new database tables via migrations, new background tasks, new worker events, maybe register new templates/scripts and their settings. All of that is modifying existing merchants api code. Some plugins might need to add new UI features: this means modifying separate admin and store containers.
With our separation of services it might be non-trivial to add plugins support.
Plugins will probably be separated by a few types: backend plugins (extending merchants API), UI plugins (extending admin or store), service plugins (adding completely new services running in one-domain mode under some URL) and mixed plugins which could contain all previous types.

Plugins must have their version set, name, description, and a set of requirements.
Plugins may have requirements for BitcartCC version, if version doesn't match, plugin code shouldn't be loaded at all (so metadata should be separate from plugin code).
Plugins might have specific library dependencies from pypi, or even require docker-compose services. The services and other requirements are specified in the metadata file.
Plugins should be packed in a standalone file, possibly just a zip archive, with .bitcartcc extension.
There are two approaches we may use:
1. Zip archive with source code
BitcartCC will just execute needed commands to install the plugin, that means pip installing requirements, copying service files, re-generating docker-compose, applying database migrations, running build commands like yarn build for node.js parts
This is good because this will work on any architecture and will be of minimal file size, as it just contains source code
Disadvantages are that we will need to somehow isolate the dependencies to not break the main app, and also that installation times may take a long time
2. Binary file
This will install dependencies during pack time and then bundle it all with pyinstaller or other tools
The advantages are that everything is isolated and self-contained, instant installation
Disadvantages are that we will need one binary per each architecture, and also I am not sure how to import from those files

The code might need to be refactored to allow adding new features easily

This is a complex task, so any ideas and help welcome

After implementing that BitCCL could be added as a plugin

This is our next top priority

One idea that may simplify the implementation is to not allow hot loading of modules, but instead just restart bitcart and let it load plugins on startup only

The issue with compiled vue application somehow using plugins is still present, as well as the question of how to package plugins

Released in 0.7.0.0! ๐ŸŽ‰