# app/api/v1/admin/__init__.py """ 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 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). Extracted modules (app/modules/{module}/routes/): - billing: Subscription tiers, vendor billing, invoices - inventory: Stock management, inventory tracking - orders: Order management, fulfillment, exceptions - marketplace: Letzshop integration, product sync Module extraction pattern: 1. Create app/modules/{module}/ directory 2. Create routes/admin.py with require_module_access("{module}") dependency 3. Import module router here and include it 4. Comment out legacy router include """ from fastapi import APIRouter # Import all admin routers from . import ( admin_users, audit, auth, background_tasks, code_quality, companies, # content_pages - moved to app.modules.cms.routes.api.admin customers, dashboard, email_templates, features, images, inventory, letzshop, logs, marketplace, media, menu_config, messages, module_config, modules, monitoring, notifications, order_item_exceptions, orders, platform_health, platforms, products, settings, subscriptions, # Legacy - will be replaced by billing module router tests, users, vendor_domains, vendor_products, vendor_themes, vendors, ) # Import extracted module routers # NOTE: Import directly from admin.py files to avoid circular imports through __init__.py from app.modules.billing.routes.api.admin import admin_router as billing_admin_router from app.modules.inventory.routes.admin import admin_router as inventory_admin_router from app.modules.orders.routes.admin import admin_router as orders_admin_router from app.modules.orders.routes.admin import admin_exceptions_router as orders_exceptions_router from app.modules.marketplace.routes.api.admin import admin_router as marketplace_admin_router from app.modules.marketplace.routes.api.admin import admin_letzshop_router as letzshop_admin_router # CMS module router from app.modules.cms.routes.api.admin import router as cms_admin_router # Create admin router router = APIRouter() # ============================================================================ # Authentication & Authorization # ============================================================================ # 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 CMS module router (self-contained module) router.include_router( cms_admin_router, prefix="/content-pages", tags=["admin-content-pages"] ) # Legacy: content_pages.router moved to app.modules.cms.routes.api.admin # 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"]) # Include module management endpoints (super admin only) router.include_router(modules.router, tags=["admin-modules"]) # Include module configuration endpoints (super admin only) 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"]) # Include customer management endpoints router.include_router(customers.router, tags=["admin-customers"]) # ============================================================================ # Dashboard & Statistics # ============================================================================ # Include dashboard and statistics endpoints router.include_router(dashboard.router, tags=["admin-dashboard"]) # ============================================================================ # Vendor Operations (Product Catalog, Inventory & Orders) - Module-gated # ============================================================================ # Include marketplace product catalog management endpoints router.include_router(products.router, tags=["admin-marketplace-products"]) # Include vendor product catalog management endpoints router.include_router(vendor_products.router, tags=["admin-vendor-products"]) # Include inventory module router (with module access control) router.include_router(inventory_admin_router, tags=["admin-inventory"]) # Legacy: router.include_router(inventory.router, tags=["admin-inventory"]) # Include orders module router (with module access control) router.include_router(orders_admin_router, tags=["admin-orders"]) router.include_router(orders_exceptions_router, tags=["admin-order-exceptions"]) # Legacy: router.include_router(orders.router, tags=["admin-orders"]) # Legacy: router.include_router(order_item_exceptions.router, tags=["admin-order-exceptions"]) # ============================================================================ # Marketplace & Imports (Module-gated) # ============================================================================ # Include marketplace module router (with module access control) router.include_router(marketplace_admin_router, tags=["admin-marketplace"]) router.include_router(letzshop_admin_router, tags=["admin-letzshop"]) # Legacy: router.include_router(marketplace.router, tags=["admin-marketplace"]) # Legacy: router.include_router(letzshop.router, tags=["admin-letzshop"]) # ============================================================================ # 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"] ) # ============================================================================ # Billing & Subscriptions (Module-gated) # ============================================================================ # Include billing module router (with module access control) # This router checks if the 'billing' module is enabled for the platform router.include_router(billing_admin_router, tags=["admin-billing"]) # Legacy subscriptions router (to be removed once billing module is fully tested) # router.include_router(subscriptions.router, tags=["admin-subscriptions"]) # Include feature management endpoints router.include_router(features.router, tags=["admin-features"]) # ============================================================================ # 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"]) # Export the router __all__ = ["router"]