Plugin System Guide
This guide explains how to extend Business M by creating and integrating new domain plugins.
1. Backend Plugin Structure
Section titled β1. Backend Plugin StructureβA backend plugin is a standard Framework M App defined as a library.
Folder Structure
Section titled βFolder Structureβlibs/my_plugin/βββ src/β βββ my_plugin/β βββ __init__.py # App definitionβ βββ doctypes/ # Domain entitiesβ βββ services/ # Business logicβ βββ bootstrap.py # DI wiring & extensionsβββ pyproject.tomlβββ README.mdEntry Point
Section titled βEntry PointβIn pyproject.toml, register the app and optional bootstrap/container:
[project.entry-points."framework_m.apps"]my_plugin = "my_plugin:app"
[project.entry-points."framework_m.bootstrap"]my_plugin_init = "my_plugin.bootstrap:MyPluginBootstrap"2. Extending Core DocTypes
Section titled β2. Extending Core DocTypesβUse the Bounded Context pattern. Instead of adding fields directly to core Item, create a MyPluginItem in your library:
class MyPluginItem(BaseDocType): item: str = Field(description="Link to core Item") special_field: str = Field(...)
class Meta: table_name = "my_plugin_item"3. Frontend Plugin Structure
Section titled β3. Frontend Plugin StructureβFrontend plugins are integrated into the Desk UI at build-time.
Folder Structure
Section titled βFolder Structureβlibs/my_plugin/frontend/βββ src/β βββ pages/β βββ components/β βββ plugin.config.ts # Plugin Manifestβββ package.jsonβββ vite.config.tsManifest (plugin.config.ts)
Section titled βManifest (plugin.config.ts)βThe manifest defines how your plugin integrates into the UI:
import type { FrameworkMPlugin } from "@framework-m/plugin-sdk";
const plugin: FrameworkMPlugin = { name: "my_plugin", version: "0.1.0",
manifests: [ { app_id: "my_plugin", label: "My Plugin", icon: "box", resources: [ { name: "my_plugin.dashboard", label: "Dashboard", route: "/my-plugin/dashboard", } ] } ],
routes: [ { path: "/my-plugin/dashboard", element: () => import("./pages/Dashboard"), } ]};
export default plugin;4. Integration into Business M
Section titled β4. Integration into Business MβTo enable your plugin in the main application:
Backend Integration
Section titled βBackend IntegrationβAdd the library to apps/business-m/pyproject.toml or install it in the environment.
cd apps/business-muv add --path ../../libs/my_pluginFrontend Integration
Section titled βFrontend IntegrationβAdd the plugin path to apps/business-m/frontend/plugin.config.ts (or the discovery configuration).
Ensure the library is linked via pnpm:
cd apps/business-m/frontendpnpm add ../../../libs/my_plugin/frontend5. Development Tips
Section titled β5. Development Tipsβ- Namespacing: Always prefix your DocTypes and menu items to avoid collisions (e.g.,
my_plugin.settings). - Isolation: Use
m_protocolsto communicate with other libraries. Avoid direct imports of other domain logic. - Seeding: Use
m seedto populate initial data required by your plugin.