Files
orion/app/platforms/shared/base_platform.py
Samir Boulahtit 5be42c5907 feat: implement modular platform architecture (Phase 1)
Add module system for enabling/disabling feature bundles per platform.

Module System:
- ModuleDefinition dataclass for defining modules
- 12 modules: core, platform-admin, billing, inventory, orders,
  marketplace, customers, cms, analytics, messaging, dev-tools, monitoring
- Core modules (core, platform-admin) cannot be disabled
- Module dependencies (e.g., marketplace requires inventory)

MenuService Integration:
- Menu items filtered by module enablement
- MenuItemConfig includes is_module_enabled and module_code fields
- Module-disabled items hidden from sidebar

Platform Configuration:
- BasePlatformConfig.enabled_modules property
- OMS: all modules enabled (full commerce)
- Loyalty: focused subset (no billing/inventory/orders/marketplace)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 21:42:44 +01:00

129 lines
3.6 KiB
Python

# app/platforms/shared/base_platform.py
"""
Base Platform Configuration
Provides a base class for platform-specific configurations.
Each platform (OMS, Loyalty, etc.) should extend this class.
"""
from abc import ABC, abstractmethod
from typing import Any
class BasePlatformConfig(ABC):
"""
Base configuration class for platforms.
Each platform should create a config.py that extends this class
and provides platform-specific settings.
Module Configuration:
- enabled_modules: List of module codes to enable for this platform
- Core modules (core, platform-admin) are always enabled
- If not specified, all modules are enabled (backwards compatibility)
"""
@property
@abstractmethod
def code(self) -> str:
"""Unique platform code (e.g., 'oms', 'loyalty')."""
pass
@property
@abstractmethod
def name(self) -> str:
"""Display name (e.g., 'Wizamart OMS')."""
pass
@property
def description(self) -> str:
"""Platform description."""
return ""
@property
def default_language(self) -> str:
"""Default language code."""
return "fr"
@property
def supported_languages(self) -> list[str]:
"""List of supported language codes."""
return ["fr", "de", "en"]
@property
def theme_defaults(self) -> dict[str, Any]:
"""Default theme configuration."""
return {
"primary_color": "#6366f1",
"secondary_color": "#8b5cf6",
"font_family": "Inter, sans-serif",
}
@property
def features(self) -> list[str]:
"""List of feature codes enabled for this platform."""
return []
@property
def enabled_modules(self) -> list[str]:
"""
List of module codes enabled for this platform.
Core modules (core, platform-admin) are always enabled regardless.
Override in subclass to customize which modules are available.
Available modules:
- core (always enabled): Dashboard, settings, profile
- platform-admin (always enabled): Companies, vendors, admin users
- billing: Subscription tiers, billing history
- inventory: Stock management, products
- orders: Order processing, fulfillment
- marketplace: Letzshop integration
- customers: Customer management
- cms: Content pages, media library
- analytics: Reports, dashboard analytics
- messaging: Messages, notifications
- dev-tools: Component library (internal)
- monitoring: Logs, background tasks (internal)
Returns:
List of module codes. Empty list means all modules enabled.
"""
return [] # Empty = all modules enabled (backwards compatibility)
@property
def marketing_page_slugs(self) -> list[str]:
"""
Slugs that should be treated as platform marketing pages.
These pages describe the platform itself (pricing, features, etc.)
rather than being vendor storefront content.
"""
return [
"home",
"pricing",
"about",
"contact",
"faq",
"terms",
"privacy",
"features",
"integrations",
]
@property
def vendor_default_page_slugs(self) -> list[str]:
"""
Slugs for default vendor storefront pages.
These pages provide fallback content for vendors who haven't
customized their storefront.
"""
return [
"about",
"shipping",
"returns",
"privacy-policy",
"terms-of-service",
]