MIGRATION: - Delete app/api/v1/vendor/analytics.py (duplicate - analytics module already auto-discovered) - Move usage routes from app/api/v1/vendor/usage.py to billing module - Move onboarding routes from app/api/v1/vendor/onboarding.py to marketplace module - Move features routes to billing module (admin + vendor) - Move inventory routes to inventory module (admin + vendor) - Move marketplace/letzshop routes to marketplace module - Move orders routes to orders module - Delete legacy letzshop service files (moved to marketplace module) DOCUMENTATION: - Add docs/development/migration/module-autodiscovery-migration.md with full migration history - Update docs/architecture/module-system.md with Entity Auto-Discovery Reference section - Add detailed sections for each entity type: routes, services, models, schemas, tasks, exceptions, templates, static files, locales, configuration ARCHITECTURE VALIDATION: - Add MOD-016: Routes must be in modules, not app/api/v1/ - Add MOD-017: Services must be in modules, not app/services/ - Add MOD-018: Tasks must be in modules, not app/tasks/ - Add MOD-019: Schemas must be in modules, not models/schema/ - Update scripts/validate_architecture.py with _validate_legacy_locations method - Update .architecture-rules/module.yaml with legacy location rules These rules enforce that all entities must be in self-contained modules. Legacy locations now trigger ERROR severity violations. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
205 lines
6.5 KiB
Python
205 lines
6.5 KiB
Python
# 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).
|
|
|
|
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
|
|
"""
|
|
|
|
from fastapi import APIRouter
|
|
|
|
# Import all admin routers (legacy routes that haven't been migrated to modules)
|
|
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
|
|
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 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"])
|
|
|
|
|
|
# ============================================================================
|
|
# 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
|
|
|
|
from app.modules.routes import get_admin_api_routes
|
|
|
|
for route_info in get_admin_api_routes():
|
|
# Only pass prefix if custom_prefix is set (router already has internal prefix)
|
|
if route_info.custom_prefix:
|
|
router.include_router(
|
|
route_info.router,
|
|
prefix=route_info.custom_prefix,
|
|
tags=route_info.tags,
|
|
)
|
|
else:
|
|
router.include_router(
|
|
route_info.router,
|
|
tags=route_info.tags,
|
|
)
|
|
|
|
# Export the router
|
|
__all__ = ["router"]
|