|
| 1 | +# Pluggable Apps |
| 2 | + |
| 3 | + |
| 4 | +## Overview |
| 5 | + |
| 6 | +Care supports plugins that can be used to extend its functionality. Plugins are basically django apps that are defined in the `plug_config.py`. |
| 7 | +These plugins can be automatically loaded during docker image build or run time, however its recommended to include them during docker image build time. |
| 8 | +The default care image does not include any plugins, but you can create your own plugin config by overriding the `plug_config.py` file. |
| 9 | + |
| 10 | + |
| 11 | +example `plug_config.py` file: |
| 12 | + |
| 13 | +```python |
| 14 | + |
| 15 | +from plugs.manager import PlugManager |
| 16 | +from plugs.plug import Plug |
| 17 | + |
| 18 | +my_plugin = Plug( |
| 19 | + name="my_plugin", |
| 20 | + package_name="git+https://github.com/octo/my_plugin.git", |
| 21 | + version="@v1.0.0", |
| 22 | + configs={ |
| 23 | + "SERVICE_API_KEY": "my_api_key", |
| 24 | + "SERVICE_SECRET_KEY": "my_secret_key", |
| 25 | + "VALUE_1_MAX": 10, |
| 26 | + }, |
| 27 | +) |
| 28 | + |
| 29 | +plugs = [my_plugin] |
| 30 | + |
| 31 | +manager = PlugManager(plugs) |
| 32 | +``` |
| 33 | + |
| 34 | +## Plugin config variables |
| 35 | + |
| 36 | +Each plugin will define their own config variables with some defaults, they can also pick the values from the environment variables if required. |
| 37 | +The order of precedence is as follows: |
| 38 | + |
| 39 | +- Environment variables |
| 40 | +- Configs defined in the `plug_config.py` |
| 41 | +- Default values defined in the plugin |
| 42 | + |
| 43 | + |
| 44 | +## Development |
| 45 | + |
| 46 | +To get started with developing a plugin, use [care-plugin-cookiecutter](https://github.com/coronasafe/care-plugin-cookiecutter) |
| 47 | +The plugin follows the structure of a typical django app where you can define your models, views, urls, etc. in the plugin folder. |
| 48 | +The plugin manager will automatically load the required configurations and plugin urls under `/api/plugin-name/`. |
| 49 | + |
| 50 | +To develop the plugins locally you can install the plugin in the editable mode using `pip install -e /path/to/plugin`. |
| 51 | + |
| 52 | +If you need to inherit the components from the core app, you can install care in editable mode in the plugin using `pip install -e /path/to/care`. |
| 53 | + |
| 54 | + |
| 55 | +## Available Plugins |
| 56 | + |
| 57 | +- [Care Scribe](https://github.com/coronasafe/care_scribe): Care Scribe is a plugin that provides autofill functionality for the care consultation forms. |
0 commit comments