feat: implement self-contained module architecture (Phase 1 & 2)

Phase 1 - Foundation:
- Add app/modules/contracts/ with Protocol definitions for cross-module
  communication (ServiceProtocol, ContentServiceProtocol, MediaServiceProtocol)
- Enhance app/modules/base.py ModuleDefinition with self-contained module
  support (is_self_contained, services_path, models_path, etc.)
- Update app/templates_config.py with multi-directory template loading
  using Jinja2 ChoiceLoader for module templates

Phase 2 - CMS Pilot Module:
- Migrate CMS service to app/modules/cms/services/content_page_service.py
- Create app/modules/cms/exceptions.py with CMS-specific exceptions
- Configure app/modules/cms/models/ to re-export ContentPage from canonical
  location (models.database) to avoid circular imports
- Update cms_module definition with is_self_contained=True and paths
- Add backwards compatibility shims with deprecation warnings:
  - app/services/content_page_service.py -> app.modules.cms.services
  - app/exceptions/content_page.py -> app.modules.cms.exceptions

Note: SQLAlchemy models remain in models/database/ as the canonical location
to avoid circular imports at startup time. Module model packages re-export
from the canonical location.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-26 21:35:36 +01:00
parent 4cf37add1b
commit 2ce19e66b1
14 changed files with 1663 additions and 1086 deletions

View File

@@ -24,6 +24,9 @@ Features:
- SEO metadata
- Published/Draft status
- Navigation placement (header, footer, legal)
NOTE: This is the canonical location for the ContentPage model.
The CMS module (app.modules.cms) re-exports this model.
"""
from datetime import UTC, datetime
@@ -230,8 +233,3 @@ class ContentPage(Base):
"created_by": self.created_by,
"updated_by": self.updated_by,
}
# Add relationship to Vendor model
# This should be added to models/database/vendor.py:
# content_pages = relationship("ContentPage", back_populates="vendor", cascade="all, delete-orphan")