Getting Started with Fast Pluggy
This guide will help you get started with Fast Pluggy in your FastAPI application.
Prerequisites
- Python 3.10 or higher
- FastAPI
- Basic knowledge of FastAPI applications
Installation
Install Fast Pluggy using pip:
Basic Setup
1. Import the necessary modules
2. Create your FastAPI application
app = FastAPI(
title="My FastAPI App with Plugins",
description="A FastAPI application with plugin support",
version="0.1.0"
)
3. Initialize Fast Pluggy
# Initialize with default settings
pluggy = FastPluggy(app)
# Or with custom settings
pluggy = FastPluggy(
app,
app_root_dir=".", # Root directory of your application
path_plugins="./plugins", # Directory where plugins are stored
path_modules="./domains" # Directory where domain modules are stored
)
4. Run your application
Complete Example
Here's a complete example of a FastAPI application with Fast Pluggy:
from fastapi import FastAPI
from fastpluggy import FastPluggy
# Create the FastAPI application
app = FastAPI(
title="My FastAPI App with Plugins",
description="A FastAPI application with plugin support",
version="0.1.0"
)
# Initialize Fast Pluggy
# The initialization process happens automatically in the constructor
pluggy = FastPluggy(
app,
app_root_dir=".", # Root directory of your application
path_plugins="./plugins", # Directory where plugins are stored
path_modules="./domains" # Directory where domain modules are stored
)
# Define your routes
@app.get("/")
def read_root():
return {"message": "Welcome to my FastAPI application with plugin support!"}
# Run the application
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
Try It With a Real Plugin
The examples above show a bare FastPluggy app with no plugins loaded. To see a real one in action:
Restart your application — no code changes needed. FastPluggy discovers
installed plugins automatically via the fastpluggy.plugins entry point
declared in the plugin's own pyproject.toml (see
Installing Plugins), so a plain pip install into
the same environment is enough.
You should see:
- A new "Example Plugin" entry in the main menu
- Its page at
/plugin-pkg/example_plugin/ - A puzzle-piece icon in the topbar opening a modal with links to its pages
The example plugin's source
is also the reference template for writing your own — its plugin.py shows menu
registration, a topbar action, a registered global, and routing, and its README
walks through copying it as a starting point.
Next Steps
- Learn how to install plugins
- Explore the configuration options
- Check out the API reference for more details