API Reference
Protocols
Section titled âProtocolsâAdminContributorProtocol
Section titled âAdminContributorProtocolâContract for packages that contribute admin dashboard surfaces.
Any lexigram extension package can implement this protocol and register
it via the lexigram.admin.contributors entry point. The admin
dashboard discovers contributors at boot and assembles their widgets,
pages, navigation, and actions into the unified admin UI.
Unique contributor identifier (e.g. âcacheâ, âeventsâ, âaiâ).
Human-readable contributor name for the admin UI.
Navigation group this contributor belongs to.
Lucide icon name for the contributor.
Ordering priority within its group (lower = first).
Semantic version of this contributor (e.g. â1.2.3â).
Python package name that provides this contributor (e.g. âlexigram-cacheâ).
Stable unique identifier used for lookup and RBAC keying (equals name).
Permissions a user must hold to execute any action on this contributor.
Return widget definitions for the main dashboard.
Return navigation entries for the admin sidebar.
Return full management page definitions.
Return settings panel definitions.
Return health check definitions to surface in the dashboard.
Return framework-level actions.
async def on_admin_boot(container: ContainerResolverProtocol) -> None
Called when the admin dashboard boots.
Called when the admin dashboard shuts down.
Execute a named action on this contributor.
| Parameter | Type | Description |
|---|---|---|
| `action_name` | str | Name of the action to execute. |
| `params` | dict[str, object] | Keyword arguments forwarded to the action handler. |
| Type | Description |
|---|---|
| object | Whatever the action handler returns. |
async def render_widget( widget_name: str, params: WidgetParams ) -> Result[str, AdminError]
Render a named widget to an HTML fragment.
| Parameter | Type | Description |
|---|---|---|
| `widget_name` | str | Name of the widget to render. |
| `params` | WidgetParams | Typed, validated widget parameters. |
| Type | Description |
|---|---|
| Result[str, AdminError] | Ok(html_str) on success. Err(WidgetNotFoundError) when the widget name is unknown. Err(AdminError) for other expected domain failures. Infrastructure exceptions propagate (not caught here). |
async def render_health_check(check_name: str) -> Result[str, AdminError]
Render HTML result for a health check.
| Parameter | Type | Description |
|---|---|---|
| `check_name` | str | Name of the health check to run (matches check ID from ``get_health_definitions``). |
| Type | Description |
|---|---|
| Result[str, AdminError] | ``Ok(html_string)`` with health check result on success. ``Err(HealthCheckNotFoundError)`` if *check_name* is not served by this contributor. ``Err(AdminError)`` if the check fails for any other reason. |
AdminContributorRegistryProtocol
Section titled âAdminContributorRegistryProtocolâRegistry that collects and manages admin contributors.
def register(contributor: AdminContributorProtocol) -> None
Register a contributor.
def get(name: str) -> AdminContributorProtocol | None
Get contributor by name.
def get_all() -> Sequence[AdminContributorProtocol]
Get all registered contributors, ordered by priority.
def get_by_group(group: str) -> Sequence[AdminContributorProtocol]
Get contributors in a specific group.
AdminDashboardProtocol
Section titled âAdminDashboardProtocolâProtocol for the assembled admin dashboard service.
Collect widgets from all contributors.
Collect navigation from all contributors.
Aggregate health from all contributors.
async def execute_action( contributor_id: str, action_name: str, params: dict[str, object], user_permissions: frozenset[str] ) -> object
Execute a framework-level action from a contributor.
| Parameter | Type | Description |
|---|---|---|
| `contributor_id` | str | Identifier of the target contributor. |
| `action_name` | str | Name of the action to execute. |
| `params` | dict[str, object] | Parameters forwarded to the action handler. |
| `user_permissions` | frozenset[str] | Permissions held by the requesting user. |
| Type | Description |
|---|---|
| object | Whatever the action handler returns. |
Classes
Section titled âClassesâAdminBundleProvider
Section titled âAdminBundleProviderâOrchestrates admin sub-providers for the full admin panel.
Sub-providers are focused helper classes (not Provider subclasses). This follows the EventsProvider/AuthBundleProvider pattern.
Config is accepted only in init and never mutated after construction. Sub-providers are instantiated in register() â not in init â so that no DI work happens before the container is ready.
def __init__( config: AdminConfig | None = None, auth_provider: Any | None = None, resources: list[type] | None = None, controllers: list[type] | None = None, **kwargs: Any ) -> None
Return current admin config.
Create provider from typed config.
async def register(container: ContainerRegistrarProtocol) -> None
Register admin and all sub-providers.
Sub-providers are instantiated here (not in init) so that no DI resolution or heavyweight initialisation happens before the container lifecycle has started. No resolution is performed in this method â only bindings are registered.
async def mount_to_app( app: Any, container: ContainerResolverProtocol ) -> None
Build and mount the admin panel onto a Starlette application.
Called by the web provider during route setup, after the Starlette app is created and all providers have booted.
| Parameter | Type | Description |
|---|---|---|
| `app` | Any | The Starlette application to mount the admin panel on. |
| `container` | ContainerResolverProtocol | The DI resolver for resolving controller dependencies. |
async def boot(container: ContainerResolverProtocol) -> None
Boot all sub-providers in order.
Shut down sub-providers in reverse order.
Aggregate health from all sub-providers.
AdminModule
Section titled âAdminModuleâLexigram admin panel module.
Call configure to register the admin panel with its bundle provider and contributor system.
Usage
from lexigram.admin.config import AdminConfig
app.add_modules([ AdminModule.configure( config=AdminConfig(title="My Admin"), resources=[UserResource, ProductResource], ),])def configure( cls, config: Any | None = None, auth_provider: Any | None = None, resources: list[type] | None = None, controllers: list[type] | None = None, **kwargs: Any ) -> DynamicModule
Create an AdminModule with explicit configuration.
| Parameter | Type | Description |
|---|---|---|
| `config` | Any | None | AdminConfig or None for defaults. |
| `auth_provider` | Any | None | Optional AuthProviderProtocol for auth integration. |
| `resources` | list[type] | None | List of Resource classes to register. |
| `controllers` | list[type] | None | List of controller classes to register. **kwargs: Forwarded to AdminBundleProvider. |
| Type | Description |
|---|---|
| DynamicModule | A DynamicModule descriptor. |
def stub(cls) -> DynamicModule
Return a no-op AdminModule for testing.
| Type | Description |
|---|---|
| DynamicModule | A DynamicModule with default admin configuration. |
AdminPanelStartedHook
Section titled âAdminPanelStartedHookâPayload fired after the admin panel has finished its startup sequence.
AdminPanelStoppedHook
Section titled âAdminPanelStoppedHookâPayload fired after an orderly admin panel shutdown completes.
AdminProvider
Section titled âAdminProviderâOrchestrates admin sub-providers for the full admin panel.
Sub-providers are focused helper classes (not Provider subclasses). This follows the EventsProvider/AuthBundleProvider pattern.
Config is accepted only in init and never mutated after construction. Sub-providers are instantiated in register() â not in init â so that no DI work happens before the container is ready.
def __init__( config: AdminConfig | None = None, auth_provider: Any | None = None, resources: list[type] | None = None, controllers: list[type] | None = None, **kwargs: Any ) -> None
Return current admin config.
Create provider from typed config.
async def register(container: ContainerRegistrarProtocol) -> None
Register admin and all sub-providers.
Sub-providers are instantiated here (not in init) so that no DI resolution or heavyweight initialisation happens before the container lifecycle has started. No resolution is performed in this method â only bindings are registered.
async def mount_to_app( app: Any, container: ContainerResolverProtocol ) -> None
Build and mount the admin panel onto a Starlette application.
Called by the web provider during route setup, after the Starlette app is created and all providers have booted.
| Parameter | Type | Description |
|---|---|---|
| `app` | Any | The Starlette application to mount the admin panel on. |
| `container` | ContainerResolverProtocol | The DI resolver for resolving controller dependencies. |
async def boot(container: ContainerResolverProtocol) -> None
Boot all sub-providers in order.
Shut down sub-providers in reverse order.
Aggregate health from all sub-providers.
AdminResourceAccessedHook
Section titled âAdminResourceAccessedHookâPayload fired when an admin resource page is accessed.
Attributes:
resource_name: Registered name of the admin resource (e.g. "User").
action: CRUD action being performed (e.g. "list", "change").
user_id: Identifier of the admin user performing the action.
AdminStatus
Section titled âAdminStatusâStatus of admin operations.
AdminUser
Section titled âAdminUserâAdmin user representation.
BaseAdminContributor
Section titled âBaseAdminContributorâConvenience base class for admin contributors.
Provides no-op defaults for all AdminContributorProtocol methods.
Subclasses override only the methods they need.
Stable identifier for RBAC lookup â equals name.
Return an empty list by default.
Return an empty list by default.
Return an empty list by default.
Return an empty list by default.
Return an empty list by default.
Return an empty list by default.
async def on_admin_boot(container: ContainerResolverProtocol) -> None
No-op boot hook.
No-op shutdown hook.
Execute a named action by dispatching to its registered handler path.
Looks up action_name in the list returned by get_actions,
imports the module:func handler, and calls it with **params.
| Parameter | Type | Description |
|---|---|---|
| `action_name` | str | Name of the action to execute. |
| `params` | dict[str, object] | Parameters forwarded to the handler. |
| Type | Description |
|---|---|
| object | Whatever the handler returns. |
| Exception | Description |
|---|---|
| ValueError | If *action_name* is not registered on this contributor. |
async def render_widget( widget_name: str, params: WidgetParams ) -> Result[str, AdminError]
Return a not-found error by default â override in subclasses.
async def render_health_check(check_name: str) -> Result[str, AdminError]
Default: this contributor does not serve the requested health check.
| Parameter | Type | Description |
|---|---|---|
| `check_name` | str | Name of the health check requested. |
| Type | Description |
|---|---|
| Result[str, AdminError] | ``Err(HealthCheckNotFoundError)`` â contributor does not provide this check. |
ContributorRegistry
Section titled âContributorRegistryâRegistry that collects and manages admin contributors.
Follows the Registry pattern (AGENTS.md §6.3): empty __init__,
with_defaults() classmethod for pre-populated instances.
def with_defaults(cls) -> ContributorRegistry
Create a registry (no built-in contributors by default).
def register(contributor: AdminContributorProtocol) -> None
Register a contributor, keyed by its name.
def get(name: str) -> AdminContributorProtocol | None
Get a contributor by name, or None.
def get_all() -> Sequence[AdminContributorProtocol]
Get all contributors sorted by priority (lower = first).
def get_by_group(group: str) -> Sequence[AdminContributorProtocol]
Get contributors in a specific group, sorted by priority.
CoreAdminContributor
Section titled âCoreAdminContributorâBuilt-in contributor providing core dashboard surfaces.
Provides the framework health overview widget, the main dashboard navigation entry, and the system-wide health check surface.
Return core dashboard widgets: health overview and recent activity.
Return core navigation: Dashboard link.
Return core health definitions.
async def render_widget( widget_name: str, params: WidgetParams ) -> Result[str, AdminError]
Render core widgets.
| Parameter | Type | Description |
|---|---|---|
| `widget_name` | str | Name of the widget to render. |
| `params` | WidgetParams | Widget parameters. |
| Type | Description |
|---|---|
| Result[str, AdminError] | Result containing rendered HTML string, or WidgetNotFoundError if the widget is not found. |
async def render_health_check(check_name: str) -> Result[str, AdminError]
Render health check for admin core.
| Parameter | Type | Description |
|---|---|---|
| `check_name` | str | Name of the health check. |
| Type | Description |
|---|---|
| Result[str, AdminError] | Result with rendered HTML or error. |
ErrorCode
Section titled âErrorCodeâMachine-readable error codes for admin operations.
Exceptions
Section titled âExceptionsâAdminError
Section titled âAdminErrorâBase exception for all admin errors.
AdminValidationError
Section titled âAdminValidationErrorâRaised when validation fails.
ConflictError
Section titled âConflictErrorâRaised when a resource conflict occurs.
DataError
Section titled âDataErrorâRaised when a data source or database error occurs in admin.
NotFoundError
Section titled âNotFoundErrorâRaised when a resource is not found.
NotificationError
Section titled âNotificationErrorâRaised when a notification fails to send.
PermissionDeniedError
Section titled âPermissionDeniedErrorâRaised when permission is denied.