feat: extract billing module with routes (Phase 3)
Create app/modules/billing/ directory structure with:
- definition.py: Module definition with features and menu items
- routes/admin.py: Admin billing routes with module access control
- routes/vendor.py: Vendor billing routes with module access control
Key changes:
- Billing module uses require_module_access("billing") dependency
- Admin router now includes billing module router instead of legacy
- Module registry imports billing_module from extracted location
- Routes have identical functionality but are now module-gated
Module structure pattern for future extractions:
app/modules/{module}/
├── __init__.py
├── definition.py (ModuleDefinition + router getters)
└── routes/
├── __init__.py
├── admin.py (require_module_access dependency)
└── vendor.py (require_module_access dependency)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,6 +19,20 @@ 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
|
||||
|
||||
Future extractions will follow the same pattern:
|
||||
1. Create app/modules/{module}/ directory
|
||||
2. Move routes to app/modules/{module}/routes/admin.py
|
||||
3. Add require_module_access("{module}") to router
|
||||
4. Update this file to import from module instead
|
||||
"""
|
||||
|
||||
from fastapi import APIRouter
|
||||
@@ -42,6 +56,7 @@ from . import (
|
||||
logs,
|
||||
marketplace,
|
||||
media,
|
||||
menu_config,
|
||||
messages,
|
||||
monitoring,
|
||||
notifications,
|
||||
@@ -51,7 +66,7 @@ from . import (
|
||||
platforms,
|
||||
products,
|
||||
settings,
|
||||
subscriptions,
|
||||
subscriptions, # Legacy - will be replaced by billing module router
|
||||
tests,
|
||||
users,
|
||||
vendor_domains,
|
||||
@@ -60,6 +75,9 @@ from . import (
|
||||
vendors,
|
||||
)
|
||||
|
||||
# Import extracted module routers
|
||||
from app.modules.billing.routes import admin_router as billing_admin_router
|
||||
|
||||
# Create admin router
|
||||
router = APIRouter()
|
||||
|
||||
@@ -96,6 +114,9 @@ router.include_router(
|
||||
# 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"])
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# User Management
|
||||
@@ -192,11 +213,15 @@ router.include_router(
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Billing & Subscriptions
|
||||
# Billing & Subscriptions (Module-gated)
|
||||
# ============================================================================
|
||||
|
||||
# Include subscription management endpoints
|
||||
router.include_router(subscriptions.router, tags=["admin-subscriptions"])
|
||||
# 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"])
|
||||
|
||||
Reference in New Issue
Block a user