Plugin Architecture Overview
Plugins in Invenicum consist of:- STAC UI Definition: Declarative UI components defined in JSON
- Plugin Manifest: Metadata about your plugin (name, version, author, etc.)
- SDK Actions: JavaScript-like calls to Invenicum’s native functionality
- UI Slots: Predefined locations where plugins can render
How Plugins Work
- Plugin UI is defined using STAC (Simple Template for App Components)
- Plugins are loaded dynamically from GitHub or local storage
- The
InvenicumSdkParserhandles SDK function calls from plugins - Plugins render in designated UI slots throughout the app
Getting Started
Set Up Your Development Environment
You’ll need:
- A GitHub account (for publishing)
- A text editor or IDE
- Basic knowledge of JSON and Flutter concepts
- A local Invenicum instance for testing
Understand the STAC Framework
STAC allows you to build UIs declaratively using JSON. Here’s a simple example:Learn more about STAC at pub.dev/packages/stac.
Plugin Manifest
Every plugin requires these fields in its manifest:| Field | Type | Required | Description |
|---|---|---|---|
id | String | Yes | Unique identifier for your plugin |
name | String | Yes | Display name |
version | String | Yes | Semantic version (e.g., “1.0.0”) |
author | String | Yes | Your GitHub username |
description | String | Yes | Brief description (max 200 chars) |
slot | String | Yes | Where the plugin renders (see UI Slots) |
ui | Object | Yes | STAC UI definition |
authorAvatar | String | No | URL to author avatar image |
isPublic | Boolean | No | Whether plugin is publicly available (default: false) |
Example Manifest
UI Slots
Plugins can render in various locations throughout the Invenicum app:| Slot Name | Location | Use Case |
|---|---|---|
dashboard_top | Top of dashboard | Summary widgets, important alerts |
dashboard_bottom | Bottom of dashboard | Charts, recent activity |
asset_detail_top | Top of asset detail page | Custom asset actions |
asset_detail_bottom | Bottom of asset detail page | Additional asset information |
sidebar | App sidebar | Quick actions, navigation |
Invenicum SDK Functions
The SDK allows plugins to interact with Invenicum’s core functionality. SDK calls are made through theInvenicumSdkParser (see lib/core/utils/sdk_plugin_parser.dart:21).
Available SDK Methods
getUserName()
Get the current user’s name.
STAC Action Example:
sdk_plugin_parser.dart:42):
showAlert(message)
Display a success toast message to the user.
Parameters:
message(String): The message to display
sdk_plugin_parser.dart:47):
navigate(path)
Navigate to a specific route in the app.
Parameters:
path(String): The route path to navigate to
sdk_plugin_parser.dart:51):
logout()
Log out the current user.
STAC Action Example:
sdk_plugin_parser.dart:59):
Using SDK Functions in Your Plugin
Here’s a complete example of a button that calls an SDK function:Building Your First Plugin
Let’s create a simple “Quick Actions” plugin for the dashboard.Test Locally
To test your plugin locally:
- Start your Invenicum instance
- Go to Settings > Plugins > Developer Mode
- Upload your
quick-actions.jsonfile - The plugin will appear in the dashboard
Advanced Plugin Examples
Interactive Counter Plugin
A plugin with state management:User Greeting Plugin
A plugin that displays user information:Plugin Service API
ThePluginService (from lib/data/services/plugin_service.dart:22) provides methods for plugin management:
Key Methods
Install a Plugin
Toggle Plugin Active State
Get Installed Plugins
Get Community Plugins
Plugin Model Structure
Plugins are represented by theStorePlugin model (from lib/data/models/store_plugin_model.dart:1):
Testing Your Plugin
Local Testing
- Developer Mode: Enable developer mode in plugin settings
- Upload: Upload your plugin JSON file
- Verify: Check that it appears in the correct slot
- Test Actions: Click buttons and verify SDK calls work
- Check Console: Look for debug messages in Flutter DevTools
Testing Checklist
- Plugin loads without errors
- UI renders correctly in the target slot
- All SDK function calls work as expected
- Plugin doesn’t crash the app
- Manifest data is accurate
- Version number follows semantic versioning
- Plugin works on multiple screen sizes
Publishing to Marketplace
Prepare for Release
- Test thoroughly
- Write clear documentation
- Add screenshots (optional)
- Ensure manifest is complete
Create GitHub Repository
- Create a new public repository
- Add your plugin JSON file
- Include a README with usage instructions
- Add a LICENSE file
Create a Release
- Go to Releases in your GitHub repo
- Click “Create a new release”
- Tag version (e.g.,
v1.0.0) matching your plugin version - Write release notes
- Publish release
Best Practices
Keep It Simple
Keep It Simple
Plugins should do one thing well. Don’t try to cram too much functionality into a single plugin.
Follow Naming Conventions
Follow Naming Conventions
- Use descriptive, unique plugin IDs
- Follow semantic versioning (MAJOR.MINOR.PATCH)
- Keep names under 50 characters
Optimize Performance
Optimize Performance
- Keep UI hierarchies shallow
- Avoid excessive nesting
- Don’t make plugins too large
Provide Good UX
Provide Good UX
- Use clear, actionable button labels
- Provide feedback for user actions
- Handle errors gracefully
Document Your Plugin
Document Your Plugin
- Write a clear description
- Include usage instructions in your GitHub README
- Add comments explaining complex logic
Troubleshooting
Plugin Doesn’t Load
- Verify JSON is valid (use a JSON validator)
- Check that all required manifest fields are present
- Ensure the
slotvalue is valid
SDK Functions Don’t Work
- Verify the
typeis set to"invenicum_sdk" - Check that the
methodname is correct (case-sensitive) - Ensure
paramsis an object, not an array
UI Doesn’t Render Correctly
- Check STAC documentation for proper widget structure
- Verify property names match STAC specifications
- Test with simpler UI first, then add complexity
Next Steps
Template Creation
Learn how to create custom asset templates
Contributing Guide
Contribute to Invenicum core development
