refactor: migrate templates and static files to self-contained modules
Templates Migration: - Migrate admin templates to modules (tenancy, billing, monitoring, marketplace, etc.) - Migrate vendor templates to modules (tenancy, billing, orders, messaging, etc.) - Migrate storefront templates to modules (catalog, customers, orders, cart, checkout, cms) - Migrate public templates to modules (billing, marketplace, cms) - Keep shared templates in app/templates/ (base.html, errors/, partials/, macros/) - Migrate letzshop partials to marketplace module Static Files Migration: - Migrate admin JS to modules: tenancy (23 files), core (5 files), monitoring (1 file) - Migrate vendor JS to modules: tenancy (4 files), core (2 files) - Migrate shared JS: vendor-selector.js to core, media-picker.js to cms - Migrate storefront JS: storefront-layout.js to core - Keep framework JS in static/ (api-client, utils, money, icons, log-config, lib/) - Update all template references to use module_static paths Naming Consistency: - Rename static/platform/ to static/public/ - Rename app/templates/platform/ to app/templates/public/ - Update all extends and static references Documentation: - Update module-system.md with shared templates documentation - Update frontend-structure.md with new module JS organization Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,68 +2,45 @@
|
||||
"""
|
||||
Admin API router aggregation.
|
||||
|
||||
This module combines all admin-related JSON API endpoints:
|
||||
- Authentication (login/logout)
|
||||
- Vendor management (CRUD, bulk operations)
|
||||
- Vendor domains management (custom domains, DNS verification)
|
||||
- Vendor themes management (theme editor, presets)
|
||||
- User management (status, roles)
|
||||
- Dashboard and statistics
|
||||
- Marketplace monitoring
|
||||
- Audit logging
|
||||
- Platform settings
|
||||
- Notifications and alerts
|
||||
- Code quality and architecture validation
|
||||
This module combines legacy admin routes with auto-discovered module routes.
|
||||
|
||||
LEGACY ROUTES (defined in app/api/v1/admin/):
|
||||
- /menu-config/* - Navigation configuration (super admin)
|
||||
- /modules/* - Module management (super admin)
|
||||
- /module-config/* - Module settings (super admin)
|
||||
|
||||
AUTO-DISCOVERED MODULE ROUTES:
|
||||
- tenancy: auth, admin_users, users, companies, platforms, vendors, vendor_domains
|
||||
- core: dashboard, settings
|
||||
- messaging: messages, notifications, email-templates
|
||||
- monitoring: logs, tasks, tests, code_quality, audit, platform-health
|
||||
- billing: subscriptions, invoices, payments
|
||||
- inventory: stock management
|
||||
- orders: order management, fulfillment, exceptions
|
||||
- marketplace: letzshop integration, product sync
|
||||
- catalog: vendor product catalog
|
||||
- cms: content-pages, images, media, vendor-themes
|
||||
- customers: customer management
|
||||
|
||||
IMPORTANT:
|
||||
- This router is for JSON API endpoints only
|
||||
- HTML page routes are mounted separately in main.py at /vendor/*
|
||||
- Do NOT include pages.router here - it causes route conflicts
|
||||
|
||||
MODULE SYSTEM:
|
||||
Routes can be module-gated using require_module_access() dependency.
|
||||
For multi-tenant apps, module enablement is checked at request time
|
||||
based on platform context (not at route registration time).
|
||||
|
||||
Self-contained modules (auto-discovered from app/modules/{module}/routes/api/admin.py):
|
||||
- billing: Subscription tiers, vendor billing, invoices
|
||||
- inventory: Stock management, inventory tracking
|
||||
- orders: Order management, fulfillment, exceptions
|
||||
- marketplace: Letzshop integration, product sync, marketplace products
|
||||
- catalog: Vendor product catalog management
|
||||
- cms: Content pages management
|
||||
- customers: Customer management
|
||||
- HTML page routes are mounted separately in main.py
|
||||
- Module routes are auto-discovered from app/modules/{module}/routes/api/admin.py
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
# Import all admin routers (legacy routes that haven't been migrated to modules)
|
||||
# NOTE: Migrated to modules (auto-discovered):
|
||||
# - tenancy: auth, admin_users, users, companies, platforms, vendors, vendor_domains
|
||||
# - core: dashboard, settings
|
||||
# - messaging: messages, notifications, email_templates
|
||||
# - monitoring: logs, tasks, tests, code_quality, audit, platform_health
|
||||
# - cms: content_pages, images, media, vendor_themes
|
||||
from . import (
|
||||
admin_users,
|
||||
audit,
|
||||
auth,
|
||||
background_tasks,
|
||||
code_quality,
|
||||
companies,
|
||||
dashboard,
|
||||
email_templates,
|
||||
images,
|
||||
logs,
|
||||
media,
|
||||
menu_config,
|
||||
messages,
|
||||
module_config,
|
||||
modules,
|
||||
monitoring,
|
||||
notifications,
|
||||
platform_health,
|
||||
platforms,
|
||||
settings,
|
||||
tests,
|
||||
users,
|
||||
vendor_domains,
|
||||
vendor_themes,
|
||||
vendors,
|
||||
)
|
||||
|
||||
# Create admin router
|
||||
@@ -71,32 +48,9 @@ router = APIRouter()
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Authentication & Authorization
|
||||
# Framework Config (remain in legacy - super admin only)
|
||||
# ============================================================================
|
||||
|
||||
# Include authentication endpoints
|
||||
router.include_router(auth.router, tags=["admin-auth"])
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Company & Vendor Management
|
||||
# ============================================================================
|
||||
|
||||
# Include company management endpoints
|
||||
router.include_router(companies.router, tags=["admin-companies"])
|
||||
|
||||
# Include vendor management endpoints
|
||||
router.include_router(vendors.router, tags=["admin-vendors"])
|
||||
|
||||
# Include vendor domains management endpoints
|
||||
router.include_router(vendor_domains.router, tags=["admin-vendor-domains"])
|
||||
|
||||
# Include vendor themes management endpoints
|
||||
router.include_router(vendor_themes.router, tags=["admin-vendor-themes"])
|
||||
|
||||
# Include platforms management endpoints (multi-platform CMS)
|
||||
router.include_router(platforms.router, tags=["admin-platforms"])
|
||||
|
||||
# Include menu configuration endpoints (super admin only)
|
||||
router.include_router(menu_config.router, tags=["admin-menu-config"])
|
||||
|
||||
@@ -107,82 +61,13 @@ router.include_router(modules.router, tags=["admin-modules"])
|
||||
router.include_router(module_config.router, tags=["admin-module-config"])
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# User Management
|
||||
# ============================================================================
|
||||
|
||||
# Include user management endpoints
|
||||
router.include_router(users.router, tags=["admin-users"])
|
||||
|
||||
# Include admin user management endpoints (super admin only)
|
||||
router.include_router(admin_users.router, tags=["admin-admin-users"])
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Dashboard & Statistics
|
||||
# ============================================================================
|
||||
|
||||
# Include dashboard and statistics endpoints
|
||||
router.include_router(dashboard.router, tags=["admin-dashboard"])
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Platform Administration
|
||||
# ============================================================================
|
||||
|
||||
# Include background tasks monitoring endpoints
|
||||
router.include_router(
|
||||
background_tasks.router, prefix="/background-tasks", tags=["admin-background-tasks"]
|
||||
)
|
||||
|
||||
# Include audit logging endpoints
|
||||
router.include_router(audit.router, tags=["admin-audit"])
|
||||
|
||||
# Include platform settings endpoints
|
||||
router.include_router(settings.router, tags=["admin-settings"])
|
||||
|
||||
# Include notifications and alerts endpoints
|
||||
router.include_router(notifications.router, tags=["admin-notifications"])
|
||||
|
||||
# Include messaging endpoints
|
||||
router.include_router(messages.router, tags=["admin-messages"])
|
||||
|
||||
# Include email templates management endpoints
|
||||
router.include_router(email_templates.router, tags=["admin-email-templates"])
|
||||
|
||||
# Include log management endpoints
|
||||
router.include_router(logs.router, tags=["admin-logs"])
|
||||
|
||||
# Include image management endpoints
|
||||
router.include_router(images.router, tags=["admin-images"])
|
||||
|
||||
# Include media library management endpoints
|
||||
router.include_router(media.router, tags=["admin-media"])
|
||||
|
||||
# Include platform health endpoints
|
||||
router.include_router(
|
||||
platform_health.router, prefix="/platform", tags=["admin-platform-health"]
|
||||
)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Code Quality & Architecture
|
||||
# ============================================================================
|
||||
|
||||
# Include code quality and architecture validation endpoints
|
||||
router.include_router(
|
||||
code_quality.router, prefix="/code-quality", tags=["admin-code-quality"]
|
||||
)
|
||||
|
||||
# Include test runner endpoints
|
||||
router.include_router(tests.router, prefix="/tests", tags=["admin-tests"])
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Auto-discovered Module Routes
|
||||
# ============================================================================
|
||||
# Routes from self-contained modules are auto-discovered and registered.
|
||||
# Modules include: billing, inventory, orders, marketplace, cms, customers
|
||||
# Modules include: billing, inventory, orders, marketplace, cms, customers,
|
||||
# monitoring (logs, tasks, tests, code_quality, audit, platform_health),
|
||||
# messaging (messages, notifications, email_templates)
|
||||
|
||||
from app.modules.routes import get_admin_api_routes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user