In a Nutshell (🌰)
- SSM has a flexible plugin architecture for extending functionality
- Plugins can add new UI components, data models, and backend services
- The system uses a modular approach with clearly defined extension points
- Developers can create plugins with React and TypeScript
- Plugins are distributed as standalone modules that can be installed by users
Understanding SSM's Plugin Architecture
Squirrel Servers Manager (SSM) was designed with extensibility in mind. The plugin system allows developers to extend and enhance SSM's functionality without modifying the core codebase.
Plugin System Components
The plugin architecture consists of several key components that work together to provide a flexible extension mechanism:
Plugin Registry
The Plugin Registry is the central component that:
- Discovers and loads available plugins
- Manages plugin lifecycle (activation/deactivation)
- Provides access to plugin metadata
Extension Points
SSM offers several extension points where plugins can integrate:
UI Components
- Add new pages
API Extensions
- Add new API endpoints
Data Models
- Define new data structures
- Create custom storage solutions
Event Handlers
- Subscribe to system events
- Implement custom event processing
- Generate new events for other plugins
Plugin Structure
A typical SSM plugin consists of:
plugin-name/
├── manifest.json # Plugin metadata and configuration
├── package.json # Node.js package information
├── public/ # Static assets
│ └── icon.svg # Plugin icon displayed in the UI
└── src/
├── client/ # Frontend React components
│ └── index.tsx # Client-side entry point
└── index.ts # Server-side entry point
The Manifest File
The manifest.json file defines the plugin's metadata and extension points:
{
"id": "my-awesome-plugin",
"name": "My Awesome Plugin",
"version": "1.0.0",
"description": "Adds awesome functionality to SSM",
"author": "Your Name",
"license": "MIT",
"icon": "public/icon.svg",
"entrypoints": {
"client": "src/client/index.tsx",
"server": "src/index.ts"
},
"slots": [
{
"id": "dashboard-widget",
"component": "CustomDashboardWidget"
}
],
"routes": [
{
"path": "/plugins/awesome",
"component": "AwesomePluginPage",
"exact": true
}
]
}
Plugin Lifecycle
Installation
Plugins can be installed through several methods:
- From the Plugin Store in the SSM UI
- Manually by placing files in the plugins directory
- Via command line using npm or similar tools
Activation
When SSM starts up, it:
- Discovers installed plugins
- Validates plugin manifests
- Resolves dependencies between plugins
- Loads plugin code in the correct order
- Initializes plugin components and services
Execution
During runtime, plugins can:
- Render UI components in their allocated slots
- Process API requests through added endpoints
- Respond to system events
- Interact with other plugins through defined APIs
Deactivation
Plugins can be deactivated through the UI, which:
- Unregisters UI components
- Stops processing API requests
- Unsubscribes from events
- Releases allocated resources
Plugin Communication
Plugins can communicate with each other through several mechanisms:
Events
The event system allows plugins to:
- Publish events that other plugins can subscribe to
- React to events from the core system or other plugins
- Implement event-driven architecture patterns
Shared Services
Plugins can register and consume services through the plugin registry:
- Access core system services
- Implement dependency injection patterns
Data Storage
Plugins can store and share data using:
- Plugin-specific storage in the database
- Temporary caches for performance optimization
Plugin Development Workflow
- Setup: Create a new plugin using the plugin generator tool
- Develop: Implement your plugin functionality
- Test: Use the development environment to test your plugin
- Package: Build and package your plugin for distribution
- Publish: Share your plugin with the community
Security Considerations
When developing or installing plugins, consider these security aspects:
- Permissions: Plugins run with the same permissions as the SSM application
- Data Access: Plugins can access and modify system data
- Resource Usage: Poorly written plugins can impact system performance
- Code Review: Always review plugin code before installation in production environments