# Plugin Template A minimal plugin template for LeoCRM. Copy this directory to `app/plugins/builtins//` and customize. ## Quick Start 1. **Copy the template:** ```bash cp -r templates/plugin-template app/plugins/builtins/my_plugin ``` 2. **Rename the plugin class:** Edit `plugin.py` and rename `ExamplePlugin` to your plugin name. 3. **Update the manifest:** - Change `name`, `version`, `display_name`, `description` - Add your routes, events, migrations, permissions - Add UI contributions (menu items, page routes, etc.) 4. **Implement routes:** Edit `routes.py` with your API endpoints. 5. **Add database models:** Uncomment and customize `models.py`. 6. **Write migrations:** Add SQL migration files to `migrations/`. 7. **Write tests:** Add tests to `tests/test_plugin.py`. ## Directory Structure ``` templates/plugin-template/ ├── __init__.py # Package init ├── plugin.py # Plugin class with manifest (required) ├── routes.py # FastAPI route definitions ├── models.py # SQLAlchemy models (optional, commented out) ├── schemas.py # Pydantic schemas (optional) ├── services.py # Business logic (optional) ├── migrations/ # SQL migration files │ └── 0001_initial.sql ├── tests/ # Plugin tests │ ├── __init__.py │ └── test_plugin.py └── README.md # This file ``` ## Manifest Fields See `docs/plugin-development-guide.md` for a complete reference of all manifest fields. ## Key Points - All API routes must be secured with `require_permission` - Event handlers are named `on_` with dots replaced by underscores - Migration files run in alphanumeric order - UI component paths use the `@/` alias (resolved to `src/` by Vite) - i18n keys should be prefixed with the plugin name