A lightweight and educational plugin framework built with pure Python.
This project demonstrates how to build a simple yet extensible plugin system using modern Python features and software architecture principles.
Educational project focused on understanding plugin architecture, decorators, dynamic imports, and clean software design.
- Automatic plugin registration using decorators
- Plugin metadata support
- Dynamic plugin discovery
- Automatic plugin loading
- Registry Pattern
- Factory Pattern
- Plugin Architecture
- Clean and extensible design
- Type hints
- Minimal and dependency-free
- Decorators
- Decorator Factory
- Abstract Base Classes (ABC)
- Type Hints
- pathlib
- importlib
- Dictionary Comprehension
- Reflection
- Dynamic Import
- kwargs / args
- Separation of Concerns
- Single Responsibility Principle (SRP)
- Open/Closed Principle (OCP)
- Loose Coupling
- High Cohesion
- Registry Pattern
- Factory Pattern
- Plugin Architecture
plugin-framework/
├── core/
│ ├── decorator.py
│ ├── manager.py
│ └── plugin.py
│
├── plugins/
│ ├── hello.py
│ └── time_plugin.py
│
├── docs/
│ └── Plugin Framework Guide (Persian).md
│
├── main.py
├── README.md
├── LICENSE
└── .gitignore
Clone the repository
git clone https://github.com/majidkhazaei/python-plugin-framework.gitMove into the project
cd plugin-frameworkRun
python main.pyfrom core.plugin import Plugin
from core.decorator import plugin
@plugin(
name="hello",
version="1.0",
author="Majid"
)
class HelloPlugin(Plugin):
def run(self):
return "Hello World!"That's it.
The plugin will be automatically discovered and registered.
from core.manager import PluginManager
manager = PluginManager()
manager.load_plugins()
print(manager.run("hello"))Output
Hello World!
A complete step-by-step guide (in Persian) is included inside the docs/ directory.
Topics include:
- Building decorators from scratch
- Decorator Factory
- Registry Pattern
- Dynamic Import
- Plugin Architecture
- SOLID principles
- Design Patterns
- Internal project architecture
The purpose of this repository is educational.
Instead of only explaining design patterns theoretically, this project demonstrates how they work together in a real implementation.
It is intended for developers who want to better understand:
- Python internals
- Clean Architecture
- Plugin systems
- Software design
Possible future features:
- Plugin priorities
- Plugin dependencies
- Version management
- Enable / Disable plugins
- Lazy loading
- CLI interface
- Configuration files
- Hook system
- Better error handling
Suggestions and improvements are always welcome.
Feel free to open an Issue or submit a Pull Request.
This project is licensed under the MIT License.
Please consider giving the repository a ⭐.
It helps more people discover the project.