OutfitTool Modular System Architecture
This document describes the principles of interaction between the main application (host) and plug-in modules. The system is built on modularity, where functionality is extended through plug-in components (modules). Communication between the main application and modules occurs through a clearly defined API layer.
1. Main Components
-
Host: The application executable file (
OutfitTool.exe). Responsible for detecting, loading, and coordinating module operations. - API (Application Programming Interface): An intermediate layer in the form of libraries (DLLs) containing abstract classes and interfaces. Serves as a contract for interaction between the host and the module. Current API version — 1.
- Module: A dynamically loadable library (DLL) implementing business logic and inheriting interfaces of a specific API version.
💡 Important about versioning: The system is designed to allow smooth transitions between API versions. The host can work with modules supporting different interface versions thanks to an adaptation layer.
2. Module Loading Mechanism (Discovery & Loading)
The module initialization process occurs automatically when the host starts, following this algorithm:
-
Scanning: The host scans the
./modulesdirectory. Each subdirectory is treated as a potential module. -
Entry point: Inside the module directory (e.g.,
./modules/MailAgent/), the host looks for a file with the same name as the directory and.dllextension (e.g.,MailAgent.dll). This is the module's main assembly. -
Reflection (Assembly analysis): The host analyzes the found assembly for the presence of required types:
ModuleInfo: Provides module metadata (name, version, author, etc.).ModuleController: Implements module control points (initialization, startup, shutdown).
-
API version determination: The host determines which API version (
ApiVersion) the found classes correspond to (e.g., by checking implemented interfaces or assembly attributes). - Adaptation and loading: To ensure backward compatibility, the host creates an adapter layer. The adapter dynamically converts the host's control methods to an interface understandable by the module, allowing modules of different API versions to be used in a single host version without conflicts.
ℹ️ Note: If an error occurs at any stage (missing directory, DLL, or required classes), the module is skipped, and the host logs a warning and continues loading the remaining modules.
3. Module Requirements (Contract)
For successful interaction with the host, the module must strictly follow these rules:
- Be located in a separate subdirectory within
./modules. - The main assembly (DLL) must have a name identical to the directory name (e.g.,
MailAgent.dllinside theMailAgentfolder). - The assembly must contain public classes
ModuleInfoandModuleControllerimplementing interfaces of one of the supported API versions. - The module must not have hard dependencies (direct references) on the host executable file — only on API libraries.
Example Directory Structure
OutfitTool.exe
./modules/
MailAgent/
MailAgent.dll # Main assembly
API1.dll # API library version 1
MailAgent.pdb # Optional: debug file
MailKit.dll # Optional: additional module files
MimeKit.dll # Optional: additional module files
assets/ # Optional: module resources
ImageProcessor/
ImageProcessor.dll
API1.dll
ImageProcessor.deps.json
...
Example Minimal Module Code
namespace MailAgent
{
public class ModuleInfo : IModuleInfo
{
...
}
public class ModuleController : IModuleController
{
...
}
}
This approach ensures the stability of the main application, allows independent module updates, and provides system extensibility for many years to come.