refactor: complete module-driven architecture migration
This commit completes the migration to a fully module-driven architecture: ## Models Migration - Moved all domain models from models/database/ to their respective modules: - tenancy: User, Admin, Vendor, Company, Platform, VendorDomain, etc. - cms: MediaFile, VendorTheme - messaging: Email, VendorEmailSettings, VendorEmailTemplate - core: AdminMenuConfig - models/database/ now only contains Base and TimestampMixin (infrastructure) ## Schemas Migration - Moved all domain schemas from models/schema/ to their respective modules: - tenancy: company, vendor, admin, team, vendor_domain - cms: media, image, vendor_theme - messaging: email - models/schema/ now only contains base.py and auth.py (infrastructure) ## Routes Migration - Moved admin routes from app/api/v1/admin/ to modules: - menu_config.py -> core module - modules.py -> tenancy module - module_config.py -> tenancy module - app/api/v1/admin/ now only aggregates auto-discovered module routes ## Menu System - Implemented module-driven menu system with MenuDiscoveryService - Extended FrontendType enum: PLATFORM, ADMIN, VENDOR, STOREFRONT - Added MenuItemDefinition and MenuSectionDefinition dataclasses - Each module now defines its own menu items in definition.py - MenuService integrates with MenuDiscoveryService for template rendering ## Documentation - Updated docs/architecture/models-structure.md - Updated docs/architecture/menu-management.md - Updated architecture validation rules for new exceptions ## Architecture Validation - Updated MOD-019 rule to allow base.py in models/schema/ - Created core module exceptions.py and schemas/ directory - All validation errors resolved (only warnings remain) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,8 +6,8 @@ Platform, company, vendor, and admin user management.
|
||||
Required for multi-tenant operation - cannot be disabled.
|
||||
"""
|
||||
|
||||
from app.modules.base import ModuleDefinition
|
||||
from models.database.admin_menu_config import FrontendType
|
||||
from app.modules.base import MenuItemDefinition, MenuSectionDefinition, ModuleDefinition
|
||||
from app.modules.enums import FrontendType
|
||||
|
||||
tenancy_module = ModuleDefinition(
|
||||
code="tenancy",
|
||||
@@ -22,6 +22,7 @@ tenancy_module = ModuleDefinition(
|
||||
"vendor_management",
|
||||
"admin_user_management",
|
||||
],
|
||||
# Legacy menu_items
|
||||
menu_items={
|
||||
FrontendType.ADMIN: [
|
||||
"platforms",
|
||||
@@ -33,6 +34,84 @@ tenancy_module = ModuleDefinition(
|
||||
"team",
|
||||
],
|
||||
},
|
||||
# New module-driven menu definitions
|
||||
menus={
|
||||
FrontendType.ADMIN: [
|
||||
MenuSectionDefinition(
|
||||
id="superAdmin",
|
||||
label_key="tenancy.menu.super_admin",
|
||||
icon="shield",
|
||||
order=10,
|
||||
is_super_admin_only=True,
|
||||
items=[
|
||||
MenuItemDefinition(
|
||||
id="admin-users",
|
||||
label_key="tenancy.menu.admin_users",
|
||||
icon="shield",
|
||||
route="/admin/admin-users",
|
||||
order=10,
|
||||
is_mandatory=True,
|
||||
),
|
||||
],
|
||||
),
|
||||
MenuSectionDefinition(
|
||||
id="platformAdmin",
|
||||
label_key="tenancy.menu.platform_admin",
|
||||
icon="office-building",
|
||||
order=20,
|
||||
items=[
|
||||
MenuItemDefinition(
|
||||
id="companies",
|
||||
label_key="tenancy.menu.companies",
|
||||
icon="office-building",
|
||||
route="/admin/companies",
|
||||
order=10,
|
||||
is_mandatory=True,
|
||||
),
|
||||
MenuItemDefinition(
|
||||
id="vendors",
|
||||
label_key="tenancy.menu.vendors",
|
||||
icon="shopping-bag",
|
||||
route="/admin/vendors",
|
||||
order=20,
|
||||
is_mandatory=True,
|
||||
),
|
||||
],
|
||||
),
|
||||
MenuSectionDefinition(
|
||||
id="contentMgmt",
|
||||
label_key="tenancy.menu.content_management",
|
||||
icon="globe-alt",
|
||||
order=70,
|
||||
items=[
|
||||
MenuItemDefinition(
|
||||
id="platforms",
|
||||
label_key="tenancy.menu.platforms",
|
||||
icon="globe-alt",
|
||||
route="/admin/platforms",
|
||||
order=10,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
FrontendType.VENDOR: [
|
||||
MenuSectionDefinition(
|
||||
id="account",
|
||||
label_key="tenancy.menu.account_settings",
|
||||
icon="user-group",
|
||||
order=900,
|
||||
items=[
|
||||
MenuItemDefinition(
|
||||
id="team",
|
||||
label_key="tenancy.menu.team",
|
||||
icon="user-group",
|
||||
route="/vendor/{vendor_code}/team",
|
||||
order=5,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
},
|
||||
services_path="app.modules.tenancy.services",
|
||||
models_path="app.modules.tenancy.models",
|
||||
schemas_path="app.modules.tenancy.schemas",
|
||||
|
||||
Reference in New Issue
Block a user