feat: add self-contained structure to remaining modules

Add exceptions, models, schemas, services directories to modules:

customers:
- exceptions.py, models/, schemas/, services/

inventory:
- exceptions.py, models/, schemas/, services/

messaging:
- exceptions.py, models/, schemas/, services/

monitoring:
- exceptions.py, models/, schemas/, services/

orders:
- exceptions.py, models/, schemas/, services/

payments:
- Updated __init__.py

All modules now have the standard self-contained directory
structure ready for future migration of business logic.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-28 22:21:50 +01:00
parent b74d1346aa
commit 705d336e19
31 changed files with 772 additions and 87 deletions

View File

@@ -1,25 +1,36 @@
# app/modules/monitoring/__init__.py
"""
Monitoring Module - Platform monitoring and system health.
Monitoring Module - Platform monitoring and observability.
This module provides:
- Application logs
- Background tasks monitoring
This is a self-contained internal module providing:
- Background task monitoring
- Import job tracking
- Platform health metrics
- Testing hub
- Code quality tools
- System capacity monitoring
- Application logs viewing
- Platform health checks
Routes:
- Admin: /api/v1/admin/logs/*, /api/v1/admin/background-tasks/*,
/api/v1/admin/tests/*, /api/v1/admin/code-quality/*
- Vendor: None
Menu Items:
- Admin: imports, background-tasks, logs, platform-health, testing, code-quality
- Vendor: None
Module Structure:
- models/ - Database models (CapacitySnapshot, AdminNotification, etc.)
- services/ - Business logic (BackgroundTasksService)
- schemas/ - Pydantic DTOs
- routes/ - API and page routes
- exceptions.py - Module-specific exceptions
"""
from app.modules.monitoring.definition import monitoring_module
# Use lazy imports to avoid circular import issues
__all__ = ["monitoring_module"]
def __getattr__(name: str):
"""Lazy import module components to avoid circular imports."""
if name == "monitoring_module":
from app.modules.monitoring.definition import monitoring_module
return monitoring_module
elif name == "get_monitoring_module_with_routers":
from app.modules.monitoring.definition import get_monitoring_module_with_routers
return get_monitoring_module_with_routers
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
__all__ = ["monitoring_module", "get_monitoring_module_with_routers"]

View File

@@ -3,7 +3,7 @@
Monitoring module definition.
Defines the monitoring module including its features, menu items,
and route configurations.
route configurations, and self-contained module settings.
"""
from app.modules.base import ModuleDefinition
@@ -46,6 +46,14 @@ monitoring_module = ModuleDefinition(
},
is_core=False,
is_internal=True, # Internal module - admin-only, not customer-facing
# =========================================================================
# Self-Contained Module Configuration
# =========================================================================
is_self_contained=True,
services_path="app.modules.monitoring.services",
models_path="app.modules.monitoring.models",
schemas_path="app.modules.monitoring.schemas",
exceptions_path="app.modules.monitoring.exceptions",
)

View File

@@ -0,0 +1,50 @@
# app/modules/monitoring/exceptions.py
"""
Monitoring module exceptions.
Module-specific exceptions for monitoring functionality.
"""
from app.exceptions.base import (
BusinessLogicException,
ResourceNotFoundException,
)
class TaskNotFoundException(ResourceNotFoundException):
"""Raised when a background task is not found."""
def __init__(self, task_id: str):
super().__init__(
resource_type="BackgroundTask",
identifier=task_id,
error_code="TASK_NOT_FOUND",
)
class CapacitySnapshotNotFoundException(ResourceNotFoundException):
"""Raised when a capacity snapshot is not found."""
def __init__(self, snapshot_id: int):
super().__init__(
resource_type="CapacitySnapshot",
identifier=str(snapshot_id),
error_code="CAPACITY_SNAPSHOT_NOT_FOUND",
)
class MonitoringServiceException(BusinessLogicException):
"""Raised when a monitoring operation fails."""
def __init__(self, operation: str, reason: str):
super().__init__(
message=f"Monitoring operation '{operation}' failed: {reason}",
error_code="MONITORING_OPERATION_FAILED",
)
__all__ = [
"TaskNotFoundException",
"CapacitySnapshotNotFoundException",
"MonitoringServiceException",
]

View File

@@ -0,0 +1,21 @@
# app/modules/monitoring/models/__init__.py
"""
Monitoring module database models.
Re-exports monitoring-related models from their source locations.
"""
# CapacitySnapshot is in billing module (tracks system capacity over time)
from app.modules.billing.models import CapacitySnapshot
# Admin notification and logging models
from models.database.admin import (
AdminNotification,
PlatformAlert,
)
__all__ = [
"CapacitySnapshot",
"AdminNotification",
"PlatformAlert",
]

View File

@@ -0,0 +1,11 @@
# app/modules/monitoring/schemas/__init__.py
"""
Monitoring module Pydantic schemas.
Schemas for monitoring API request/response serialization.
"""
# Monitoring schemas are defined inline in routes or in models/schema/
# Add re-exports here as needed
__all__ = []

View File

@@ -0,0 +1,16 @@
# app/modules/monitoring/services/__init__.py
"""
Monitoring module services.
Re-exports monitoring-related services from their source locations.
"""
from app.services.background_tasks_service import (
background_tasks_service,
BackgroundTasksService,
)
__all__ = [
"background_tasks_service",
"BackgroundTasksService",
]