# jpdante/corepluginloader architecture

> Architecture diagram of the GitHub repository jpdante/corepluginloader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jpdante/corepluginloader
- Repository: https://github.com/jpdante/corepluginloader

## Overview

##### Main Components
- Core Plugin Loader Library – This is the core .NET library (located in the CorePluginLoader folder) that implements the main API. It contains key classes such as PluginLoader and PluginLoaderBase.
- Host Application – This component (illustrated by the Examples/Basic/HostApplication project and the Testing/Host application in Testing/CorePluginLoader.Testing) demonstrates how a host uses the plugin loader. It contains the entry point (Program.cs) and the interface IPlugin, which defines the plugin contract.
- Plugin Projects – These are the dynamic libraries (e.g., Examples/Basic/Plugin and the Testing/CorePluginLoader.Testing.Plugin1/Plugin1.cs & Plugin2.cs) that implement the IPlugin interface. They illustrate how plugins are constructed and loaded.
- Testing Suite – A dedicated directory that not only includes plugin examples but also the test harness (found in Testing/CorePluginLoader.Testing) to verify the integration and behavior of the dynamic plugin loading mechanism.

##### Relationships and Interactions
- The Host Application component calls into the Core Plugin Loader Library, instantiating a PluginLoader for a given interface (IPlugin).
- The PluginLoader then dynamically loads plugin assemblies from specified directories (using, for example, Directory.GetFiles with a "*.dll" search).
- Loaded plugin instances (which conform to the IPlugin interface) then interact with the Host Application, typically by invoking their PluginName properties or other exposed methods.
- The Testing components mimic these interactions to ensure that different plugins (as demonstrated in Plugin1 and Plugin2) are correctly loaded and can interact within the same memory space as the Host.

##### Architectural Patterns and Design Principles
- Shared Memory Model – Note that the library is designed to allow shared memory between the Host and Plugins, as opposed to isolating them (this is a key design principle noted in the README). This enables plugins to interact and call methods across each other easily.
- Separation of Concerns – Although the host, plugin, and loader are part of the same solution architecture, each holds well-defined responsibilities (the Core Plugin Loader handles plugin resolution, the Host manages application logic, and the Plugins encapsulate the extendable functionality).

##### Recommend Technologies and Tools
- .NET Core – Highlight that the system is built using .NET Core.
- NuGet Package (CorePluginLoader) – Represent that developers can install the library via NuGet and integrate it into their projects.

##### Elements
- Clear labels for each component: “CorePluginLoader Library”, “Host Application”, “Plugin (Example/Basic)”, “Plugin (Testing/Plugin1 & Plugin2)”, and “Testing Suite”.
- If needed, include annotations that describe some specific methods or interactions (like the call to LoadPlugins and shared memory design).

## Diagram (Mermaid)

```mermaid
graph TB
    %% Runtime Environment
    subgraph "Runtime Environment"
        HOST["Host Application"]:::host
        Loader["CorePluginLoader Library"]:::loader
        PLUGINB["Basic Plugin"]:::plugin
        PLUGINT1["Testing Plugin1"]:::plugin
        PLUGINT2["Testing Plugin2"]:::plugin
    end

    %% Testing Environment
    subgraph "Testing Environment"
        TESTSUITE["Testing Suite"]:::testing
    end

    %% Connections between Runtime components
    HOST -->|"LoadPlugins"| Loader
    Loader -->|"loads"| PLUGINB
    Loader -->|"loads"| PLUGINT1
    Loader -->|"loads"| PLUGINT2

    %% Testing interactions
    TESTSUITE -->|"tests"| Loader
    TESTSUITE -->|"tests"| PLUGINT1
    TESTSUITE -->|"tests"| PLUGINT2

    %% Click Events
    click Loader "https://github.com/jpdante/corepluginloader/tree/master/CorePluginLoader/"
    click HOST "https://github.com/jpdante/corepluginloader/tree/master/Examples/Basic/HostApplication/"
    click PLUGINB "https://github.com/jpdante/corepluginloader/blob/master/Examples/Basic/Plugin/Plugin.cs"
    click PLUGINT1 "https://github.com/jpdante/corepluginloader/blob/master/Testing/CorePluginLoader.Testing.Plugin1/Plugin1.cs"
    click PLUGINT2 "https://github.com/jpdante/corepluginloader/blob/master/Testing/CorePluginLoader.Testing.Plugin2/Plugin2.cs"
    click TESTSUITE "https://github.com/jpdante/corepluginloader/tree/master/Testing/CorePluginLoader.Testing/"

    %% Styles
    classDef host fill:#A2D9CE,stroke:#000,stroke-width:1px;
    classDef loader fill:#AED6F1,stroke:#000,stroke-width:1px;
    classDef plugin fill:#F9E79F,stroke:#000,stroke-width:1px;
    classDef testing fill:#F5B7B1,stroke:#000,stroke-width:1px;
```
