Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔌 Python Plugin Framework

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.


✨ Features

  • 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

📚 Concepts Covered

Python

  • Decorators
  • Decorator Factory
  • Abstract Base Classes (ABC)
  • Type Hints
  • pathlib
  • importlib
  • Dictionary Comprehension
  • Reflection
  • Dynamic Import
  • kwargs / args

Software Design

  • Separation of Concerns
  • Single Responsibility Principle (SRP)
  • Open/Closed Principle (OCP)
  • Loose Coupling
  • High Cohesion
  • Registry Pattern
  • Factory Pattern
  • Plugin Architecture

📁 Project Structure

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

🚀 Getting Started

Clone the repository

git clone https://github.com/majidkhazaei/python-plugin-framework.git

Move into the project

cd plugin-framework

Run

python main.py

🧩 Creating a Plugin

from 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.


▶ Running Plugins

from core.manager import PluginManager

manager = PluginManager()

manager.load_plugins()

print(manager.run("hello"))

Output

Hello World!

📖 Documentation

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

🎯 Why This Project?

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

🛣 Future Improvements

Possible future features:

  • Plugin priorities
  • Plugin dependencies
  • Version management
  • Enable / Disable plugins
  • Lazy loading
  • CLI interface
  • Configuration files
  • Hook system
  • Better error handling

🤝 Contributing

Suggestions and improvements are always welcome.

Feel free to open an Issue or submit a Pull Request.


📄 License

This project is licensed under the MIT License.


⭐ If you found this useful...

Please consider giving the repository a ⭐.

It helps more people discover the project.

About

A lightweight plugin framework built with pure Python to demonstrate decorators, dynamic imports, registry pattern, and clean software architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages