Plugin system
Care is designed to be extended without forking the core. Functionality you do not want to maintain in the main codebase — a transcription service, a custom integration, a bespoke UI — ships as a plugin. There are two halves to the system:
- Backend plugs — Django apps loaded into the
careserver throughplug_config.pyor theADDITIONAL_PLUGSenvironment variable. - Frontend Care Apps — federated React bundles loaded into the
care_fehost at runtime.
A plugin can be backend-only, frontend-only, or both, depending on what it needs to do.
Backend plugs
A backend plugin is a regular Django app. What makes it a Care plugin is that it is
declared in plug_config.py using the Plug and PlugManager classes from the plugs
package, or in the ADDITIONAL_PLUGS environment variable. The default Care image ships
with no plugins enabled — plug_config.py declares an empty list — and you opt in by
overriding that file with your own or by setting ADDITIONAL_PLUGS.
from plugs.manager import PlugManager
from plugs.plug import Plug
my_plugin = Plug(
name="my_plugin",
package_name="git+https://github.com/octo/my_plugin.git",
version="@v1.0.0",
configs={
"SERVICE_API_KEY": "my_api_key",
"SERVICE_SECRET_KEY": "my_secret_key",
"VALUE_1_MAX": 10,
},
)
plugs = [my_plugin]
manager = PlugManager(plugs)
Each Plug points at a package_name (here a Git source) and a version, and carries a
configs dictionary that is passed to the plugin. name is the plugin's Django app name.
version defaults to @main and is appended to package_name when the plug is installed.
ADDITIONAL_PLUGS takes a JSON list of plug objects with the same fields, and the PlugManager
adds them to the plugs declared in plug_config.py. If the value is not valid JSON, Care logs an
error and ignores it.
The backend plug, extension and device-type machinery is the same in Care 3.0 and 3.1.
Load timing: build vs runtime
Plugins are installed while the Docker image is being built. install_plugins.py
pip-installs every declared plug, and the production and development Dockerfiles run it with
ADDITIONAL_PLUGS passed as a build argument. No start script installs plugs when a container
starts, so the plugin and its dependencies are baked into the image and containers start with a
known, reproducible set of plugins.
The plug list is read again at runtime: when Django starts, every plug is added to
INSTALLED_APPS and its configs go into PLUGIN_CONFIGS.
In the production Dockerfile, ADDITIONAL_PLUGS is set only in the builder stage, and the
runtime stage does not carry it. A plug given only as a build argument is installed, but it is not
added to Django or mounted. Also set ADDITIONAL_PLUGS on the running backend container, or list
the plug in plug_config.py.
For the deployment steps, see Install apps.
Config precedence
Every plugin defines its own configuration variables, usually with sensible defaults, and may read values from the environment. When the same value is set in more than one place, the plugin resolves it in this order (highest priority first):
- Values in the plug's
configsdictionary (inplug_config.pyorADDITIONAL_PLUGS). - Environment variables.
- Default values defined inside the plugin.
So the configs dictionary always wins, environment variables fill the gaps, and the plugin's
own defaults are the fallback. Core Care only passes each plug's configs to Django settings as
PLUGIN_CONFIGS; each plugin applies this order in its own code.
URL mounting
The PlugManager automatically wires up each plugin's configuration and mounts its URLs
under /api/<plugin-name>/. A plugin named my_plugin therefore exposes its routes under
/api/my_plugin/.
Permissions and roles
A plug can add permissions with PermissionController.register_permission_handler and roles
with RoleController.register_role.
Registering them is not enough on its own. Permissions, roles and the role-permission mapping
reach the database only through python manage.py sync_permissions_roles, which should run after
every deployment and every plug change. The shipped Celery beat script (scripts/celery_beat.sh)
runs it on start.
Once synced, a plug permission is listed in the admin role editor like a core permission, because that list is read from the table that the sync fills.
For example, care_filly registers the facility permission "Can Use Filly" at import time, and
gives it to default roles that include Doctor, Nurse, Staff, Facility Admin and Administrator.
Device types
A plug adds a device type by registering a device class under a type name with
DeviceTypeRegistry.register(device_type, device_class). Registering a name again replaces the
earlier class.
When a device is created, its care_type is checked against this registry, and an unregistered
type fails with "Invalid Device Type".
Core registers a placeholder camera type, SomeCameraPlugin, which returns sample data
({"Hello": "There"}) and is not a working camera. The care_teleicu_devices plug registers its
own camera type, which replaces the placeholder when installed.
A Care App supplies the matching frontend through the manifest's devices field. Each entry is
keyed by type, which matches the device's care_type, and can supply the device type icon, the
configure form, a card on the device page and a panel in the encounter overview.
Extension fields
Nine resources accept extension fields: account, encounter, patient,
payment_reconciliation, supply_delivery, supply_delivery_order, product,
resource_request and facility. Each stores its values in an extensions JSON field.
A deployment defines fields without code, through the CORE_EXTENSIONS_<RESOURCE>_<ACTION>
environment variables that Care's core extension reads. A plug adds its own fields by subclassing
PlugExtension and registering it with ExtensionRegistry.register, which requires a resource
type and an extension name. PlugExtension does no validation unless the plug overrides
validate.
Values are stored per extension name, as extensions.core.<field> and
extensions.<extension name>.<field>. Top-level keys that match no registered extension are
dropped without an error.
GET /api/v1/extensions/ returns, for each resource, every registered extension with its name,
owner, version and write, read and retrieve schemas. It is read-only, and any signed-in user can
call it. The frontend knows seven of the nine resources (not facility or resource_request),
shows fields for five of them (no screen shows encounter or product fields), and keeps the
schemas for 24 hours.
For the environment variables, the x-ui rendering hints and where the fields appear, see
Define extension fields.
Scaffolding a new plug
A backend plugin follows the structure of a typical Django app — you define your models, views, and URLs inside the plugin folder. To start from a working skeleton, use the care-plugin-cookiecutter template rather than wiring everything up by hand.
Local development
For local work, install the plugin in editable mode so your source edits are picked up without reinstalling:
pip install -e /path/to/plugin
If the plugin needs to inherit components from the core app, install Care itself in editable mode from inside the plugin:
pip install -e /path/to/care
Set up the Care backend first — see Backend local setup for getting the server running before you attach a plugin to it.
Frontend Care Apps
On the frontend, a plugin is called a Care App: a separately built React bundle that the
care_fe host loads at runtime through Vite module federation. The host app is the federation
core and shares key dependencies — react, react-dom, react-i18next,
@tanstack/react-query, @tanstack/react-router, sonner, decimal.js — so a plugin reuses the
host's single copy of each rather
than bundling its own. Each Care App exposes a ./manifest (from src/manifest.tsx) that
declares what it contributes, listed in the table below; src/pluginTypes.ts in
care_fe is the source of truth for that manifest contract.
Care 3.1 shares @tanstack/react-router, so there is one router instance and apps read the host
router's context. raviger is not shared.
The manifest
| Field | What it contributes |
|---|---|
plugin | The app's plugin name. |
routes | App pages, attached to the router under the signed-in layout. |
components | Components for the named slots that host screens render with PLUGIN_Component. |
navItems | Facility sidebar items, added at the end after Settings. |
billingNavItems | Items under Billing, after Accounts, Invoices and Payments. |
userNavItems | Items in the user menu. |
adminNavItems | Items at the end of the admin sidebar. |
organizationTabs | Tabs on organization pages; their pages are attached to the router with the app's routes. |
encounterTabs | Encounter tabs, also offered in the workspace editor and the encounter command menu. |
encounterWidgets | Encounter workspace widgets. New in 3.1. |
encounterFileTabs | Sub-tabs in the encounter Files tab. |
devices | Frontend for a device type: icon, configure form, device page card and encounter overview panel. |
overrides | Replacements for components that are registered for override. |
registeredQuestionGroups | Question groups for questionnaires. New in 3.1. |
extends | Declared ("DoctorConnectButtons" or "PatientExternalRegistration") but never read. |
Each slot renders the component from every loaded app that provides it, each inside its own error
boundary, so one app's crash does not take down the screen. Nothing renders when no app provides
the slot. The slot names are the keys of SupportedPluginComponents in src/pluginTypes.ts;
DoctorConnectButtons is declared there, but no screen renders it.
Workspace widgets and question groups
encounterWidgets and registeredQuestionGroups are new in Care 3.1.
encounterWidgetsadds widgets to the encounter workspace. The workspace studio offers them under "From apps", with the description "A widget provided by an app. Its settings are defined by the app."registeredQuestionGroupsadds question groups. When the app loads, the host registers each one into the questionnaire group registry (registerQuestionGroupinsrc/components/QuestionnaireV2/groups/registry.ts).
Content in the EncounterOverviewTop slot can also be placed in a workspace as the widget "App
overview content" (type encounter_extensions). When no installed app provides it, the widget
says "Hidden because no installed app adds content here".
The Scribe slot
The Scribe slot changed in Care 3.1. It now receives actions (an ActionDescriptor[]) and
invoke(actionId, input), which returns a Promise<ActionRunResult>. In 3.0 it received
formState and setFormState. The comment on the type in src/pluginTypes.ts says that changing
this shape requires a lockstep update in care_scribe.
The host renders the slot on the questionnaire fill page and passes it that page's actions.
How Care Apps are discovered
The host resolves its effective plugin set from two sources and merges them:
| Source | Where it comes from | Behavior |
|---|---|---|
| Built-in | REACT_ENABLED_APPS env var, parsed into careConfig.careApps; set at build time, or replaced after the build through /runtime-env.js | Always enabled, read-only in the admin UI; the slug is the repository name |
| API | GET /api/v1/plug_config/; rows written by the App Store's Install button or the Manual setup form in Admin Dashboard > Apps | Editable in the admin UI |
Built-in entries act as the base set, so they load even if the backend returns no matching
plug_config row. When both sources define the same plugin, the built-in entry wins for
overlapping metadata and non-conflicting API metadata is preserved. Each REACT_ENABLED_APPS
entry takes the form org/repo, org/repo@host/path/to/remoteEntry.js or
org/repo@/path/to/remoteEntry.js; when the host/path
is omitted, Care defaults to GitHub Pages at https://{org}.github.io/{repo}.
A path that starts with / is relative to the Care frontend's own origin. For a host, Care adds
the scheme: http when the host contains localhost, https otherwise. Entries are
comma-separated. An invalid entry is logged and left out, and the frontend does not start if
validation fails.
A built-in app's slug is its repository name (for example care_filly_fe), while an App Store
install uses the App Store id (for example care-filly). Because the slugs differ, the App Store
still offers Install for an app that is already built in, and installing it creates a second
entry.
For each resolved plugin, the host validates the remote URL, registers the remote with Vite
federation under the plugin's slug, loads its ./manifest, and exposes the loaded manifests
through CareAppsContext. If a remote is missing or fails to load, that plugin is logged and
skipped — the rest of the app and other plugins keep working. A config with no meta.url is
skipped with a console error, and a 401 or 403 from plug_config is ignored silently.
The App Store
In Care 3.1 the App Store (Admin Dashboard > Apps) reads its catalog from REACT_APP_STORE_API_URL, whose
shipped default is https://experience.ohc.network/api/plugins/. The browser fetches the catalog
directly; the Care backend is not involved. An empty value turns the catalog off. Like
REACT_ENABLED_APPS, the value can be replaced after the build through /runtime-env.js.
Care 3.0 used a different setting, REACT_APP_STORE_INDEX_URL, which pointed at the
care_apps_registry index. Care 3.1 does not read care_apps_registry.
Install writes a plug_config row: the slug is the App Store id, and the meta holds url,
name, plug and config from the app's frontend entry. If the app lists a backend health check
(for example /api/care_filly/healthz), the browser first calls it on the Care API, so the app's
backend plug must be installed and reachable, CORS included.
Writing plug_config rows needs a Django is_staff account, but listing and reading them needs no
sign-in, so everything in a plug config's meta is public. Do not put secrets in an app's config.
App Store entries carry care_version and branch, but the frontend ignores both, so Care does
not filter or warn by Care version. Make sure the remote URL in your entry serves a build made for
Care 3.1.
For installing apps on a deployment, see Install apps.
Local development
The recommended way to develop a Care App is in-tree: drop or symlink your plugin checkout
into the host's apps/ directory so its manifest lives at apps/<slug>/src/manifest.tsx, then
run the host dev server:
npm run dev
The host's localPluginDevSupport() (in vite.config.mts) auto-discovers every
apps/*/src/manifest.tsx, wires each plugin directly into the host's own Vite module graph,
and serves its static assets — no separate build, no vite preview, and no REACT_ENABLED_APPS
entry needed. Editing plugin source hot-reloads through the host; adding or removing a manifest
triggers a full reload. Because dependencies are shared and deduplicated, you avoid duplicate
React copies and the hook-order errors they cause.
In-tree loading exists only in the dev server; production builds include none of the apps under
apps/.
When you need to exercise the real federated remoteEntry.js loading path (for example, to test
the production flow), run the plugin standalone as a remote and point the host at it through
REACT_ENABLED_APPS. In this mode there is no automatic HMR back to the host — the host only
reloads after a plugin rebuild produces a fresh remoteEntry.js.
To reuse a host component inside a plugin, care_fe ships a clone-component CLI
(scripts/clone-component.ts, npm run clone-component) that copies a component and every
local file it transitively imports into your plugin's src/ tree, rewriting host path aliases
as it goes. Cloned files are independent copies and do not stay in sync with the host.
Override architecture
Care Apps can change host UI without the host code knowing about them, through an override system. The mental model: instead of a component rendering itself, it asks the system what it should be and renders that.
- Components opt in by wrapping their export with
register("ComponentName", Component). Usage does not change — call sites still render the component normally. In Care 3.1, core code registers two components this way:PrintInvoiceandPaymentReconciliationSheet. - Any other exported component can be made overridable only at build time, by listing it in
REACT_MFE_REGISTERED_COMPONENTS: a comma-separated list of component names, or*for every exported component. Empty or unset registers none. This setting cannot be changed through/runtime-env.js. - The host computes a resolution map once and serves most lookups from it, keeping per-component resolution close to O(1). Overrides can be context-aware (page, role, position in the render tree), with a slower stack-aware path reserved for the rare cases that need it.
- A plugin registers its overrides through its manifest, letting it inject or replace behavior without breaking existing call sites.
The override design note in care_fe (docs/care-apps-override-architecture.md) is a
design-intent document. The authoritative, shipped implementation lives in
care_fe/src/lib/override/ (register.ts, registry.ts, bridge.ts, types.ts); where the
note and the code disagree, the code wins.
Example plugin
Care Scribe is a published plugin with a backend
repository and a frontend repository (care_scribe_fe).
Its frontend was written for the 3.0 Scribe slot on the questionnaire fill page.
On 29 November 2026 the Care Scribe frontend still used the 3.0 Scribe props (formState,
setFormState). It does not yet match the 3.1 contract described above, so do not copy its
Scribe integration into a 3.1 plugin.