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,34 @@
"""
Customers Module - Customer database and management.
This module provides:
This is a self-contained core module providing:
- Customer registration and authentication
- Customer profiles and contact information
- Customer address management
- Customer segmentation and tags
- Purchase history tracking
- Customer exports
Routes:
- Admin: /api/v1/admin/customers/*
- Vendor: /api/v1/vendor/customers/*
Menu Items:
- Admin: customers
- Vendor: customers
Module Structure:
- models/ - Database models (Customer, CustomerAddress, etc.)
- services/ - Business logic (CustomerService, CustomerAddressService)
- schemas/ - Pydantic DTOs
- routes/ - API routes
- exceptions.py - Module-specific exceptions
"""
from app.modules.customers.definition import customers_module
# Use lazy imports to avoid circular import issues
__all__ = ["customers_module"]
def __getattr__(name: str):
"""Lazy import module components to avoid circular imports."""
if name == "customers_module":
from app.modules.customers.definition import customers_module
return customers_module
elif name == "get_customers_module_with_routers":
from app.modules.customers.definition import get_customers_module_with_routers
return get_customers_module_with_routers
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
__all__ = ["customers_module", "get_customers_module_with_routers"]

View File

@@ -3,7 +3,7 @@
Customers module definition.
Defines the customers module including its features, menu items,
and route configurations.
route configurations, and self-contained module settings.
"""
from app.modules.base import ModuleDefinition
@@ -28,12 +28,15 @@ def _get_vendor_router():
customers_module = ModuleDefinition(
code="customers",
name="Customer Management",
description="Customer database, profiles, and segmentation.",
description="Customer database, profiles, addresses, and segmentation.",
version="1.0.0",
features=[
"customer_view", # View customer profiles
"customer_export", # Export customer data
"customer_profiles", # Detailed customer profiles
"customer_segmentation", # Customer tagging and segments
"customer_addresses", # Address management
"customer_authentication", # Customer login/registration
],
menu_items={
FrontendType.ADMIN: [
@@ -44,6 +47,14 @@ customers_module = ModuleDefinition(
],
},
is_core=True, # Customers is a core module - customer data is fundamental
# =========================================================================
# Self-Contained Module Configuration
# =========================================================================
is_self_contained=True,
services_path="app.modules.customers.services",
models_path="app.modules.customers.models",
schemas_path="app.modules.customers.schemas",
exceptions_path="app.modules.customers.exceptions",
)

View File

@@ -0,0 +1,37 @@
# app/modules/customers/exceptions.py
"""
Customers module exceptions.
Re-exports customer-related exceptions from their source locations.
"""
from app.exceptions.customer import (
CustomerNotFoundException,
CustomerAlreadyExistsException,
DuplicateCustomerEmailException,
CustomerNotActiveException,
InvalidCustomerCredentialsException,
CustomerValidationException,
CustomerAuthorizationException,
)
from app.exceptions.address import (
AddressNotFoundException,
AddressLimitExceededException,
InvalidAddressTypeException,
)
__all__ = [
# Customer exceptions
"CustomerNotFoundException",
"CustomerAlreadyExistsException",
"DuplicateCustomerEmailException",
"CustomerNotActiveException",
"InvalidCustomerCredentialsException",
"CustomerValidationException",
"CustomerAuthorizationException",
# Address exceptions
"AddressNotFoundException",
"AddressLimitExceededException",
"InvalidAddressTypeException",
]

View File

@@ -0,0 +1,18 @@
# app/modules/customers/models/__init__.py
"""
Customers module database models.
Re-exports customer-related models from their source locations.
"""
from models.database.customer import (
Customer,
CustomerAddress,
)
from models.database.password_reset_token import PasswordResetToken
__all__ = [
"Customer",
"CustomerAddress",
"PasswordResetToken",
]

View File

@@ -0,0 +1,28 @@
# app/modules/customers/schemas/__init__.py
"""
Customers module Pydantic schemas.
Re-exports customer-related schemas from their source locations.
"""
from models.schema.customer import (
CustomerRegister,
CustomerUpdate,
CustomerLogin,
CustomerResponse,
CustomerListResponse,
CustomerAddressCreate,
CustomerAddressUpdate,
CustomerAddressResponse,
)
__all__ = [
"CustomerRegister",
"CustomerUpdate",
"CustomerLogin",
"CustomerResponse",
"CustomerListResponse",
"CustomerAddressCreate",
"CustomerAddressUpdate",
"CustomerAddressResponse",
]

View File

@@ -0,0 +1,28 @@
# app/modules/customers/services/__init__.py
"""
Customers module services.
Re-exports customer-related services from their source locations.
"""
from app.services.customer_service import (
customer_service,
CustomerService,
)
from app.services.admin_customer_service import (
admin_customer_service,
AdminCustomerService,
)
from app.services.customer_address_service import (
customer_address_service,
CustomerAddressService,
)
__all__ = [
"customer_service",
"CustomerService",
"admin_customer_service",
"AdminCustomerService",
"customer_address_service",
"CustomerAddressService",
]