feat: complete modular platform architecture (Phases 1-5)
Phase 1 - Vendor Router Integration: - Wire up vendor module routers in app/api/v1/vendor/__init__.py - Use lazy imports via __getattr__ to avoid circular dependencies Phase 2 - Extract Remaining Modules: - Create 6 new module directories: customers, cms, analytics, messaging, dev_tools, monitoring - Each module has definition.py and route wrappers - Update registry to import from extracted modules Phase 3 - Database Table Migration: - Add PlatformModule junction table for auditable module tracking - Add migration zc2m3n4o5p6q7_add_platform_modules_table.py - Add modules relationship to Platform model - Update ModuleService with JSON-to-junction-table migration Phase 4 - Module-Specific Configuration UI: - Add /api/v1/admin/module-config/* endpoints - Add module-config.html template and JS Phase 5 - Integration Tests: - Add tests/fixtures/module_fixtures.py - Add tests/integration/api/v1/admin/test_modules.py - Add tests/integration/api/v1/modules/test_module_access.py Architecture fixes: - Fix JS-003 errors: use ...data() directly in Alpine components - Fix JS-005 warnings: add init() guards to prevent duplicate init - Fix API-001 errors: add MenuActionResponse Pydantic model - Add FE-008 noqa for dynamic number input in template Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
54
app/api/v1/vendor/__init__.py
vendored
54
app/api/v1/vendor/__init__.py
vendored
@@ -8,6 +8,23 @@ 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
|
||||
@@ -42,6 +59,15 @@ from . import (
|
||||
usage,
|
||||
)
|
||||
|
||||
# Import extracted module routers
|
||||
# NOTE: Import directly from vendor.py files to avoid circular imports through __init__.py
|
||||
from app.modules.billing.routes.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.vendor import vendor_router as marketplace_vendor_router
|
||||
from app.modules.marketplace.routes.vendor import vendor_letzshop_router as letzshop_vendor_router
|
||||
|
||||
# Create vendor router
|
||||
router = APIRouter()
|
||||
|
||||
@@ -67,14 +93,26 @@ router.include_router(onboarding.router, tags=["vendor-onboarding"])
|
||||
|
||||
# Business operations (with prefixes: /products/*, /orders/*, etc.)
|
||||
router.include_router(products.router, tags=["vendor-products"])
|
||||
router.include_router(orders.router, tags=["vendor-orders"])
|
||||
router.include_router(order_item_exceptions.router, tags=["vendor-order-exceptions"])
|
||||
|
||||
# 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"])
|
||||
router.include_router(inventory.router, tags=["vendor-inventory"])
|
||||
router.include_router(marketplace.router, tags=["vendor-marketplace"])
|
||||
router.include_router(letzshop.router, tags=["vendor-letzshop"])
|
||||
|
||||
# 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"])
|
||||
@@ -82,7 +120,11 @@ 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"])
|
||||
router.include_router(billing.router, tags=["vendor-billing"])
|
||||
|
||||
# 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"])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user