feat: implement DashboardWidgetProvider pattern for modular dashboard widgets
Add protocol-based widget system following the MetricsProvider pattern: - Create DashboardWidgetProviderProtocol in contracts/widgets.py - Add WidgetAggregatorService in core to discover and aggregate widgets - Implement MarketplaceWidgetProvider for recent_imports widget - Implement TenancyWidgetProvider for recent_vendors widget - Update admin dashboard to use widget_aggregator - Add widget_provider field to ModuleDefinition Architecture documentation: - Add widget-provider-pattern.md with implementation guide - Add cross-module-import-rules.md enforcing core/optional separation - Update module-system.md with widget_provider and import rules This enables modules to provide rich dashboard widgets without core modules importing from optional modules, maintaining true module independence. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,6 +22,13 @@ def _get_metrics_provider():
|
||||
return tenancy_metrics_provider
|
||||
|
||||
|
||||
def _get_widget_provider():
|
||||
"""Lazy import of widget provider to avoid circular imports."""
|
||||
from app.modules.tenancy.services.tenancy_widgets import tenancy_widget_provider
|
||||
|
||||
return tenancy_widget_provider
|
||||
|
||||
|
||||
tenancy_module = ModuleDefinition(
|
||||
code="tenancy",
|
||||
name="Tenancy Management",
|
||||
@@ -161,6 +168,8 @@ tenancy_module = ModuleDefinition(
|
||||
exceptions_path="app.modules.tenancy.exceptions",
|
||||
# Metrics provider for dashboard statistics
|
||||
metrics_provider=_get_metrics_provider,
|
||||
# Widget provider for dashboard widgets
|
||||
widget_provider=_get_widget_provider,
|
||||
)
|
||||
|
||||
__all__ = ["tenancy_module"]
|
||||
|
||||
Reference in New Issue
Block a user