# app/api/v1/vendor/__init__.py """ Vendor API router aggregation. This module aggregates all vendor-related JSON API endpoints. 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/vendor.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 sub-routers (JSON API only) from . import ( analytics, auth, billing, # content_pages - moved to app.modules.cms.routes.api.vendor customers, dashboard, email_settings, email_templates, features, info, inventory, invoices, letzshop, marketplace, media, messages, notifications, onboarding, order_item_exceptions, orders, payments, products, profile, settings, team, usage, ) # Import extracted module routers # NOTE: Import directly from vendor.py files to avoid circular imports through __init__.py from app.modules.billing.routes.api.vendor import vendor_router as billing_vendor_router from app.modules.inventory.routes.vendor import vendor_router as inventory_vendor_router from app.modules.orders.routes.vendor import vendor_router as orders_vendor_router from app.modules.orders.routes.vendor import vendor_exceptions_router as orders_exceptions_router from app.modules.marketplace.routes.api.vendor import vendor_router as marketplace_vendor_router from app.modules.marketplace.routes.api.vendor import vendor_letzshop_router as letzshop_vendor_router # CMS module router from app.modules.cms.routes.api.vendor import router as cms_vendor_router # Create vendor router router = APIRouter() # ============================================================================ # JSON API ROUTES ONLY # ============================================================================ # These routes return JSON and are mounted at /api/v1/vendor/* # IMPORTANT: Specific routes MUST be registered BEFORE catch-all routes # The info.router has GET /{vendor_code} which catches everything, # so it must be registered LAST # Authentication (no prefix, specific routes like /auth/login) router.include_router(auth.router, tags=["vendor-auth"]) # Vendor management (with prefixes: /dashboard/*, /profile/*, /settings/*) router.include_router(dashboard.router, tags=["vendor-dashboard"]) router.include_router(profile.router, tags=["vendor-profile"]) router.include_router(settings.router, tags=["vendor-settings"]) router.include_router(email_templates.router, tags=["vendor-email-templates"]) router.include_router(email_settings.router, tags=["vendor-email-settings"]) router.include_router(onboarding.router, tags=["vendor-onboarding"]) # Business operations (with prefixes: /products/*, /orders/*, etc.) router.include_router(products.router, tags=["vendor-products"]) # Include orders module router (with module access control) router.include_router(orders_vendor_router, tags=["vendor-orders"]) router.include_router(orders_exceptions_router, tags=["vendor-order-exceptions"]) # Legacy: router.include_router(orders.router, tags=["vendor-orders"]) # Legacy: router.include_router(order_item_exceptions.router, tags=["vendor-order-exceptions"]) router.include_router(invoices.router, tags=["vendor-invoices"]) router.include_router(customers.router, tags=["vendor-customers"]) router.include_router(team.router, tags=["vendor-team"]) # Include inventory module router (with module access control) router.include_router(inventory_vendor_router, tags=["vendor-inventory"]) # Legacy: router.include_router(inventory.router, tags=["vendor-inventory"]) # Include marketplace module router (with module access control) router.include_router(marketplace_vendor_router, tags=["vendor-marketplace"]) router.include_router(letzshop_vendor_router, tags=["vendor-letzshop"]) # Legacy: router.include_router(marketplace.router, tags=["vendor-marketplace"]) # Legacy: router.include_router(letzshop.router, tags=["vendor-letzshop"]) # Services (with prefixes: /payments/*, /media/*, etc.) router.include_router(payments.router, tags=["vendor-payments"]) router.include_router(media.router, tags=["vendor-media"]) router.include_router(notifications.router, tags=["vendor-notifications"]) router.include_router(messages.router, tags=["vendor-messages"]) router.include_router(analytics.router, tags=["vendor-analytics"]) # Include billing module router (with module access control) router.include_router(billing_vendor_router, tags=["vendor-billing"]) # Legacy: router.include_router(billing.router, tags=["vendor-billing"]) router.include_router(features.router, tags=["vendor-features"]) router.include_router(usage.router, tags=["vendor-usage"]) # CMS module router (self-contained module) router.include_router(cms_vendor_router, tags=["vendor-content-pages"]) # Legacy: content_pages.router moved to app.modules.cms.routes.api.vendor # Vendor info endpoint - MUST BE LAST! Has catch-all GET /{vendor_code} router.include_router(info.router, tags=["vendor-info"]) __all__ = ["router"]