From 081f81af4752cc8f49f1fe577cea1116be9f0484 Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sun, 18 Jan 2026 19:55:10 +0100 Subject: [PATCH] docs: update multi-platform implementation plan with Phase 1 status - Mark Phase 1 tasks as complete - Add detailed Phase 2 (OMS Migration) checklist - Add documentation requirements section - Add next session checklist for easy continuation - Include quick reference for three-tier resolution Co-Authored-By: Claude Opus 4.5 --- ...rm-cms-architecture-implementation-plan.md | 734 ++++++++---------- 1 file changed, 328 insertions(+), 406 deletions(-) diff --git a/docs/proposals/multi-platform-cms-architecture-implementation-plan.md b/docs/proposals/multi-platform-cms-architecture-implementation-plan.md index d3c1d81f..8e401976 100644 --- a/docs/proposals/multi-platform-cms-architecture-implementation-plan.md +++ b/docs/proposals/multi-platform-cms-architecture-implementation-plan.md @@ -1,406 +1,328 @@ - Multi-Platform CMS Architecture Implementation Plan - - Summary - - Transform the single-platform OMS into a multi-platform system supporting independent business offerings (OMS, Loyalty, Site Builder), each with its own CMS, - vendor defaults, and marketing pages. - - --- - URL/Access Pattern Matrix - - Production Environment - ┌─────────────┬──────────┬───────────────────────────────────────────┬────────────────────────────────────────┐ - │ Persona │ Platform │ URL │ Purpose │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ Super Admin │ Global │ admin.wizamart.lu/ │ Global admin dashboard │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ admin.wizamart.lu/platforms │ Manage all platforms │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ admin.wizamart.lu/platforms/oms/pages │ OMS platform marketing pages │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ admin.wizamart.lu/platforms/oms/defaults │ OMS vendor default pages │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ admin.wizamart.lu/platforms/loyalty/pages │ Loyalty platform pages │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ Vendor │ OMS │ oms.lu/vendor/{code}/login │ Vendor login │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ oms.lu/vendor/{code}/dashboard │ Vendor dashboard │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ oms.lu/vendor/{code}/content-pages │ Manage CMS pages │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ Loyalty │ loyalty.lu/vendor/{code}/login │ Loyalty vendor login │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ Customer │ OMS │ {vendor}.oms.lu/ │ Vendor storefront (subdomain) │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ {vendor}.oms.lu/shop/ │ Shop pages │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ {vendor}.oms.lu/about │ Content page (3-tier fallback) │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ {customdomain}.com/ │ Custom domain storefront │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ Public │ OMS │ oms.lu/ │ Platform homepage │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ oms.lu/pricing │ Platform pricing page │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ │ oms.lu/about │ Platform about (is_platform_page=True) │ - ├─────────────┼──────────┼───────────────────────────────────────────┼────────────────────────────────────────┤ - │ │ Loyalty │ loyalty.lu/ │ Loyalty platform homepage │ - └─────────────┴──────────┴───────────────────────────────────────────┴────────────────────────────────────────┘ - Development Environment (localhost:9999) - ┌─────────────┬──────────┬────────────────────────────────────────────┬───────────────────────────┐ - │ Persona │ Platform │ URL │ Purpose │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ Super Admin │ Global │ localhost:9999/admin/ │ Global admin │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ │ │ localhost:9999/admin/platforms │ Platform management │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ │ │ localhost:9999/admin/platforms/oms/pages │ OMS platform pages │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ Vendor │ OMS │ localhost:9999/oms/vendor/{code}/login │ OMS vendor login │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ │ │ localhost:9999/oms/vendor/{code}/dashboard │ OMS vendor dashboard │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ │ Loyalty │ localhost:9999/loyalty/vendor/{code}/login │ Loyalty vendor login │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ Customer │ OMS │ localhost:9999/oms/vendors/{code}/ │ Vendor root │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ │ │ localhost:9999/oms/vendors/{code}/shop/ │ Vendor shop │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ │ │ localhost:9999/oms/vendors/{code}/about │ Content page │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ │ Loyalty │ localhost:9999/loyalty/vendors/{code}/ │ Loyalty vendor storefront │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ Public │ OMS │ localhost:9999/oms/ │ OMS platform homepage │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ │ │ localhost:9999/oms/pricing │ OMS pricing │ - ├─────────────┼──────────┼────────────────────────────────────────────┼───────────────────────────┤ - │ │ Loyalty │ localhost:9999/loyalty/ │ Loyalty platform homepage │ - └─────────────┴──────────┴────────────────────────────────────────────┴───────────────────────────┘ - --- - Three-Tier Content Resolution - - Customer visits: oms.lu/vendors/wizamart/about - │ - ▼ - ┌─────────────────────────────────────────────────────────────┐ - │ Tier 1: Vendor Override │ - │ SELECT * FROM content_pages │ - │ WHERE platform_id = 1 AND vendor_id = 123 AND slug = 'about' │ - │ │ - │ Found? → Return vendor's custom page │ - └─────────────────────────────────────────────────────────────┘ - │ Not found - ▼ - ┌─────────────────────────────────────────────────────────────┐ - │ Tier 2: Platform Vendor Default │ - │ SELECT * FROM content_pages │ - │ WHERE platform_id = 1 AND vendor_id IS NULL │ - │ AND is_platform_page = FALSE AND slug = 'about' │ - │ │ - │ Found? → Return platform default │ - └─────────────────────────────────────────────────────────────┘ - │ Not found - ▼ - Return 404 - - --- - Data Models - - New: Platform Model - - File: models/database/platform.py - - class Platform(Base): - id: Integer (PK) - code: String(50) unique # "oms", "loyalty", "sites" - name: String(100) # "Wizamart OMS" - domain: String(255) # "oms.lu" (production) - path_prefix: String(50) # "oms" (for localhost:9999/oms/*) - logo: String(500) - theme_config: JSON - is_active: Boolean - default_language: String(5) - supported_languages: JSON - - New: VendorPlatform Junction Table - - File: models/database/vendor_platform.py - - class VendorPlatform(Base): - id: Integer (PK) - vendor_id: FK → vendors.id - platform_id: FK → platforms.id - tier_id: FK → platform_subscription_tiers.id - is_active: Boolean - is_primary: Boolean # Vendor's primary platform - custom_subdomain: String(100) - settings: JSON - joined_at: DateTime - - # Constraints - UniqueConstraint(vendor_id, platform_id) - - Updated: SubscriptionTier Model (Extend Existing) - - File: models/database/subscription.py - - Add fields to existing model: - platform_id: FK → platforms.id (nullable for global tiers, set for platform-specific) - cms_pages_limit: Integer (nullable) # NULL = unlimited - cms_custom_pages_limit: Integer (nullable) - - Update constraint: - UniqueConstraint(platform_id, code) # Allow same tier code per platform - - Updated: ContentPage Model - - File: models/database/content_page.py - - Add fields: - platform_id: FK → platforms.id (NOT NULL) - is_platform_page: Boolean (default=False) - # True = Platform marketing page (homepage, pricing) - # False = Vendor default OR vendor override/custom - - Update constraint: - UniqueConstraint(platform_id, vendor_id, slug) - - New CMS Feature Codes - - File: models/database/feature.py - - CMS_BASIC = "cms_basic" - CMS_CUSTOM_PAGES = "cms_custom_pages" - CMS_UNLIMITED_PAGES = "cms_unlimited_pages" - CMS_TEMPLATES = "cms_templates" - CMS_SEO = "cms_seo" - - --- - New Middleware: PlatformContextMiddleware - - File: middleware/platform_context.py - - Runs BEFORE VendorContextMiddleware. - - Detection Priority: - 1. Path-based (dev): localhost:9999/oms/* → platform_code = "oms" - 2. Domain-based (prod): oms.lu → platform_code = "oms" - 3. Default: localhost → platform_code = "oms" (backwards compatibility) - - Sets: - - request.state.platform → Platform object - - request.state.platform_context → Detection metadata - - request.state.platform_clean_path → Path without platform prefix - - --- - Folder Organization - - Platform-Specific Folders (NEW) - - app/ - ├── platforms/ # NEW - Platform-specific code - │ ├── oms/ # OMS-specific - │ │ ├── routes/ # OMS-specific routes - │ │ ├── templates/ # OMS templates (homepage, etc.) - │ │ └── config.py # OMS configuration - │ ├── loyalty/ # Loyalty-specific - │ │ ├── routes/ - │ │ ├── templates/ - │ │ └── config.py - │ └── shared/ # Shared across platforms - │ └── base_platform.py - ├── services/ # Shared services (extended) - │ ├── content_page_service.py # Add platform_id support - │ ├── feature_service.py # Extend with platform awareness - │ └── subscription_service.py # Extend with platform awareness - ├── templates/ - │ └── platform/ # Keep existing, used by platform router - └── middleware/ - └── platform_context.py # NEW - Platform detection - - Shared vs Platform-Specific - ┌────────────────────┬─────────────────────────────────┬─────────────────────────────────────┐ - │ Type │ Location │ Example │ - ├────────────────────┼─────────────────────────────────┼─────────────────────────────────────┤ - │ Shared models │ models/database/ │ Platform, ContentPage, Vendor │ - ├────────────────────┼─────────────────────────────────┼─────────────────────────────────────┤ - │ Shared services │ app/services/ │ FeatureService, SubscriptionService │ - ├────────────────────┼─────────────────────────────────┼─────────────────────────────────────┤ - │ Shared middleware │ middleware/ │ PlatformContextMiddleware │ - ├────────────────────┼─────────────────────────────────┼─────────────────────────────────────┤ - │ Platform routes │ app/platforms/{code}/routes/ │ OMS homepage, Loyalty dashboard │ - ├────────────────────┼─────────────────────────────────┼─────────────────────────────────────┤ - │ Platform templates │ app/platforms/{code}/templates/ │ OMS-specific homepage │ - ├────────────────────┼─────────────────────────────────┼─────────────────────────────────────┤ - │ Platform config │ app/platforms/{code}/config.py │ Domain, features, defaults │ - └────────────────────┴─────────────────────────────────┴─────────────────────────────────────┘ - --- - Critical Files to Modify - ┌──────────────────────────────────────┬───────────────────────────────────────────────────────────────┐ - │ File │ Changes │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ models/database/platform.py │ NEW - Platform model │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ models/database/vendor_platform.py │ NEW - Junction table │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ models/database/subscription.py │ Add platform_id, cms_pages_limit to existing SubscriptionTier │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ models/database/content_page.py │ Add platform_id, is_platform_page │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ models/database/feature.py │ Add CMS feature codes │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ middleware/platform_context.py │ NEW - Platform detection middleware │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ middleware/vendor_context.py │ Update to use platform_clean_path │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ app/services/content_page_service.py │ Add platform_id to all methods │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ app/services/feature_service.py │ Extend has_feature() with platform context │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ app/services/subscription_service.py │ Extend tier lookup with platform context │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ app/platforms/oms/ │ NEW - OMS-specific code │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ app/platforms/loyalty/ │ NEW - Loyalty-specific code │ - ├──────────────────────────────────────┼───────────────────────────────────────────────────────────────┤ - │ main.py │ Register PlatformContextMiddleware, platform-prefixed routes │ - └──────────────────────────────────────┴───────────────────────────────────────────────────────────────┘ - --- - Migration Strategy - - Pre-Migration - - # 1. Create git tag - git add -A && git commit -m "chore: prepare for multi-platform migration" - git tag -a v1.0.0-pre-multiplatform -m "Before multi-platform CMS migration" - git push origin v1.0.0-pre-multiplatform - - # 2. Backup database - pg_dump wizamart > wizamart_backup_$(date +%Y%m%d).sql - - Migration Steps - - 1. Create platforms table with default "oms" platform - 2. Create vendor_platforms junction table - 3. Add platform_id, cms_pages_limit, cms_custom_pages_limit to existing subscription_tiers - 4. Add platform_id and is_platform_page to content_pages - 5. Backfill: Set all subscription_tiers.platform_id = OMS platform ID - 6. Backfill: Set all content_pages.platform_id = OMS platform ID - 7. Backfill: Set is_platform_page=True for extended slugs (homepage, pricing, about, contact, faq, terms, privacy, features, integrations) - 8. Create vendor_platforms entries for all existing vendors → OMS - 9. Update unique constraint on content_pages and subscription_tiers - - --- - Implementation Phases - - Phase 1: Database & Models - - - Create Platform model - - Create VendorPlatform junction table - - Create PlatformSubscriptionTier model - - Update ContentPage with platform_id, is_platform_page - - Add CMS feature codes - - Write Alembic migration - - Test migration on dev database - - Phase 2: Middleware & Services - - - Create PlatformContextMiddleware - - Update VendorContextMiddleware - - Update ContentPageService with three-tier resolution - - Create CMSLimitService - - Update middleware registration order in main.py - - Phase 3: Admin Interface - - - Platform management UI (/admin/platforms) - - Platform pages editor - - Vendor defaults editor - - Update content-pages list - - Phase 4: Vendor Dashboard - - - Show page source (Default/Override/Custom) - - "Override" action for defaults - - "Revert to Default" action - - Page limit indicators - - Phase 5: Routes & Templates - - - Register platform-prefixed routes (dev mode) - - Fix platform homepage to use CMS - - Update shop routes with platform context - - Test all URL patterns - - Phase 6: Loyalty Platform Setup - - - Create "loyalty" platform record - - Create loyalty platform pages - - Create loyalty vendor defaults - - Test full flow - - --- - Verification Steps - - 1. Git tag created: git tag -l | grep pre-multiplatform - 2. Migration successful: - SELECT * FROM platforms; - SELECT COUNT(*) FROM vendor_platforms; - SELECT platform_id, is_platform_page, COUNT(*) FROM content_pages GROUP BY 1, 2; - 3. Dev URLs work: - - localhost:9999/oms/ → OMS homepage - - localhost:9999/loyalty/ → Loyalty homepage - - localhost:9999/oms/vendor/wizamart/dashboard → Vendor dashboard - 4. Three-tier resolution: - - Create vendor override → shows override - - Delete override → shows platform default - - Delete default → shows 404 - 5. Page limits: Create pages until limit → shows upgrade prompt - - --- - Open Questions Resolved - ┌───────────────────────┬─────────────────────────────────────────────────────────────────────────────────────────┐ - │ Question │ Answer │ - ├───────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ - │ Domain routing │ Prod: separate domains / Dev: path-based │ - ├───────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ - │ Vendor multi-platform │ Yes, junction table │ - ├───────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ - │ Tier CMS restrictions │ Yes, integrate with existing feature system │ - ├───────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ - │ MVP scope │ OMS + Loyalty, git tag first │ - ├───────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ - │ Admin structure │ Global super admin only (/admin/*) │ - ├───────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ - │ CMS page limits │ Essential: 3, Pro: 10, Business: 30, Enterprise: unlimited │ - ├───────────────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ - │ Platform page slugs │ platform_homepage, pricing, about, contact, faq, terms, privacy, features, integrations │ - └───────────────────────┴─────────────────────────────────────────────────────────────────────────────────────────┘ - --- - CMS Tier Limits (Final) - ┌──────────────┬─────────────┬──────────────┬─────────────────────────────────────────────────────┐ - │ Tier │ Total Pages │ Custom Pages │ Features │ - ├──────────────┼─────────────┼──────────────┼─────────────────────────────────────────────────────┤ - │ Essential │ 3 │ 0 │ cms_basic │ - ├──────────────┼─────────────┼──────────────┼─────────────────────────────────────────────────────┤ - │ Professional │ 10 │ 5 │ cms_basic, cms_custom_pages, cms_seo │ - ├──────────────┼─────────────┼──────────────┼─────────────────────────────────────────────────────┤ - │ Business │ 30 │ 20 │ cms_basic, cms_custom_pages, cms_seo, cms_templates │ - ├──────────────┼─────────────┼──────────────┼─────────────────────────────────────────────────────┤ - │ Enterprise │ Unlimited │ Unlimited │ cms_unlimited_pages, cms_scheduling │ - └──────────────┴─────────────┴──────────────┴─────────────────────────────────────────────────────┘ - --- - Platform Marketing Page Slugs (is_platform_page=True) - - These slugs will be marked as platform marketing pages during migration: - - platform_homepage (or home) - - pricing - - about - - contact - - faq - - terms - - privacy - - features - - integrations - - All other vendor_id=NULL pages become vendor defaults (is_platform_page=False). \ No newline at end of file +# Multi-Platform CMS Architecture - Implementation Plan + +> **Status:** Phase 1 Complete | Phases 2-6 Pending +> **Last Updated:** 2026-01-18 +> **Commit:** `408019d` (feat: add multi-platform CMS architecture Phase 1) + +--- + +## Executive Summary + +Transform the single-platform OMS into a multi-platform system supporting independent business offerings (OMS, Loyalty, Site Builder), each with its own CMS, vendor defaults, and marketing pages. + +--- + +## Phase 1: Database & Models ✅ COMPLETE + +### Completed Work + +| Task | File | Status | +|------|------|--------| +| Platform model | `models/database/platform.py` | ✅ | +| VendorPlatform junction table | `models/database/vendor_platform.py` | ✅ | +| SubscriptionTier updates | `models/database/subscription.py` | ✅ | +| ContentPage updates | `models/database/content_page.py` | ✅ | +| CMS feature codes | `models/database/feature.py` | ✅ | +| Model exports | `models/database/__init__.py` | ✅ | +| PlatformContextMiddleware | `middleware/platform_context.py` | ✅ | +| Middleware exports | `middleware/__init__.py` | ✅ | +| ContentPageService updates | `app/services/content_page_service.py` | ✅ | +| Alembic migration | `alembic/versions/z4e5f6a7b8c9_...py` | ✅ | +| Platform folder structure | `app/platforms/` | ✅ | + +--- + +## Phase 2: OMS Migration & Integration 🔄 NEXT + +### 2.1 Run Database Migration + +```bash +# 1. Backup database first +pg_dump wizamart > wizamart_backup_$(date +%Y%m%d).sql + +# 2. Run migration +alembic upgrade head + +# 3. Verify migration +psql -d wizamart -c "SELECT * FROM platforms;" +psql -d wizamart -c "SELECT COUNT(*) FROM vendor_platforms;" +psql -d wizamart -c "SELECT platform_id, is_platform_page, COUNT(*) FROM content_pages GROUP BY 1, 2;" +``` + +### 2.2 Register PlatformContextMiddleware in main.py + +```python +# In main.py, add BEFORE VendorContextMiddleware +from middleware import PlatformContextMiddleware + +# Order matters: Platform detection must run first +app.add_middleware(VendorContextMiddleware) # Runs second (existing) +app.add_middleware(PlatformContextMiddleware) # Runs first (NEW) +``` + +### 2.3 Update VendorContextMiddleware + +File: `middleware/vendor_context.py` + +Changes needed: +- [ ] Use `request.state.platform_clean_path` instead of `request.url.path` for path-based vendor detection +- [ ] Skip vendor detection if no platform found (platform marketing pages like /oms/pricing) +- [ ] Pass platform context to vendor lookup for multi-platform vendor support + +### 2.4 Fix Platform Homepage Route + +File: `app/routes/platform/homepage.py` + +Current state (BROKEN): +- Uses hardcoded `homepage-wizamart.html` template +- Admin CMS changes are saved but ignored by route + +Fix required: +```python +# Get platform from middleware +platform = request.state.platform + +# Query CMS for platform homepage +page = content_page_service.get_platform_page( + db, + platform_id=platform.id, + slug="home" +) + +if page: + # Render with selected template + return templates.TemplateResponse( + f"platform/homepage-{page.template}.html", + {"request": request, "page": page} + ) +else: + # Fallback to hardcoded (temporary) + return templates.TemplateResponse("platform/homepage-wizamart.html", {...}) +``` + +### 2.5 Update Content Page Routes + +Files to update: +- [ ] `app/routes/platform/content_pages.py` - Add platform_id from request.state.platform +- [ ] `app/routes/vendor/content_pages.py` - Add platform_id to queries +- [ ] `app/routes/admin/content_pages.py` - Add platform filtering + +--- + +## Phase 3: Admin Interface + +### 3.1 Platform Management UI + +New routes needed: +- [ ] `GET /admin/platforms` - List all platforms +- [ ] `GET /admin/platforms/{code}` - Platform details +- [ ] `GET /admin/platforms/{code}/pages` - Platform marketing pages +- [ ] `GET /admin/platforms/{code}/defaults` - Vendor default pages +- [ ] `POST/PUT/DELETE` endpoints for CRUD operations + +### 3.2 Update Content Pages Admin + +Changes to existing admin: +- [ ] Add platform dropdown filter +- [ ] Show page tier badge (Platform / Default / Override) +- [ ] Add `is_platform_page` toggle for platform-level pages +- [ ] Group pages by tier in list view + +--- + +## Phase 4: Vendor Dashboard + +### 4.1 Content Pages List Updates + +- [ ] Show source indicator: "Default" / "Override" / "Custom" +- [ ] Add "Override Default" button for vendor default pages +- [ ] Add "Revert to Default" button for vendor overrides +- [ ] Show CMS usage: "3 of 10 pages used" with progress bar +- [ ] Upgrade prompt when approaching limit + +### 4.2 Page Editor Updates + +- [ ] Show banner: "This page overrides the platform default" +- [ ] "View Default" button to preview default content +- [ ] "Revert" button inline in editor + +--- + +## Phase 5: Routes & Templates + +### 5.1 Platform-Prefixed Routes (Development) + +Register in `main.py`: +```python +# Development mode: path-based routing +if settings.environment == "development": + app.mount("/oms", oms_router) + app.mount("/loyalty", loyalty_router) +``` + +### 5.2 Update Shop Routes + +- [ ] Add platform context to shop routes +- [ ] Use `request.state.platform` for template selection +- [ ] Pass platform to content page lookups + +### 5.3 Test All URL Patterns + +Development: +- [ ] `localhost:9999/oms/` → OMS homepage +- [ ] `localhost:9999/oms/pricing` → OMS pricing page +- [ ] `localhost:9999/oms/vendors/{code}/` → Vendor storefront +- [ ] `localhost:9999/loyalty/` → Loyalty homepage + +--- + +## Phase 6: Loyalty Platform Setup + +### 6.1 Database Setup + +```sql +-- Insert loyalty platform +INSERT INTO platforms (code, name, description, domain, path_prefix, ...) +VALUES ('loyalty', 'Loyalty+', 'Customer loyalty program', 'loyalty.lu', 'loyalty', ...); +``` + +### 6.2 Create Platform Pages + +- [ ] Loyalty homepage +- [ ] Loyalty pricing +- [ ] Loyalty features +- [ ] How it works + +### 6.3 Create Vendor Defaults + +- [ ] About (loyalty-specific) +- [ ] Rewards catalog +- [ ] Terms of service +- [ ] Privacy policy + +--- + +## Documentation Requirements + +### Architecture Documentation + +Create `docs/architecture/multi-platform-cms.md`: +- [ ] Three-tier content hierarchy explanation +- [ ] Platform vs Vendor Default vs Vendor Override +- [ ] Database schema diagrams +- [ ] Request flow diagrams + +### API Documentation + +Update OpenAPI specs: +- [ ] Platform endpoints +- [ ] Content page endpoints with platform_id +- [ ] Vendor platform membership endpoints + +### Developer Guide + +Create `docs/guides/adding-new-platform.md`: +- [ ] Step-by-step platform creation +- [ ] Required database records +- [ ] Required config files +- [ ] Required routes and templates + +--- + +## Quick Reference + +### Three-Tier Content Resolution + +``` +Customer visits: oms.lu/vendors/wizamart/about + │ + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ Tier 1: Vendor Override │ +│ WHERE platform_id=1 AND vendor_id=123 AND slug='about' │ +│ Found? → Return vendor's custom page │ +└─────────────────────────────────────────────────────────────┘ + │ Not found + ▼ +┌─────────────────────────────────────────────────────────────┐ +│ Tier 2: Vendor Default │ +│ WHERE platform_id=1 AND vendor_id IS NULL │ +│ AND is_platform_page=FALSE AND slug='about' │ +│ Found? → Return platform default │ +└─────────────────────────────────────────────────────────────┘ + │ Not found + ▼ + Return 404 +``` + +### CMS Tier Limits + +| Tier | Total Pages | Custom Pages | +|------|-------------|--------------| +| Essential | 3 | 0 | +| Professional | 10 | 5 | +| Business | 30 | 20 | +| Enterprise | Unlimited | Unlimited | + +### Platform Marketing Page Slugs + +`home`, `platform_homepage`, `pricing`, `about`, `contact`, `faq`, `terms`, `privacy`, `features`, `integrations` + +--- + +## Next Session Checklist + +Start here when resuming work: + +1. [ ] Run `alembic upgrade head` (backup DB first!) +2. [ ] Verify migration: `SELECT * FROM platforms;` +3. [ ] Register PlatformContextMiddleware in `main.py` +4. [ ] Update VendorContextMiddleware to use `platform_clean_path` +5. [ ] Fix platform homepage to use CMS +6. [ ] Test: `localhost:9999/oms/` shows CMS homepage +7. [ ] Test: Three-tier resolution works + +--- + +## Files Created/Modified in Phase 1 + +### New Files (17) +``` +models/database/platform.py +models/database/vendor_platform.py +middleware/platform_context.py +alembic/versions/z4e5f6a7b8c9_add_multi_platform_support.py +app/platforms/__init__.py +app/platforms/oms/__init__.py +app/platforms/oms/config.py +app/platforms/oms/routes/__init__.py +app/platforms/oms/templates/__init__.py +app/platforms/loyalty/__init__.py +app/platforms/loyalty/config.py +app/platforms/loyalty/routes/__init__.py +app/platforms/loyalty/templates/__init__.py +app/platforms/shared/__init__.py +app/platforms/shared/base_platform.py +app/platforms/shared/routes/__init__.py +app/platforms/shared/templates/__init__.py +``` + +### Modified Files (7) +``` +models/database/__init__.py +models/database/content_page.py +models/database/subscription.py +models/database/feature.py +models/database/vendor.py +middleware/__init__.py +app/services/content_page_service.py +``` + +--- + +## Notes + +- Git tag `v1.0.0-pre-multiplatform` was created before starting +- All existing `content_pages` will be backfilled to OMS platform +- All existing vendors will be linked to OMS via `vendor_platforms` +- Migration is reversible (see downgrade function in migration file)