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

@@ -2,21 +2,35 @@
"""
Messaging Module - Internal messaging and notifications.
This module provides:
This is a self-contained module providing:
- Internal messages between users
- Customer communication
- Admin-vendor-customer conversations
- Notification center
- Email notifications
- Message attachments
Routes:
- Admin: /api/v1/admin/messages/*, /api/v1/admin/notifications/*
- Vendor: /api/v1/vendor/messages/*, /api/v1/vendor/notifications/*
Menu Items:
- Admin: messages, notifications
- Vendor: messages, notifications
Module Structure:
- models/ - Database models (Conversation, Message, etc.)
- services/ - Business logic (MessagingService, NotificationService)
- schemas/ - Pydantic DTOs
- routes/ - API routes
- exceptions.py - Module-specific exceptions
"""
from app.modules.messaging.definition import messaging_module
# Use lazy imports to avoid circular import issues
__all__ = ["messaging_module"]
def __getattr__(name: str):
"""Lazy import module components to avoid circular imports."""
if name == "messaging_module":
from app.modules.messaging.definition import messaging_module
return messaging_module
elif name == "get_messaging_module_with_routers":
from app.modules.messaging.definition import get_messaging_module_with_routers
return get_messaging_module_with_routers
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
__all__ = ["messaging_module", "get_messaging_module_with_routers"]

View File

@@ -3,7 +3,7 @@
Messaging module definition.
Defines the messaging module including its features, menu items,
and route configurations.
route configurations, and self-contained module settings.
"""
from app.modules.base import ModuleDefinition
@@ -17,13 +17,6 @@ def _get_admin_router():
return admin_router
def _get_admin_notifications_router():
"""Lazy import of admin notifications router to avoid circular imports."""
from app.modules.messaging.routes.admin import admin_notifications_router
return admin_notifications_router
def _get_vendor_router():
"""Lazy import of vendor router to avoid circular imports."""
from app.modules.messaging.routes.vendor import vendor_router
@@ -31,22 +24,18 @@ def _get_vendor_router():
return vendor_router
def _get_vendor_notifications_router():
"""Lazy import of vendor notifications router to avoid circular imports."""
from app.modules.messaging.routes.vendor import vendor_notifications_router
return vendor_notifications_router
# Messaging module definition
messaging_module = ModuleDefinition(
code="messaging",
name="Messaging & Notifications",
description="Internal messages, customer communication, and notifications.",
version="1.0.0",
features=[
"customer_messaging", # Customer communication
"internal_messages", # Internal team messages
"notification_center", # Notification management
"message_attachments", # File attachments
"admin_notifications", # System admin notifications
],
menu_items={
FrontendType.ADMIN: [
@@ -59,6 +48,14 @@ messaging_module = ModuleDefinition(
],
},
is_core=False,
# =========================================================================
# Self-Contained Module Configuration
# =========================================================================
is_self_contained=True,
services_path="app.modules.messaging.services",
models_path="app.modules.messaging.models",
schemas_path="app.modules.messaging.schemas",
exceptions_path="app.modules.messaging.exceptions",
)

View File

@@ -0,0 +1,28 @@
# app/modules/messaging/exceptions.py
"""
Messaging module exceptions.
Re-exports messaging-related exceptions from their source locations.
"""
from app.exceptions.message import (
ConversationNotFoundException,
MessageNotFoundException,
ConversationClosedException,
MessageAttachmentException,
UnauthorizedConversationAccessException,
InvalidConversationTypeException,
InvalidRecipientTypeException,
AttachmentNotFoundException,
)
__all__ = [
"ConversationNotFoundException",
"MessageNotFoundException",
"ConversationClosedException",
"MessageAttachmentException",
"UnauthorizedConversationAccessException",
"InvalidConversationTypeException",
"InvalidRecipientTypeException",
"AttachmentNotFoundException",
]

View File

@@ -0,0 +1,26 @@
# app/modules/messaging/models/__init__.py
"""
Messaging module database models.
Re-exports messaging-related models from their source locations.
"""
from models.database.message import (
Conversation,
ConversationParticipant,
ConversationType,
Message,
MessageAttachment,
ParticipantType,
)
from models.database.admin import AdminNotification
__all__ = [
"Conversation",
"ConversationParticipant",
"ConversationType",
"Message",
"MessageAttachment",
"ParticipantType",
"AdminNotification",
]

View File

@@ -0,0 +1,28 @@
# app/modules/messaging/schemas/__init__.py
"""
Messaging module Pydantic schemas.
Re-exports messaging-related schemas from their source locations.
"""
from models.schema.message import (
ConversationResponse,
ConversationListResponse,
MessageResponse,
MessageCreate,
AttachmentResponse,
)
from models.schema.notification import (
NotificationResponse,
NotificationListResponse,
)
__all__ = [
"ConversationResponse",
"ConversationListResponse",
"MessageResponse",
"MessageCreate",
"AttachmentResponse",
"NotificationResponse",
"NotificationListResponse",
]

View File

@@ -0,0 +1,30 @@
# app/modules/messaging/services/__init__.py
"""
Messaging module services.
Re-exports messaging-related services from their source locations.
"""
from app.services.messaging_service import (
messaging_service,
MessagingService,
)
from app.services.message_attachment_service import (
message_attachment_service,
MessageAttachmentService,
)
from app.services.admin_notification_service import (
admin_notification_service,
AdminNotificationService,
)
# Note: notification_service is a placeholder - not yet implemented
__all__ = [
"messaging_service",
"MessagingService",
"message_attachment_service",
"MessageAttachmentService",
"admin_notification_service",
"AdminNotificationService",
]