From abcbf687ae8848d94b315a4baf738144ecdb10fb Mon Sep 17 00:00:00 2001 From: alorig <220087330+alorig@users.noreply.github.com> Date: Tue, 18 Nov 2025 03:27:56 +0500 Subject: [PATCH] Phase 4 pending --- .../phases/FRONTEND-VERIFICATION-REPORT.md | 290 ----- ...ASE-5-7-9-SITES-RENDERER-INTEGRATION-UI.md | 1144 +++++++++++++++++ .../planning/phases/PHASE-5-SITES-RENDERER.md | 181 --- .../PHASE-6-SITE-INTEGRATION-PUBLISHING.md | 242 ---- .../PHASE-7-UI-COMPONENTS-MODULE-SETTINGS.md | 205 --- ...9-AI-FRAMEWORK-SITE-BUILDER-INTEGRATION.md | 682 ---------- 6 files changed, 1144 insertions(+), 1600 deletions(-) delete mode 100644 docs/planning/phases/FRONTEND-VERIFICATION-REPORT.md create mode 100644 docs/planning/phases/PHASE-5-7-9-SITES-RENDERER-INTEGRATION-UI.md delete mode 100644 docs/planning/phases/PHASE-5-SITES-RENDERER.md delete mode 100644 docs/planning/phases/PHASE-6-SITE-INTEGRATION-PUBLISHING.md delete mode 100644 docs/planning/phases/PHASE-7-UI-COMPONENTS-MODULE-SETTINGS.md delete mode 100644 docs/planning/phases/PHASE-9-AI-FRAMEWORK-SITE-BUILDER-INTEGRATION.md diff --git a/docs/planning/phases/FRONTEND-VERIFICATION-REPORT.md b/docs/planning/phases/FRONTEND-VERIFICATION-REPORT.md deleted file mode 100644 index 2c3992d3..00000000 --- a/docs/planning/phases/FRONTEND-VERIFICATION-REPORT.md +++ /dev/null @@ -1,290 +0,0 @@ -# FRONTEND FEATURES VERIFICATION REPORT -**Phase 0-4 Frontend Implementation Status** - -**Date**: 2025-01-XX -**Status**: Verification Complete - ---- - -## VERIFICATION SUMMARY - -| Feature Category | Status | Notes | -|-----------------|--------|-------| -| **Credit Balance Display** | ✅ **VERIFIED** | HeaderMetrics component displays credit balance automatically (FIXED) | -| **Automation Navigation** | ✅ **VERIFIED** | Properly configured in AppSidebar | -| **Site Dashboard** | ✅ **VERIFIED** | Exists in site-builder app | -| **Phase 4 Pages** | ✅ **VERIFIED** | All pages exist and properly configured | -| **Phase 4 Components** | ✅ **VERIFIED** | All components exist and properly implemented | - ---- - -## DETAILED VERIFICATION - -### 1. CREDIT BALANCE DISPLAY IN HEADER - -**Status**: ✅ **FULLY IMPLEMENTED** - -**What Exists**: -- ✅ `HeaderMetrics` component (`frontend/src/components/header/HeaderMetrics.tsx`) -- ✅ `HeaderMetricsContext` (`frontend/src/context/HeaderMetricsContext.tsx`) -- ✅ `HeaderMetrics` imported and rendered in `AppHeader.tsx` (line 163) -- ✅ `CreditBalanceWidget` component exists for dashboard display -- ✅ **Credit balance automatically loaded and displayed in header** (FIXED) - -**Implementation**: -- ✅ Credit balance loaded in `AppLayout.tsx` using `useBillingStore` -- ✅ Balance automatically set in HeaderMetrics using `useHeaderMetrics().setMetrics()` -- ✅ Color-coded display based on credit level: - - Green: > 1000 credits (high) - - Blue: > 100 credits (normal) - - Amber: > 0 credits (low) - - Purple: 0 credits (critical) -- ✅ Updates automatically when balance changes -- ✅ Clears when user logs out - ---- - -### 2. AUTOMATION PAGES NAVIGATION - -**Status**: ✅ **VERIFIED** - -**What Exists**: -- ✅ Automation menu item in `AppSidebar.tsx` (lines 161-168) -- ✅ Module enable check: `if (moduleEnabled('automation'))` -- ✅ Route configured: `/automation` -- ✅ Route in `App.tsx` (line 337-343) with ModuleGuard -- ✅ `AutomationDashboard` component exists (`frontend/src/pages/Automation/Dashboard.tsx`) - -**Configuration**: -```typescript -// AppSidebar.tsx - Lines 161-168 -if (moduleEnabled('automation')) { - workflowItems.push({ - icon: , - name: "Automation", - path: "/automation", - }); -} -``` - -**Route Configuration**: -```typescript -// App.tsx - Lines 337-343 - - - - - -} /> -``` - -**Status**: ✅ **FULLY CONFIGURED AND WORKING** - ---- - -### 3. SITE DASHBOARD PAGE - -**Status**: ✅ **VERIFIED** - -**What Exists**: -- ✅ `SiteDashboard.tsx` exists (`site-builder/src/pages/dashboard/SiteDashboard.tsx`) -- ✅ Component properly implemented with: - - Blueprint listing - - Loading states - - Error handling - - API integration (`builderApi.listBlueprints()`) - -**Implementation Details**: -- Uses `builderApi` from `site-builder/src/api/builder.api.ts` -- Displays blueprint list with status indicators -- Handles empty state -- Proper TypeScript typing - -**Status**: ✅ **FULLY IMPLEMENTED** - ---- - -### 4. PHASE 4 FRONTEND PAGES - -**Status**: ✅ **ALL VERIFIED** - -#### 4.1 Linker Pages - -| Page | File | Status | Notes | -|------|------|--------|-------| -| **Linker Dashboard** | `frontend/src/pages/Linker/Dashboard.tsx` | ✅ **VERIFIED** | Exists, properly implemented with stats | -| **Linker Content List** | `frontend/src/pages/Linker/ContentList.tsx` | ✅ **VERIFIED** | Exists, includes link processing functionality | - -**Routes Configured**: -- ✅ `/linker` → `LinkerDashboard` (App.tsx line 220-226) -- ✅ `/linker/content` → `LinkerContentList` (App.tsx line 227-233) -- ✅ Both routes wrapped in `ModuleGuard module="linker"` - -#### 4.2 Optimizer Pages - -| Page | File | Status | Notes | -|------|------|--------|-------| -| **Optimizer Dashboard** | `frontend/src/pages/Optimizer/Dashboard.tsx` | ✅ **VERIFIED** | Exists, properly implemented with stats | -| **Content Selector** | `frontend/src/pages/Optimizer/ContentSelector.tsx` | ✅ **VERIFIED** | Exists, includes batch optimization and filters | -| **Analysis Preview** | `frontend/src/pages/Optimizer/AnalysisPreview.tsx` | ✅ **VERIFIED** | Exists, displays analysis scores | - -**Routes Configured**: -- ✅ `/optimizer` → `OptimizerDashboard` (App.tsx line 236-242) -- ✅ `/optimizer/content` → `OptimizerContentSelector` (App.tsx line 243-249) -- ✅ `/optimizer/analyze/:id` → `AnalysisPreview` (App.tsx line 250-256) -- ✅ All routes wrapped in `ModuleGuard module="optimizer"` - ---- - -### 5. PHASE 4 FRONTEND COMPONENTS - -**Status**: ✅ **ALL VERIFIED** - -#### 5.1 Content Components - -| Component | File | Status | Implementation | -|-----------|------|--------|----------------| -| **SourceBadge** | `frontend/src/components/content/SourceBadge.tsx` | ✅ **VERIFIED** | Properly implemented with 4 source types | -| **SyncStatusBadge** | `frontend/src/components/content/SyncStatusBadge.tsx` | ✅ **VERIFIED** | Properly implemented with 3 status types | -| **ContentFilter** | `frontend/src/components/content/ContentFilter.tsx` | ✅ **VERIFIED** | Full filter implementation with source/sync status/search | - -#### 5.2 Linker Components - -| Component | File | Status | Implementation | -|-----------|------|--------|----------------| -| **LinkResults** | `frontend/src/components/linker/LinkResults.tsx` | ✅ **VERIFIED** | Displays links added count, version, link details | - -#### 5.3 Optimizer Components - -| Component | File | Status | Implementation | -|-----------|------|--------|----------------| -| **OptimizationScores** | `frontend/src/components/optimizer/OptimizationScores.tsx` | ✅ **VERIFIED** | Full implementation with SEO, readability, engagement, overall scores | -| **ScoreComparison** | `frontend/src/components/optimizer/ScoreComparison.tsx` | ✅ **VERIFIED** | Before/after comparison with improvement calculations | - -#### 5.4 API Clients - -| Client | File | Status | Functions | -|--------|------|--------|-----------| -| **Linker API** | `frontend/src/api/linker.api.ts` | ✅ **VERIFIED** | `process()`, `batchProcess()` | -| **Optimizer API** | `frontend/src/api/optimizer.api.ts` | ✅ **VERIFIED** | `optimize()`, `batchOptimize()`, `analyze()` | - ---- - -### 6. WRITER INTEGRATION (Phase 4) - -**Status**: ✅ **VERIFIED** - -**What Exists**: -- ✅ Source and sync status columns in Content table (`frontend/src/pages/Writer/Content.tsx`) -- ✅ Source and sync status filters (`sourceFilter`, `syncStatusFilter` in Content.tsx lines 37-38) -- ✅ "Optimize" action button (uses `optimizerApi.optimize()`) -- ✅ Content config updated (`frontend/src/config/pages/content.config.tsx`) - -**Implementation**: -- Content page uses `SourceBadge` and `SyncStatusBadge` components -- Filters properly integrated -- Optimize action calls optimizer API - ---- - -### 7. SIDEBAR NAVIGATION - -**Status**: ✅ **VERIFIED** - -**What Exists**: -- ✅ Linker menu item in AppSidebar (lines 137-147) -- ✅ Optimizer menu item in AppSidebar (lines 149-159) -- ✅ Automation menu item in AppSidebar (lines 161-168) -- ✅ All items respect module enable settings -- ✅ Proper icons and submenu structure - -**Configuration**: -```typescript -// Linker -if (moduleEnabled('linker')) { - workflowItems.push({ - icon: , - name: "Linker", - subItems: [ - { name: "Dashboard", path: "/linker" }, - { name: "Content", path: "/linker/content" }, - ], - }); -} - -// Optimizer -if (moduleEnabled('optimizer')) { - workflowItems.push({ - icon: , - name: "Optimizer", - subItems: [ - { name: "Dashboard", path: "/optimizer" }, - { name: "Content", path: "/optimizer/content" }, - ], - }); -} -``` - ---- - -## ISSUES FOUND - -### Issue 1: Credit Balance Not in Header - -**Status**: ✅ **FIXED** - -**Fix Applied**: -- Added credit balance loading in `AppLayout.tsx` -- Credit balance now automatically displayed in header via HeaderMetrics -- Color coding based on credit level: - - Green: > 1000 credits - - Blue: > 100 credits - - Amber: > 0 credits - - Purple: 0 credits - -**Implementation**: -- Added `useBillingStore` and `useHeaderMetrics` hooks to AppLayout -- Added useEffect to load balance when authenticated -- Added useEffect to update HeaderMetrics when balance changes -- Balance automatically refreshes when user authenticates - ---- - -## SUMMARY - -### ✅ Fully Verified (Working) -- Automation pages navigation -- Site Dashboard page -- All Phase 4 pages (Linker Dashboard, Content List, Optimizer Dashboard, Content Selector, Analysis Preview) -- All Phase 4 components (SourceBadge, SyncStatusBadge, ContentFilter, LinkResults, OptimizationScores, ScoreComparison) -- All Phase 4 API clients (linker.api.ts, optimizer.api.ts) -- Writer integration (source/sync badges, filters, optimize action) -- Sidebar navigation (Linker, Optimizer, Automation) - -### ✅ Fully Implemented -- Credit Balance Display in Header (✅ FIXED - now automatically populated) - ---- - -## RECOMMENDATIONS - -1. ✅ **Add Credit Balance to Header** (COMPLETED) - - Credit balance now automatically displayed in header - - Color-coded based on credit level - - Updates automatically when balance changes - -2. **Test All Routes** (Priority: LOW) - - Verify all routes are accessible - - Test module enable/disable functionality - - Verify ModuleGuard works correctly - -3. **Verify API Integration** (Priority: LOW) - - Test all API calls work correctly - - Verify error handling - - Test with insufficient credits - ---- - -**END OF VERIFICATION REPORT** - diff --git a/docs/planning/phases/PHASE-5-7-9-SITES-RENDERER-INTEGRATION-UI.md b/docs/planning/phases/PHASE-5-7-9-SITES-RENDERER-INTEGRATION-UI.md new file mode 100644 index 00000000..00ba3e2b --- /dev/null +++ b/docs/planning/phases/PHASE-5-7-9-SITES-RENDERER-INTEGRATION-UI.md @@ -0,0 +1,1144 @@ +# PHASES 5-7 & 9: SITES RENDERER, INTEGRATION & UI +**Consolidated Implementation Plan** + +**Goal**: Build Sites renderer, multi-destination publishing, comprehensive UI system, and Site Builder enhancements. + +**Timeline**: 8.5-11 weeks +**Priority**: MEDIUM +**Dependencies**: Phase 0, Phase 1, Phase 3 + +--- + +## TABLE OF CONTENTS + +1. [Executive Summary](#executive-summary) +2. [Phase 5: Sites Renderer & Bulk Generation](#phase-5-sites-renderer--bulk-generation) +3. [Phase 6: Site Integration & Multi-Destination Publishing](#phase-6-site-integration--multi-destination-publishing) +4. [Phase 7: UI Components & Prompt Management](#phase-7-ui-components--prompt-management) +5. [Cross-Phase Integration](#cross-phase-integration) +6. [Testing & Validation](#testing--validation) +7. [Implementation Checklist](#implementation-checklist) +8. [Success Criteria](#success-criteria) + +--- + +## EXECUTIVE SUMMARY + +This document consolidates Phases 5, 6, 7, and 9 into a unified implementation plan: + +- **Phase 5**: Sites Renderer for hosting public sites + Bulk page generation from Site Builder +- **Phase 6**: Multi-destination publishing (WordPress, Sites, Shopify) + Site integrations + Enhanced task queuing +- **Phase 7**: Complete UI component library + Prompt management UI + Advanced site management + CMS styling + +**Key Exclusions** (Already Implemented): +- ✅ Module Settings UI (implemented in Phase 0) +- ✅ Module Guard component (implemented in Phase 0) +- ✅ Conditional route loading (implemented in Phase 0) +- ✅ Sidebar module filtering (implemented in Phase 0) +- ✅ GenerateSiteStructureFunction (implemented in Phase 3) +- ✅ Single page generation (implemented in Phase 3) +- ✅ File management service (implemented in Phase 3) + +--- + +## PHASE 5: SITES RENDERER & BULK GENERATION + +**Timeline**: 2.5-3.5 weeks +**Dependencies**: Phase 3 + +### 5.1 Overview + +**Objectives**: +- Create Sites renderer container for hosting public sites +- Build publisher service and deployment infrastructure +- Support multiple layout options (7 layout types) +- Enable bulk page content generation from Site Builder +- Deploy sites to public URLs +- Render sites from site definitions + +**Key Principles**: +- **Component Reuse**: Use shared component library from Phase 3 +- **Multiple Layouts**: Support 7 layout types +- **Public Access**: Sites accessible via public URLs +- **User-Friendly**: "My Websites" or "Published Sites" in UI +- **Bulk Operations**: Generate all pages at once before publishing + +### 5.2 Sites Renderer Container + +**User-Friendly Name**: "My Websites" or "Published Sites" + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Create Sites Container** | `docker-compose.app.yml` | None | Add new container for sites renderer | +| **Sites Renderer Frontend** | `sites/src/` | NEW | React app for rendering sites | +| **Site Definition Loader** | `sites/src/loaders/loadSiteDefinition.ts` | NEW | Load site definitions from API | +| **Layout Renderer** | `sites/src/utils/layoutRenderer.ts` | NEW | Render different layouts | +| **Template System** | `sites/src/utils/templateEngine.ts` | NEW | Template rendering system | +| **File Access Integration** | `sites/src/utils/fileAccess.ts` | Phase 3 | Integrate Phase 3's SiteBuilderFileService | +| **Component Import** | `sites/src/components/` | Phase 3 | Import shared components from `frontend/src/components/shared/` | + +**Docker Compose Configuration**: +```yaml +# docker-compose.app.yml +igny8_sites: + build: ./sites + ports: + - "8024:5176" + volumes: + - /data/app/igny8/sites:/app + - /data/app/sites-data:/sites + environment: + - VITE_API_URL=http://igny8_backend:8010 +``` + +**File Access Integration**: +- Sites Renderer must access site assets from `/data/app/sites-data/clients/{site_id}/v{version}/assets/` +- Use Phase 3's `SiteBuilderFileService` for file access patterns +- Ensure Sites Renderer can load images, documents, and media files + +### 5.3 Publisher Service + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **PublisherService** | `business/publishing/services/publisher_service.py` | Phase 1 | Main publishing service | +| **SitesRendererAdapter** | `business/publishing/services/adapters/sites_renderer_adapter.py` | Phase 3 | Adapter for Sites renderer | +| **DeploymentService** | `business/publishing/services/deployment_service.py` | Phase 3 | Deploy sites to renderer | + +**PublisherService Structure**: +```python +# business/publishing/services/publisher_service.py +class PublisherService: + def publish_to_sites(self, site_blueprint): + """Publish site to Sites renderer""" + adapter = SitesRendererAdapter() + return adapter.deploy(site_blueprint) + + def get_deployment_status(self, site_blueprint): + """Get deployment status for a site""" + return DeploymentService().get_status(site_blueprint) +``` + +**SitesRendererAdapter**: +- Write site definition to filesystem (`/data/app/sites-data/`) +- Update deployment records +- Handle versioning +- Support rollback + +**DeploymentService**: +- Manage deployment lifecycle +- Track deployment versions +- Handle deployment errors +- Support rollback capability + +### 5.4 Publishing Models + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **PublishingRecord Model** | `business/publishing/models.py` | Phase 1 | Track content publishing | +| **DeploymentRecord Model** | `business/publishing/models.py` | Phase 3 | Track site deployments | + +**PublishingRecord Model**: +```python +class PublishingRecord(SiteSectorBaseModel): + content = models.ForeignKey(Content, on_delete=models.CASCADE, null=True) + site_blueprint = models.ForeignKey(SiteBlueprint, on_delete=models.CASCADE, null=True) + destination = models.CharField(max_length=50) # 'wordpress', 'sites', 'shopify' + destination_id = models.CharField(max_length=255) # External ID + status = models.CharField(max_length=20) # 'pending', 'published', 'failed' + published_at = models.DateTimeField(null=True, blank=True) + metadata = models.JSONField(default=dict) +``` + +**DeploymentRecord Model**: +```python +class DeploymentRecord(SiteSectorBaseModel): + site_blueprint = models.ForeignKey(SiteBlueprint, on_delete=models.CASCADE) + version = models.IntegerField() + deployed_version = models.IntegerField() + status = models.CharField(max_length=20) # 'deploying', 'deployed', 'failed' + deployed_at = models.DateTimeField(null=True, blank=True) + deployment_url = models.URLField(blank=True, null=True) + metadata = models.JSONField(default=dict) +``` + +### 5.5 Publisher API + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Publisher ViewSet** | `modules/publisher/views.py` | PublisherService | API for publishing operations | + +**Publisher API Endpoints**: +- `POST /api/v1/publisher/publish/` - Publish content or site +- `GET /api/v1/publisher/status/{id}/` - Get publishing status +- `POST /api/v1/publisher/deploy/{blueprint_id}/` - Deploy site to renderer +- `GET /api/v1/publisher/deployments/` - List deployments + +### 5.6 Multiple Layout Options + +**Layout Types** (7 total): +- Default (Standard) +- Minimal (Clean, simple) +- Magazine (Editorial, content-focused) +- Ecommerce (Product-focused) +- Portfolio (Showcase) +- Blog (Content-first) +- Corporate (Business) + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Layout Configuration** | `business/site_building/models.py` | Phase 3 | Store layout selection in SiteBlueprint | +| **Layout Renderer** | `sites/src/utils/layoutRenderer.ts` | Phase 5 | Render different layouts | +| **Layout Components** | `sites/src/components/layouts/` | Phase 3 | Import from shared library | + +**Layout Storage**: +- Store `layout_type` in `SiteBlueprint.config_json` or as separate field +- Sites Renderer reads layout type and renders appropriate layout component +- Layout components from Phase 3 shared library + +### 5.7 Bulk Page Generation (From Phase 9) + +**Purpose**: Enable bulk generation of all pages from a Site Builder blueprint before publishing. + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Bulk Generate Service** | `business/site_building/services/page_generation_service.py` | Phase 3 | Add `bulk_generate_pages()` method | +| **Task Creation Service** | `business/site_building/services/page_generation_service.py` | Phase 3 | Add `create_tasks_for_pages()` method | +| **Bulk Generate API** | `modules/site_builder/views.py` | PageGenerationService | Add `generate_all_pages` action | +| **Bulk Generate UI** | `site-builder/src/pages/dashboard/SiteDashboard.tsx` | API client | Add "Generate All Pages" button | +| **Page Selection UI** | `site-builder/src/pages/preview/PreviewCanvas.tsx` | State store | Add checkbox selection for pages | +| **Progress Tracking** | `site-builder/src/components/common/ProgressModal.tsx` | Existing | Track bulk generation progress | + +**Bulk Generation Service**: +```python +# business/site_building/services/page_generation_service.py +class PageGenerationService: + def bulk_generate_pages( + self, + site_blueprint: SiteBlueprint, + page_ids: Optional[List[int]] = None, + force_regenerate: bool = False + ) -> dict: + """ + Generate content for multiple pages in a blueprint. + + Similar to how ideas are queued to writer: + 1. Get pages (filtered by page_ids if provided) + 2. Create/update Writer Tasks for each page + 3. Queue content generation for all tasks + 4. Return task IDs for progress tracking + """ + pages = site_blueprint.pages.all() + if page_ids: + pages = pages.filter(id__in=page_ids) + + task_ids = [] + for page in pages: + task = self._ensure_task(page, force_regenerate=force_regenerate) + task_ids.append(task.id) + page.status = 'generating' + page.save(update_fields=['status', 'updated_at']) + + account = site_blueprint.account + result = self.content_service.generate_content(task_ids, account) + + return { + 'success': True, + 'pages_queued': len(task_ids), + 'task_ids': task_ids, + 'celery_task_id': result.get('task_id'), + } + + def create_tasks_for_pages( + self, + site_blueprint: SiteBlueprint, + page_ids: Optional[List[int]] = None, + force_regenerate: bool = False + ) -> List[Tasks]: + """ + Create Writer Tasks for blueprint pages without generating content. + + Useful for: + - Previewing what tasks will be created + - Manual task management + - Integration with existing Writer UI + """ + pages = site_blueprint.pages.all() + if page_ids: + pages = pages.filter(id__in=page_ids) + + tasks = [] + for page in pages: + task = self._ensure_task(page, force_regenerate=force_regenerate) + tasks.append(task) + + return tasks +``` + +**Bulk Generation API**: +```python +# modules/site_builder/views.py +class SiteBlueprintViewSet(SiteSectorModelViewSet): + @action(detail=True, methods=['post']) + def generate_all_pages(self, request, pk=None): + """ + Generate content for all pages in blueprint. + + Request body: + { + "page_ids": [1, 2, 3], # Optional: specific pages, or all if omitted + "force": false # Optional: force regenerate existing content + } + """ + blueprint = self.get_object() + page_ids = request.data.get('page_ids') + force = request.data.get('force', False) + + service = PageGenerationService() + result = service.bulk_generate_pages( + blueprint, + page_ids=page_ids, + force_regenerate=force + ) + return success_response(result, request=request) + + @action(detail=True, methods=['post']) + def create_tasks(self, request, pk=None): + """Create Writer tasks for pages without generating content""" + blueprint = self.get_object() + page_ids = request.data.get('page_ids') + + service = PageGenerationService() + tasks = service.create_tasks_for_pages(blueprint, page_ids=page_ids) + + serializer = TasksSerializer(tasks, many=True) + return success_response({'tasks': serializer.data}, request=request) +``` + +**Frontend API Client**: +```typescript +// site-builder/src/api/builder.api.ts +export const builderApi = { + async generateAllPages( + blueprintId: number, + options?: { pageIds?: number[]; force?: boolean } + ): Promise<{ task_id: string; pages_queued: number }> { + const res = await client.post( + `/blueprints/${blueprintId}/generate_all_pages/`, + options || {} + ); + return res.data; + }, + + async createTasksForPages( + blueprintId: number, + pageIds?: number[] + ): Promise<{ tasks: Task[] }> { + const res = await client.post( + `/blueprints/${blueprintId}/create_tasks/`, + { page_ids: pageIds } + ); + return res.data; + }, +}; +``` + +### 5.8 Phase 5 Testing + +**Test Cases**: +- ✅ Sites renderer loads site definitions +- ✅ Blocks render correctly using shared components +- ✅ File access works (images, documents, media) +- ✅ Deployment works end-to-end +- ✅ Sites are accessible publicly +- ✅ Multiple layouts work correctly +- ✅ Bulk page generation works +- ✅ Progress tracking works +- ✅ Task creation works correctly + +--- + +## PHASE 6: SITE INTEGRATION & MULTI-DESTINATION PUBLISHING + +**Timeline**: 2.5-3 weeks +**Dependencies**: Phase 5 + +### 6.1 Overview + +**Objectives**: +- Support multiple site integrations per site +- Multi-destination publishing (WordPress, Sites, Shopify) +- Two-way sync with external platforms +- Site management UI (Core CMS features) +- Publishing settings UI +- Enhanced blueprint-to-writer task integration + +**Key Principles**: +- **Multiple Integrations**: One site can have multiple integrations +- **Adapter Pattern**: Platform-specific adapters for publishing +- **Two-Way Sync**: Sync content both ways +- **User-Friendly**: "Site Manager" or "Content Manager" in UI + +### 6.2 Site Integration Models + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **SiteIntegration Model** | `business/integration/models.py` | Phase 1 | Store integration configs | + +**SiteIntegration Model**: +```python +# business/integration/models.py +class SiteIntegration(SiteSectorBaseModel): + site = models.ForeignKey(Site, on_delete=models.CASCADE) + platform = models.CharField(max_length=50) # 'wordpress', 'shopify', 'custom' + platform_type = models.CharField(max_length=50) # 'cms', 'ecommerce', 'custom_api' + config_json = models.JSONField(default=dict) + credentials = models.EncryptedField() # Encrypted API keys + is_active = models.BooleanField(default=True) + sync_enabled = models.BooleanField(default=False) + last_sync_at = models.DateTimeField(null=True, blank=True) + sync_status = models.CharField(max_length=20) # 'success', 'failed', 'pending' + + class Meta: + db_table = 'igny8_site_integrations' + unique_together = [['site', 'platform']] +``` + +### 6.3 Integration Service + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **IntegrationService** | `business/integration/services/integration_service.py` | Phase 1 | Manage integrations | +| **SyncService** | `business/integration/services/sync_service.py` | Phase 1 | Handle two-way sync | +| **ContentSyncService** | `business/integration/services/content_sync_service.py` | Phase 1 | Sync content from external platforms | + +**IntegrationService**: +- CRUD operations for SiteIntegration +- Integration validation +- Credential management (encrypted) +- Connection testing + +**SyncService**: +- Two-way sync logic +- Sync status tracking +- Error handling +- Sync logging + +**ContentSyncService**: +- Sync content from WordPress +- Sync content from Shopify +- Sync content from custom APIs +- Import content with source tracking + +### 6.4 Publishing Adapters + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **BaseAdapter** | `business/publishing/services/adapters/base_adapter.py` | Phase 5 | Base adapter interface | +| **WordPressAdapter** | `business/publishing/services/adapters/wordpress_adapter.py` | EXISTING (refactor) | WordPress publishing | +| **SitesRendererAdapter** | `business/publishing/services/adapters/sites_renderer_adapter.py` | Phase 5 | IGNY8 Sites deployment | +| **ShopifyAdapter** | `business/publishing/services/adapters/shopify_adapter.py` | Phase 5 (future) | Shopify publishing | + +**BaseAdapter Interface**: +```python +# business/publishing/services/adapters/base_adapter.py +class BaseAdapter(ABC): + @abstractmethod + def publish(self, content, destination_config): + """Publish content to destination""" + pass + + @abstractmethod + def test_connection(self, config): + """Test connection to destination""" + pass + + @abstractmethod + def get_status(self, published_id): + """Get publishing status""" + pass +``` + +**WordPressAdapter Refactor**: +- Refactor existing WordPress publishing to use BaseAdapter +- Preserve all existing functionality +- Add adapter interface compliance +- Test backward compatibility + +### 6.5 Multi-Destination Publishing + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Extend PublisherService** | `business/publishing/services/publisher_service.py` | Phase 5 | Support multiple destinations | +| **Update PublishingRecord** | `business/publishing/models.py` | Phase 5 | Track multiple destinations | + +**Multi-Destination Publishing**: +```python +# business/publishing/services/publisher_service.py +class PublisherService: + def publish(self, content, destinations): + """ + Publish content to multiple destinations. + + Args: + content: Content or SiteBlueprint to publish + destinations: List of destination configs + + Returns: + List of publishing results + """ + results = [] + for destination in destinations: + adapter = self.get_adapter(destination['platform']) + result = adapter.publish(content, destination) + results.append(result) + return results + + def get_adapter(self, platform): + """Get adapter for platform""" + adapters = { + 'wordpress': WordPressAdapter(), + 'sites': SitesRendererAdapter(), + 'shopify': ShopifyAdapter(), + } + return adapters.get(platform) +``` + +**PublishingRecord Updates**: +- Support multiple destinations per content +- Track status per destination +- Store destination-specific metadata + +### 6.6 Site Model Extensions + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Add site_type field** | `core/auth/models.py` | None | Track site type | +| **Add hosting_type field** | `core/auth/models.py` | None | Track hosting type | +| **Add integrations relationship** | `core/auth/models.py` | Phase 6.2 | Link to SiteIntegration | + +**Site Model Extensions**: +```python +# core/auth/models.py +class Site(SiteSectorBaseModel): + # Existing fields... + + # NEW fields + site_type = models.CharField( + max_length=50, + choices=[ + ('marketing', 'Marketing Site'), + ('ecommerce', 'Ecommerce Site'), + ('blog', 'Blog'), + ('portfolio', 'Portfolio'), + ('corporate', 'Corporate'), + ], + default='marketing' + ) + + hosting_type = models.CharField( + max_length=50, + choices=[ + ('igny8_sites', 'IGNY8 Sites'), + ('wordpress', 'WordPress'), + ('shopify', 'Shopify'), + ('multi', 'Multi-Destination'), + ], + default='igny8_sites' + ) +``` + +### 6.7 Integration API + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Integration ViewSet** | `modules/integration/views.py` | IntegrationService | CRUD for integrations | +| **Integration URLs** | `modules/integration/urls.py` | None | Register integration routes | + +**Integration API Endpoints**: +- `GET /api/v1/integration/integrations/` - List integrations +- `POST /api/v1/integration/integrations/` - Create integration +- `GET /api/v1/integration/integrations/{id}/` - Get integration +- `PUT /api/v1/integration/integrations/{id}/` - Update integration +- `DELETE /api/v1/integration/integrations/{id}/` - Delete integration +- `POST /api/v1/integration/integrations/{id}/test/` - Test connection +- `POST /api/v1/integration/integrations/{id}/sync/` - Trigger sync + +### 6.8 Integration UI (Update Existing) + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Update Integration Settings** | `frontend/src/pages/Settings/Integration.tsx` | EXISTING (update) | Add SiteIntegration support | +| **Multi-Platform Support** | `frontend/src/components/integration/PlatformSelector.tsx` | NEW | Platform selector | +| **Integration Status** | `frontend/src/components/integration/IntegrationStatus.tsx` | NEW | Show integration status | + +**Integration UI Features**: +- Show multiple integrations per site +- Add WordPress, Shopify, Custom API options +- Two-way sync toggle +- Connection testing +- Sync status display +- Last sync timestamp + +### 6.9 Publishing Settings UI + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Publishing Settings Page** | `frontend/src/pages/Settings/Publishing.tsx` | NEW | Publishing configuration | +| **Destination Management** | `frontend/src/pages/Settings/Publishing.tsx` | Phase 6 | Manage publishing destinations | +| **Publishing Rules** | `frontend/src/components/publishing/PublishingRules.tsx` | NEW | Publishing rules configuration | +| **Auto-Publish Settings** | `frontend/src/components/publishing/AutoPublishSettings.tsx` | NEW | Auto-publish configuration | + +**Publishing Settings Features**: +- Configure default publishing destinations +- Set up publishing rules (auto-publish, manual, scheduled) +- Manage destination priorities +- Configure auto-publish triggers + +### 6.10 Site Management UI (Core CMS) + +**User-Friendly Name**: "Site Manager" or "Content Manager" + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Site Management Dashboard** | `frontend/src/pages/Sites/Manage.tsx` | NEW | Site management overview | +| **Site Content Editor** | `frontend/src/pages/Sites/Editor.tsx` | NEW | Edit site content | +| **Post Editor** | `frontend/src/pages/Sites/PostEditor.tsx` | NEW | Edit posts | +| **Page Manager** | `frontend/src/pages/Sites/PageManager.tsx` | NEW | Manage pages | +| **Site Settings** | `frontend/src/pages/Sites/Settings.tsx` | NEW | Site settings | + +**Site Management Features** (Core): +- View all pages/posts for a site +- Add new pages +- Remove pages +- Edit page content +- Manage page order +- Change page templates +- Update site settings +- Basic site preview + +### 6.11 Enhanced Task Integration (From Phase 9) + +**Purpose**: Better integration between Site Builder tasks and Writer UI. + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Show Site Builder Tasks** | `frontend/src/pages/Writer/Content.tsx` | Existing | Filter tasks with "[Site Builder]" prefix | +| **Link to Blueprint** | `frontend/src/pages/Writer/Content.tsx` | API | Add link to source blueprint | +| **Bulk Actions** | `frontend/src/pages/Writer/Content.tsx` | Existing | Include Site Builder tasks in bulk actions | + +**Task Identification**: +- Tasks created from Site Builder have title prefix: `"[Site Builder] {page_title}"` +- Can filter Writer tasks by this prefix +- Can link back to source PageBlueprint via task description + +**Writer UI Enhancements**: +- Filter by source (Site Builder, Ideas, Manual) +- Show source blueprint link +- Include in bulk operations +- Show page type and site name + +### 6.12 Phase 6 Testing + +**Test Cases**: +- ✅ Site integrations work correctly +- ✅ Multi-destination publishing works +- ✅ WordPress sync works (when plugin connected) +- ✅ Two-way sync functions properly +- ✅ Site management UI works (core features) +- ✅ Publishing settings work +- ✅ Task integration works +- ✅ Adapter pattern works correctly + +--- + +## PHASE 7: UI COMPONENTS & PROMPT MANAGEMENT + +**Timeline**: 3.5-4.5 weeks +**Dependencies**: Phase 0, Phase 3, Phase 5 + +### 7.1 Overview + +**Objectives**: +- Complete global component library +- Add prompt management UI for Site Builder +- Build advanced site management UI +- Create layout and template system +- Implement CMS styling system + +**Key Principles**: +- **No Duplication**: All components shared across apps +- **TypeScript**: All components use TypeScript +- **Accessibility**: All components accessible (ARIA) +- **Responsive**: All components responsive + +### 7.2 Global Component Library + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Component Library Structure** | `frontend/src/components/shared/` | Phase 3 | Complete component library | +| **Block Components** | `frontend/src/components/shared/blocks/` | Phase 3 | All block components | +| **Layout Components** | `frontend/src/components/shared/layouts/` | Phase 3 | All layout components | +| **Template Components** | `frontend/src/components/shared/templates/` | Phase 3 | All template components | +| **Component Documentation** | `frontend/src/components/shared/README.md` | None | Document all components | +| **Component Storybook** | `frontend/.storybook/` | Optional | Component documentation | +| **Component Tests** | `frontend/src/components/shared/**/*.test.tsx` | None | Test all components | + +**Component Standards**: +- All components use TypeScript +- All components have props interfaces +- All components are responsive +- All components support dark mode +- All components are accessible (ARIA) +- No duplicate components + +**Block Components to Complete**: +- HeroBlock +- FeatureGridBlock +- StatsPanel +- ServicesBlock +- ProductsBlock +- TestimonialsBlock +- ContactFormBlock +- CTABlock +- ImageGalleryBlock +- VideoBlock +- TextBlock +- QuoteBlock + +**Layout Components to Complete** (7 total): +- DefaultLayout +- MinimalLayout +- MagazineLayout +- EcommerceLayout +- PortfolioLayout +- BlogLayout +- CorporateLayout + +**Template Components to Complete**: +- BlogTemplate +- BusinessTemplate +- PortfolioTemplate +- EcommerceTemplate +- LandingTemplate +- MarketingTemplate + +### 7.3 Prompt Management UI (From Phase 9) + +**Purpose**: Add Site Builder prompt to Thinker `/prompts` interface. + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Add prompt type to backend** | `modules/system/models.py` | Existing | Add `'site_structure_generation'` to PROMPT_TYPE_CHOICES | +| **Create migration** | `modules/system/migrations/XXXX_add_site_structure_prompt_type.py` | Existing | Add new choice to PROMPT_TYPE_CHOICES | +| **Add prompt type to frontend** | `frontend/src/pages/Thinker/Prompts.tsx` | Existing | Add site_structure_generation to PROMPT_TYPES array | +| **Add Site Builder section** | `frontend/src/pages/Thinker/Prompts.tsx` | Existing | Add "Site Builder" section to Prompts page | +| **Add prompt editor** | `frontend/src/pages/Thinker/Prompts.tsx` | Existing | Add prompt editor for site structure generation | + +**Backend Model Update**: +```python +# modules/system/models.py +class AIPrompt(AccountBaseModel): + PROMPT_TYPE_CHOICES = [ + ('clustering', 'Clustering'), + ('ideas', 'Ideas Generation'), + ('content_generation', 'Content Generation'), + ('image_prompt_extraction', 'Image Prompt Extraction'), + ('image_prompt_template', 'Image Prompt Template'), + ('negative_prompt', 'Negative Prompt'), + ('site_structure_generation', 'Site Structure Generation'), # NEW + ] +``` + +**Frontend Prompt Type Config**: +```typescript +// frontend/src/pages/Thinker/Prompts.tsx +const PROMPT_TYPES = [ + // ... existing prompts + { + key: 'site_structure_generation', + label: 'Site Structure Generation', + description: 'Generate site structure from business brief. Use [IGNY8_BUSINESS_BRIEF], [IGNY8_OBJECTIVES], [IGNY8_STYLE], and [IGNY8_SITE_INFO] to inject data.', + icon: '🏗️', + color: 'teal', + }, +]; +``` + +**Prompt UI Section**: +```typescript +{/* Site Builder Prompts Section */} +
+
+

+ Site Builder +

+

+ Configure prompts for AI-powered site structure generation +

+
+ + {/* Site Structure Generation Prompt */} + +
+``` + +### 7.4 Site Management UI (Advanced Features) + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Site List View** | `frontend/src/pages/Sites/List.tsx` | NEW | List all sites with filters | +| **Site Dashboard** | `frontend/src/pages/Sites/Dashboard.tsx` | NEW | Site overview with stats | +| **Site Content Manager** | `frontend/src/pages/Sites/Content.tsx` | NEW | Manage site content (posts/pages list) | +| **Post Editor** | `frontend/src/pages/Sites/PostEditor.tsx` | NEW | Full-featured post editor | +| **Page Manager** | `frontend/src/pages/Sites/Pages.tsx` | NEW | Advanced page management | +| **Site Settings** | `frontend/src/pages/Sites/Settings.tsx` | NEW | Advanced site settings + SEO | +| **Site Preview** | `frontend/src/pages/Sites/Preview.tsx` | NEW | Live site preview | + +**Site Management Features** (Advanced): +- Site list with filters (type, status, integration) +- Site dashboard with statistics +- Content manager with search and filters +- Full-featured post/page editor +- Advanced page management (drag-drop reorder, bulk actions) +- SEO settings (meta tags, Open Graph, schema) +- Live site preview with iframe +- Site analytics integration + +### 7.5 Layout & Template System + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Layout Selector** | `frontend/src/components/sites/LayoutSelector.tsx` | NEW | Select layout | +| **Template Library** | `frontend/src/components/sites/TemplateLibrary.tsx` | NEW | Template library | +| **Layout Preview** | `frontend/src/components/sites/LayoutPreview.tsx` | NEW | Preview layouts | +| **Template Customizer** | `frontend/src/components/sites/TemplateCustomizer.tsx` | NEW | Customize templates | +| **Style Editor** | `frontend/src/components/sites/StyleEditor.tsx` | NEW | Edit styles | + +**Layout Options** (7 total): +- Default Layout +- Minimal Layout +- Magazine Layout +- Ecommerce Layout +- Portfolio Layout +- Blog Layout +- Corporate Layout + +**Template System**: +- Pre-built templates +- Custom templates +- Template customization +- Style presets +- Color schemes +- Typography options + +### 7.6 CMS Styling System + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **CMS Theme System** | `frontend/src/styles/cms/` | NEW | Theme system | +| **Style Presets** | `frontend/src/styles/cms/presets.ts` | NEW | Style presets | +| **Color Schemes** | `frontend/src/styles/cms/colors.ts` | NEW | Color schemes | +| **Typography System** | `frontend/src/styles/cms/typography.ts` | NEW | Typography system | +| **Component Styles** | `frontend/src/styles/cms/components.ts` | NEW | Component styles | + +**CMS Features**: +- Theme customization +- Color palette management +- Typography settings +- Component styling +- Responsive breakpoints +- Dark/light mode + +### 7.7 Module Enhancements (Optional) + +**Note**: Module Settings UI is already implemented in Phase 0. These are optional enhancements. + +| Task | File | Dependencies | Implementation | +|------|------|--------------|----------------| +| **Module Dependencies Check** | `frontend/src/components/settings/ModuleDependencies.tsx` | NEW | Show module dependencies | +| **Module Usage Statistics** | `frontend/src/components/settings/ModuleStats.tsx` | NEW | Show module usage stats | +| **Module Configuration UI** | `frontend/src/components/settings/ModuleConfig.tsx` | NEW | Per-module configuration | + +**Module Enhancement Features** (Optional): +- Module dependencies check (warnings when disabling dependent modules) +- Module usage statistics (show usage per module) +- Module-specific configuration UI (per-module settings) + +### 7.8 Phase 7 Testing + +**Test Cases**: +- ✅ All components render correctly +- ✅ Component library is complete +- ✅ Prompt management UI works +- ✅ Site management works end-to-end (advanced features) +- ✅ Layout system works +- ✅ Template system works +- ✅ CMS styling system works +- ✅ No duplicate components +- ✅ All components are accessible +- ✅ All components are responsive + +--- + +## CROSS-PHASE INTEGRATION + +### Service Dependencies + +**Phase 5 Uses**: +- Phase 3: Shared components, file management, SiteBlueprint/PageBlueprint models +- Phase 1: ContentGenerationService (for bulk generation) +- Phase 0: CreditService (for credit checks) + +**Phase 6 Uses**: +- Phase 5: PublisherService, SitesRendererAdapter, DeploymentService +- Phase 3: SiteBlueprint models +- Phase 1: ContentGenerationService, ContentSyncService +- Phase 0: CreditService + +**Phase 7 Uses**: +- Phase 3: Shared component library (completes it) +- Phase 5: Sites Renderer (for preview) +- Phase 6: Site Management (enhances it) +- Phase 0: Module Settings backend (adds UI enhancements) + +### Workflow Integration + +**Complete Site Workflow**: +1. User creates site blueprint via Site Builder (Phase 3) +2. User generates all pages via bulk generation (Phase 5) +3. Content generated via Writer (Phase 1) +4. Site deployed to Sites Renderer (Phase 5) +5. Site published to multiple destinations (Phase 6) +6. Site managed via Site Management UI (Phase 6 & 7) +7. Prompts managed via Thinker UI (Phase 7) + +**Content Publishing Workflow**: +1. Content generated in Writer (Phase 1) +2. Content optimized via Optimizer (Phase 4) +3. Content published to multiple destinations (Phase 6) +4. Publishing tracked in PublishingRecord (Phase 5 & 6) + +--- + +## TESTING & VALIDATION + +### Phase 5 Testing + +**Sites Renderer Tests**: +- ✅ Sites renderer loads site definitions +- ✅ Blocks render correctly using shared components +- ✅ File access works (images, documents, media) +- ✅ Deployment works end-to-end +- ✅ Sites are accessible publicly +- ✅ Multiple layouts work correctly + +**Bulk Generation Tests**: +- ✅ Bulk page generation works +- ✅ Progress tracking works +- ✅ Task creation works correctly +- ✅ Selected pages can be generated +- ✅ Force regenerate works + +### Phase 6 Testing + +**Integration Tests**: +- ✅ Site integrations work correctly +- ✅ Multi-destination publishing works +- ✅ WordPress sync works (when plugin connected) +- ✅ Two-way sync functions properly +- ✅ Adapter pattern works correctly + +**Site Management Tests**: +- ✅ Site management UI works (core features) +- ✅ Publishing settings work +- ✅ Task integration works +- ✅ Content sync works + +### Phase 7 Testing + +**Component Library Tests**: +- ✅ All components render correctly +- ✅ Component library is complete +- ✅ No duplicate components +- ✅ All components are accessible +- ✅ All components are responsive + +**UI Tests**: +- ✅ Prompt management UI works +- ✅ Site management works end-to-end (advanced features) +- ✅ Layout system works +- ✅ Template system works +- ✅ CMS styling system works + +--- + +## IMPLEMENTATION CHECKLIST + +### Phase 5: Sites Renderer & Bulk Generation + +#### Backend Tasks +- [ ] Create PublisherService +- [ ] Create SitesRendererAdapter +- [ ] Create DeploymentService +- [ ] Create PublishingRecord model +- [ ] Create DeploymentRecord model +- [ ] Create Publisher ViewSet +- [ ] Add bulk_generate_pages() to PageGenerationService +- [ ] Add create_tasks_for_pages() to PageGenerationService +- [ ] Add generate_all_pages action to SiteBlueprintViewSet +- [ ] Add create_tasks action to SiteBlueprintViewSet +- [ ] Database migrations + +#### Frontend Tasks +- [ ] Create Sites container in docker-compose +- [ ] Create sites renderer frontend +- [ ] Create site definition loader +- [ ] Create layout renderer +- [ ] Create template system +- [ ] Import shared components +- [ ] Integrate file access +- [ ] Add "Generate All Pages" button to Site Builder +- [ ] Add page selection UI +- [ ] Add progress tracking +- [ ] Add bulk generation API methods + +### Phase 6: Site Integration & Multi-Destination Publishing + +#### Backend Tasks +- [ ] Create SiteIntegration model +- [ ] Create IntegrationService +- [ ] Create SyncService +- [ ] Create ContentSyncService +- [ ] Create BaseAdapter +- [ ] Refactor WordPressAdapter +- [ ] Create SitesRendererAdapter (if not done in Phase 5) +- [ ] Create ShopifyAdapter (skeleton) +- [ ] Extend PublisherService for multi-destination +- [ ] Extend Site model (site_type, hosting_type) +- [ ] Create Integration ViewSet +- [ ] Database migrations + +#### Frontend Tasks +- [ ] Update Integration Settings page +- [ ] Create Publishing Settings page +- [ ] Create Site Management Dashboard (core) +- [ ] Create Site Content Editor (core) +- [ ] Create Page Manager (core) +- [ ] Create Site Settings (core) +- [ ] Create PlatformSelector component +- [ ] Create IntegrationStatus component +- [ ] Create PublishingRules component +- [ ] Update Writer UI for Site Builder tasks + +### Phase 7: UI Components & Prompt Management + +#### Backend Tasks +- [ ] Add site_structure_generation to AIPrompt.PROMPT_TYPE_CHOICES +- [ ] Create migration for new prompt type + +#### Frontend Tasks +- [ ] Complete component library (blocks, layouts, templates) +- [ ] Add site_structure_generation to PROMPT_TYPES +- [ ] Add "Site Builder" section to Prompts page +- [ ] Add prompt editor for site structure generation +- [ ] Create Site List View +- [ ] Create Site Dashboard (advanced) +- [ ] Create Site Content Manager (advanced) +- [ ] Create Post Editor (advanced) +- [ ] Create Page Manager (advanced) +- [ ] Create Site Settings (advanced + SEO) +- [ ] Create Site Preview +- [ ] Create Layout Selector +- [ ] Create Template Library +- [ ] Create Layout Preview +- [ ] Create Template Customizer +- [ ] Create Style Editor +- [ ] Create CMS Theme System +- [ ] Create Style Presets +- [ ] Create Color Schemes +- [ ] Create Typography System +- [ ] Create Component Styles +- [ ] Write component tests +- [ ] Write component documentation + +--- + +## SUCCESS CRITERIA + +### Phase 5 Success Criteria +- ✅ Sites renderer loads site definitions +- ✅ Blocks render correctly using shared components +- ✅ File access works +- ✅ Deployment works end-to-end +- ✅ Sites are accessible publicly +- ✅ Multiple layouts supported +- ✅ Bulk page generation works +- ✅ Progress tracking works + +### Phase 6 Success Criteria +- ✅ Site integrations work correctly +- ✅ Multi-destination publishing works +- ✅ WordPress sync works +- ✅ Two-way sync functions properly +- ✅ Site management UI works (core features) +- ✅ Publishing settings work +- ✅ Task integration works + +### Phase 7 Success Criteria +- ✅ All components render correctly +- ✅ Component library is complete +- ✅ Prompt management UI works +- ✅ Site management works end-to-end (advanced features) +- ✅ Layout system works +- ✅ Template system works +- ✅ CMS styling system works +- ✅ No duplicate components +- ✅ All components are accessible and responsive + +--- + +## TIMELINE SUMMARY + +| Phase | Duration | Key Deliverables | +|-------|----------|------------------| +| **Phase 5** | 2.5-3.5 weeks | Sites renderer, bulk generation | +| **Phase 6** | 2.5-3 weeks | Multi-destination publishing, integrations | +| **Phase 7** | 3.5-4.5 weeks | Component library, prompt UI, advanced site management | +| **Total** | 8.5-11 weeks | Complete Sites Renderer, Publishing, and UI system | + +--- + +## RISK ASSESSMENT + +| Risk | Level | Mitigation | +|------|-------|------------| +| **Component library incompatibility** | MEDIUM | Early integration testing in Phase 5 | +| **File management access issues** | LOW | Use Phase 3's proven file service | +| **WordPress adapter refactor breaking existing** | MEDIUM | Comprehensive backward compatibility testing | +| **Bulk generation overloads system** | MEDIUM | Rate limiting, queue management | +| **Multi-destination publishing complexity** | MEDIUM | Adapter pattern, comprehensive testing | +| **CMS styling system complexity** | LOW | Incremental implementation, component-based | + +--- + +## RELATED PHASES + +- **Phase 0**: Credit system, Module Settings (backend) +- **Phase 1**: Service layer (ContentGenerationService, etc.) +- **Phase 3**: Site Builder foundation, shared components, file management +- **Phase 4**: Linker & Optimizer (content optimization) + +--- + +**END OF PHASES 5-7 & 9 CONSOLIDATED DOCUMENT** + diff --git a/docs/planning/phases/PHASE-5-SITES-RENDERER.md b/docs/planning/phases/PHASE-5-SITES-RENDERER.md deleted file mode 100644 index b2f9932d..00000000 --- a/docs/planning/phases/PHASE-5-SITES-RENDERER.md +++ /dev/null @@ -1,181 +0,0 @@ -# PHASE 5: SITES RENDERER -**Detailed Implementation Plan** - -**Goal**: Build Sites renderer for hosting public sites. - -**Timeline**: 2-3 weeks -**Priority**: MEDIUM -**Dependencies**: Phase 3 - ---- - -## TABLE OF CONTENTS - -1. [Overview](#overview) -2. [Sites Renderer Container](#sites-renderer-container) -3. [Publisher Service](#publisher-service) -4. [Publishing Models](#publishing-models) -5. [Publisher API](#publisher-api) -6. [Multiple Layout Options](#multiple-layout-options) -7. [Testing & Validation](#testing--validation) -8. [Implementation Checklist](#implementation-checklist) - ---- - -## OVERVIEW - -### Objectives -- ✅ Create Sites renderer container -- ✅ Build publisher service -- ✅ Support multiple layout options -- ✅ Deploy sites to public URLs -- ✅ Render sites from site definitions - -### Key Principles -- **Component Reuse**: Use shared component library from Phase 3 -- **Multiple Layouts**: Support 7 layout types -- **Public Access**: Sites accessible via public URLs -- **User-Friendly**: "My Websites" or "Published Sites" in UI - ---- - -## SITES RENDERER CONTAINER - -### 5.1 Sites Renderer Container - -**User-Friendly Name**: "My Websites" or "Published Sites" - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Create Sites Container** | `docker-compose.app.yml` | None | Add new container for sites renderer | -| **Sites Renderer Frontend** | `sites/src/` | NEW | React app for rendering sites | -| **Site Definition Loader** | `sites/src/loaders/loadSiteDefinition.ts` | NEW | Load site definitions from API | -| **Layout Renderer** | `sites/src/utils/layoutRenderer.ts` | NEW | Render different layouts | -| **Template System** | `sites/src/utils/templateEngine.ts` | NEW | Template rendering system | - -**Docker Compose Configuration**: -```yaml -# docker-compose.app.yml -igny8_sites: - build: ./sites - ports: - - "8024:5176" - volumes: - - /data/app/igny8/sites:/app - - /data/app/sites-data:/sites - environment: - - VITE_API_URL=http://igny8_backend:8010 -``` - ---- - -## PUBLISHER SERVICE - -### 5.2 Publisher Service - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **PublisherService** | `business/publishing/services/publisher_service.py` | Phase 1 | Main publishing service | -| **SitesRendererAdapter** | `business/publishing/services/adapters/sites_renderer_adapter.py` | Phase 3 | Adapter for Sites renderer | -| **DeploymentService** | `business/publishing/services/deployment_service.py` | Phase 3 | Deploy sites to renderer | - -**PublisherService**: -```python -# business/publishing/services/publisher_service.py -class PublisherService: - def publish_to_sites(self, site_blueprint): - """Publish site to Sites renderer""" - adapter = SitesRendererAdapter() - return adapter.deploy(site_blueprint) -``` - ---- - -## PUBLISHING MODELS - -### 5.3 Publishing Models - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **PublishingRecord Model** | `business/publishing/models.py` | Phase 1 | Track content publishing | -| **DeploymentRecord Model** | `business/publishing/models.py` | Phase 3 | Track site deployments | - ---- - -## PUBLISHER API - -### 5.4 Publisher API - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Publisher ViewSet** | `modules/publisher/views.py` | PublisherService | API for publishing operations | - ---- - -## MULTIPLE LAYOUT OPTIONS - -### 5.6 Multiple Layout Options - -**Layout Types**: -- Default (Standard) -- Minimal (Clean, simple) -- Magazine (Editorial, content-focused) -- Ecommerce (Product-focused) -- Portfolio (Showcase) -- Blog (Content-first) -- Corporate (Business) - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Layout Configuration** | `business/site_building/models.py` | Phase 3 | Store layout selection | -| **Layout Renderer** | `sites/src/utils/layoutRenderer.ts` | Phase 5 | Render different layouts | - ---- - -## TESTING & VALIDATION - -### 5.5 Testing - -**Test Cases**: -- ✅ Sites renderer loads site definitions -- ✅ Blocks render correctly -- ✅ Deployment works end-to-end -- ✅ Sites are accessible publicly -- ✅ Multiple layouts work correctly - ---- - -## IMPLEMENTATION CHECKLIST - -### Backend Tasks - -- [ ] Create PublisherService -- [ ] Create SitesRendererAdapter -- [ ] Create DeploymentService -- [ ] Create PublishingRecord model -- [ ] Create DeploymentRecord model -- [ ] Create Publisher ViewSet - -### Frontend Tasks - -- [ ] Create Sites container in docker-compose -- [ ] Create sites renderer frontend -- [ ] Create site definition loader -- [ ] Create layout renderer -- [ ] Create template system -- [ ] Import shared components - ---- - -## SUCCESS CRITERIA - -- ✅ Sites renderer loads site definitions -- ✅ Blocks render correctly -- ✅ Deployment works end-to-end -- ✅ Sites are accessible publicly -- ✅ Multiple layouts supported - ---- - -**END OF PHASE 5 DOCUMENT** - diff --git a/docs/planning/phases/PHASE-6-SITE-INTEGRATION-PUBLISHING.md b/docs/planning/phases/PHASE-6-SITE-INTEGRATION-PUBLISHING.md deleted file mode 100644 index c5724f5e..00000000 --- a/docs/planning/phases/PHASE-6-SITE-INTEGRATION-PUBLISHING.md +++ /dev/null @@ -1,242 +0,0 @@ -# PHASE 6: SITE INTEGRATION & MULTI-DESTINATION PUBLISHING -**Detailed Implementation Plan** - -**Goal**: Support multiple publishing destinations (WordPress, Sites, Shopify). - -**Timeline**: 2-3 weeks -**Priority**: MEDIUM -**Dependencies**: Phase 5 - ---- - -## TABLE OF CONTENTS - -1. [Overview](#overview) -2. [Site Integration Models](#site-integration-models) -3. [Integration Service](#integration-service) -4. [Publishing Adapters](#publishing-adapters) -5. [Multi-Destination Publishing](#multi-destination-publishing) -6. [Site Model Extensions](#site-model-extensions) -7. [Integration API](#integration-api) -8. [Integration UI](#integration-ui) -9. [Publishing Settings UI](#publishing-settings-ui) -10. [Site Management UI](#site-management-ui) -11. [Testing & Validation](#testing--validation) -12. [Implementation Checklist](#implementation-checklist) - ---- - -## OVERVIEW - -### Objectives -- ✅ Support multiple site integrations per site -- ✅ Multi-destination publishing (WordPress, Sites, Shopify) -- ✅ Two-way sync with external platforms -- ✅ Site management UI (CMS) -- ✅ Publishing settings UI - -### Key Principles -- **Multiple Integrations**: One site can have multiple integrations -- **Adapter Pattern**: Platform-specific adapters for publishing -- **Two-Way Sync**: Sync content both ways -- **User-Friendly**: "Site Manager" or "Content Manager" in UI - ---- - -## SITE INTEGRATION MODELS - -### 6.1 Site Integration Models - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **SiteIntegration Model** | `business/integration/models.py` | Phase 1 | Store integration configs | - -**SiteIntegration Model**: -```python -# business/integration/models.py -class SiteIntegration(SiteSectorBaseModel): - site = models.ForeignKey(Site, on_delete=models.CASCADE) - platform = models.CharField(max_length=50) # 'wordpress', 'shopify', 'custom' - platform_type = models.CharField(max_length=50) # 'cms', 'ecommerce', 'custom_api' - config_json = models.JSONField(default=dict) - credentials = models.EncryptedField() # Encrypted API keys - is_active = models.BooleanField(default=True) - sync_enabled = models.BooleanField(default=False) - last_sync_at = models.DateTimeField(null=True, blank=True) - sync_status = models.CharField(max_length=20) # 'success', 'failed', 'pending' -``` - ---- - -## INTEGRATION SERVICE - -### 6.2 Integration Service - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **IntegrationService** | `business/integration/services/integration_service.py` | Phase 1 | Manage integrations | -| **SyncService** | `business/integration/services/sync_service.py` | Phase 1 | Handle two-way sync | - ---- - -## PUBLISHING ADAPTERS - -### 6.3 Publishing Adapters - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **BaseAdapter** | `business/publishing/services/adapters/base_adapter.py` | Phase 5 | Base adapter interface | -| **WordPressAdapter** | `business/publishing/services/adapters/wordpress_adapter.py` | EXISTING (refactor) | WordPress publishing | -| **SitesRendererAdapter** | `business/publishing/services/adapters/sites_renderer_adapter.py` | Phase 5 | IGNY8 Sites deployment | -| **ShopifyAdapter** | `business/publishing/services/adapters/shopify_adapter.py` | Phase 5 (future) | Shopify publishing | - ---- - -## MULTI-DESTINATION PUBLISHING - -### 6.4 Multi-Destination Publishing - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Extend PublisherService** | `business/publishing/services/publisher_service.py` | Phase 5 | Support multiple destinations | -| **Update PublishingRecord** | `business/publishing/models.py` | Phase 5 | Track multiple destinations | - -**Multi-Destination Publishing**: -```python -# business/publishing/services/publisher_service.py -class PublisherService: - def publish(self, content, destinations): - """Publish content to multiple destinations""" - results = [] - for destination in destinations: - adapter = self.get_adapter(destination) - result = adapter.publish(content) - results.append(result) - return results -``` - ---- - -## SITE MODEL EXTENSIONS - -### 6.5 Site Model Extensions - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Add site_type field** | `core/auth/models.py` | None | Track site type | -| **Add hosting_type field** | `core/auth/models.py` | None | Track hosting type | -| **Add integrations relationship** | `core/auth/models.py` | Phase 6.1 | Link to SiteIntegration | - ---- - -## INTEGRATION API - -### 6.6 Integration API - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Integration ViewSet** | `modules/integration/views.py` | IntegrationService | CRUD for integrations | -| **Integration URLs** | `modules/integration/urls.py` | None | Register integration routes | - ---- - -## INTEGRATION UI - -### 6.7 Integration UI (Update Existing) - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Update Integration Settings** | `frontend/src/pages/Settings/Integration.tsx` | EXISTING (update) | Add SiteIntegration support | -| **Multi-Platform Support** | `frontend/src/components/integration/PlatformSelector.tsx` | NEW | Platform selector | -| **Integration Status** | `frontend/src/components/integration/IntegrationStatus.tsx` | NEW | Show integration status | - ---- - -## PUBLISHING SETTINGS UI - -### 6.8 Publishing Settings UI - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Publishing Settings Page** | `frontend/src/pages/Settings/Publishing.tsx` | NEW | Publishing configuration | -| **Destination Management** | `frontend/src/pages/Settings/Publishing.tsx` | Phase 6 | Manage publishing destinations | -| **Publishing Rules** | `frontend/src/components/publishing/PublishingRules.tsx` | NEW | Publishing rules configuration | - ---- - -## SITE MANAGEMENT UI - -### 6.9 Individual Site Management (CMS) - -**User-Friendly Name**: "Site Manager" or "Content Manager" - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Site Management Dashboard** | `frontend/src/pages/Sites/Manage.tsx` | NEW | Site management overview | -| **Site Content Editor** | `frontend/src/pages/Sites/Editor.tsx` | NEW | Edit site content | -| **Post Editor** | `frontend/src/pages/Sites/PostEditor.tsx` | NEW | Edit posts | -| **Page Manager** | `frontend/src/pages/Sites/PageManager.tsx` | NEW | Manage pages | -| **Site Settings** | `frontend/src/pages/Sites/Settings.tsx` | NEW | Site settings | - -**Site Management Features**: -- View all pages/posts for a site -- Add new pages -- Remove pages -- Edit page content -- Manage page order -- Change page templates -- Update site settings -- Preview site - ---- - -## TESTING & VALIDATION - -### 6.9 Testing - -**Test Cases**: -- ✅ Site integrations work correctly -- ✅ Multi-destination publishing works -- ✅ WordPress sync works (when plugin connected) -- ✅ Two-way sync functions properly -- ✅ Site management UI works - ---- - -## IMPLEMENTATION CHECKLIST - -### Backend Tasks - -- [ ] Create SiteIntegration model -- [ ] Create IntegrationService -- [ ] Create SyncService -- [ ] Create BaseAdapter -- [ ] Refactor WordPressAdapter -- [ ] Create SitesRendererAdapter -- [ ] Extend PublisherService for multi-destination -- [ ] Extend Site model -- [ ] Create Integration ViewSet - -### Frontend Tasks - -- [ ] Update Integration Settings page -- [ ] Create Publishing Settings page -- [ ] Create Site Management Dashboard -- [ ] Create Site Content Editor -- [ ] Create Page Manager -- [ ] Create Site Settings page - ---- - -## SUCCESS CRITERIA - -- ✅ Site integrations work correctly -- ✅ Multi-destination publishing works -- ✅ WordPress sync works -- ✅ Two-way sync functions properly -- ✅ Site management UI works - ---- - -**END OF PHASE 6 DOCUMENT** - diff --git a/docs/planning/phases/PHASE-7-UI-COMPONENTS-MODULE-SETTINGS.md b/docs/planning/phases/PHASE-7-UI-COMPONENTS-MODULE-SETTINGS.md deleted file mode 100644 index 99401c7d..00000000 --- a/docs/planning/phases/PHASE-7-UI-COMPONENTS-MODULE-SETTINGS.md +++ /dev/null @@ -1,205 +0,0 @@ -# PHASE 7: UI COMPONENTS & MODULE SETTINGS -**Detailed Implementation Plan** - -**Goal**: Build comprehensive UI system with shared components, module settings, and site management. - -**Timeline**: 3-4 weeks -**Priority**: MEDIUM -**Dependencies**: Phase 0, Phase 3, Phase 5 - ---- - -## TABLE OF CONTENTS - -1. [Overview](#overview) -2. [Global Component Library](#global-component-library) -3. [Module Settings UI](#module-settings-ui) -4. [Frontend Module Loader](#frontend-module-loader) -5. [Site Management UI](#site-management-ui) -6. [Layout & Template System](#layout--template-system) -7. [CMS Styling System](#cms-styling-system) -8. [Testing & Validation](#testing--validation) -9. [Implementation Checklist](#implementation-checklist) - ---- - -## OVERVIEW - -### Objectives -- ✅ Complete global component library -- ✅ Implement module settings UI -- ✅ Build site management UI -- ✅ Create layout and template system -- ✅ Implement CMS styling system - -### Key Principles -- **No Duplication**: All components shared across apps -- **TypeScript**: All components use TypeScript -- **Accessibility**: All components accessible (ARIA) -- **Responsive**: All components responsive - ---- - -## GLOBAL COMPONENT LIBRARY - -### 7.1 Global Component Library - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Component Library Structure** | `frontend/src/components/shared/` | None | Complete component library | -| **Block Components** | `frontend/src/components/shared/blocks/` | None | All block components | -| **Layout Components** | `frontend/src/components/shared/layouts/` | None | All layout components | -| **Template Components** | `frontend/src/components/shared/templates/` | None | All template components | -| **Component Documentation** | `frontend/src/components/shared/README.md` | None | Document all components | -| **Component Storybook** | `frontend/.storybook/` | Optional | Component documentation | -| **Component Tests** | `frontend/src/components/shared/**/*.test.tsx` | None | Test all components | - -**Component Standards**: -- All components use TypeScript -- All components have props interfaces -- All components are responsive -- All components support dark mode -- All components are accessible (ARIA) -- No duplicate components - ---- - -## MODULE SETTINGS UI - -### 7.2 Module Settings UI - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Module Settings Page** | `frontend/src/pages/Settings/Modules.tsx` | EXISTING (implement) | Module settings interface | -| **Module Toggle Component** | `frontend/src/components/settings/ModuleToggle.tsx` | NEW | Toggle module on/off | -| **Module Status Indicator** | `frontend/src/components/settings/ModuleStatus.tsx` | NEW | Show module status | -| **Module Configuration** | `frontend/src/components/settings/ModuleConfig.tsx` | NEW | Module configuration UI | - -**Module Settings Features**: -- Enable/disable modules per account -- Module-specific configuration -- Module status display -- Module usage statistics -- Module dependencies check - ---- - -## FRONTEND MODULE LOADER - -### 7.3 Frontend Module Loader - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Module Config** | `frontend/src/config/modules.config.ts` | Phase 0 | Module configuration | -| **Module Guard** | `frontend/src/components/common/ModuleGuard.tsx` | Phase 0 | Route guard component | -| **Conditional Route Loading** | `frontend/src/App.tsx` | Phase 0 | Conditional routes | -| **Sidebar Module Filter** | `frontend/src/layout/AppSidebar.tsx` | Phase 0 | Filter disabled modules | - ---- - -## SITE MANAGEMENT UI - -### 7.4 Site Management UI - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Site List View** | `frontend/src/pages/Sites/List.tsx` | NEW | List all sites | -| **Site Dashboard** | `frontend/src/pages/Sites/Dashboard.tsx` | NEW | Site overview | -| **Site Content Manager** | `frontend/src/pages/Sites/Content.tsx` | NEW | Manage site content | -| **Post Editor** | `frontend/src/pages/Sites/PostEditor.tsx` | NEW | Edit posts | -| **Page Manager** | `frontend/src/pages/Sites/Pages.tsx` | NEW | Manage pages | -| **Site Settings** | `frontend/src/pages/Sites/Settings.tsx` | NEW | Site settings | -| **Site Preview** | `frontend/src/pages/Sites/Preview.tsx` | NEW | Preview site | - ---- - -## LAYOUT & TEMPLATE SYSTEM - -### 7.5 Layout & Template System - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Layout Selector** | `frontend/src/components/sites/LayoutSelector.tsx` | NEW | Select layout | -| **Template Library** | `frontend/src/components/sites/TemplateLibrary.tsx` | NEW | Template library | -| **Layout Preview** | `frontend/src/components/sites/LayoutPreview.tsx` | NEW | Preview layouts | -| **Template Customizer** | `frontend/src/components/sites/TemplateCustomizer.tsx` | NEW | Customize templates | -| **Style Editor** | `frontend/src/components/sites/StyleEditor.tsx` | NEW | Edit styles | - -**Layout Options**: -- Default Layout -- Minimal Layout -- Magazine Layout -- Ecommerce Layout -- Portfolio Layout -- Blog Layout -- Corporate Layout - ---- - -## CMS STYLING SYSTEM - -### 7.6 CMS Styling System - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **CMS Theme System** | `frontend/src/styles/cms/` | NEW | Theme system | -| **Style Presets** | `frontend/src/styles/cms/presets.ts` | NEW | Style presets | -| **Color Schemes** | `frontend/src/styles/cms/colors.ts` | NEW | Color schemes | -| **Typography System** | `frontend/src/styles/cms/typography.ts` | NEW | Typography system | -| **Component Styles** | `frontend/src/styles/cms/components.ts` | NEW | Component styles | - -**CMS Features**: -- Theme customization -- Color palette management -- Typography settings -- Component styling -- Responsive breakpoints -- Dark/light mode - ---- - -## TESTING & VALIDATION - -### 7.7 Testing - -**Test Cases**: -- ✅ All components render correctly -- ✅ Module settings enable/disable modules -- ✅ Disabled modules don't load -- ✅ Site management works end-to-end -- ✅ Layout system works -- ✅ Template system works -- ✅ No duplicate components - ---- - -## IMPLEMENTATION CHECKLIST - -### Frontend Tasks - -- [ ] Complete component library -- [ ] Implement module settings UI -- [ ] Create module loader -- [ ] Create site management UI -- [ ] Create layout system -- [ ] Create template system -- [ ] Create CMS styling system -- [ ] Write component tests -- [ ] Write component documentation - ---- - -## SUCCESS CRITERIA - -- ✅ All components render correctly -- ✅ Module settings enable/disable modules -- ✅ Disabled modules don't load -- ✅ Site management works end-to-end -- ✅ Layout system works -- ✅ Template system works -- ✅ No duplicate components - ---- - -**END OF PHASE 7 DOCUMENT** - diff --git a/docs/planning/phases/PHASE-9-AI-FRAMEWORK-SITE-BUILDER-INTEGRATION.md b/docs/planning/phases/PHASE-9-AI-FRAMEWORK-SITE-BUILDER-INTEGRATION.md deleted file mode 100644 index 96c3e9ab..00000000 --- a/docs/planning/phases/PHASE-9-AI-FRAMEWORK-SITE-BUILDER-INTEGRATION.md +++ /dev/null @@ -1,682 +0,0 @@ -# PHASE 9: AI FRAMEWORK & SITE BUILDER INTEGRATION -**Detailed Implementation Plan** - -**Goal**: Complete AI framework integration for Site Builder, add prompt management UI, and implement blueprint-to-writer task queuing. - -**Timeline**: 2-3 weeks -**Priority**: MEDIUM -**Dependencies**: Phase 3 - ---- - -## TABLE OF CONTENTS - -1. [Overview](#overview) -2. [AI Framework Integration](#ai-framework-integration) -3. [Prompt Management UI](#prompt-management-ui) -4. [Response Handling & Structure Generation](#response-handling--structure-generation) -5. [Blueprint-to-Writer Task Queuing](#blueprint-to-writer-task-queuing) -6. [Testing & Validation](#testing--validation) -7. [Implementation Checklist](#implementation-checklist) - ---- - -## OVERVIEW - -### Objectives -- ✅ Add `site_structure_generation` prompt to Thinker `/prompts` UI -- ✅ Document AI framework integration for Site Builder -- ✅ Implement response handling for structure generation -- ✅ Enable blueprint pages to queue as Writer tasks (similar to ideas) -- ✅ Add bulk page content generation from blueprint - -### Key Principles -- **Unified Prompt Management**: Site Builder prompts managed in same UI as other prompts -- **Reuse Existing Patterns**: Follow same queuing pattern as ideas → writer tasks -- **AI Framework Compliance**: Use existing `BaseAIFunction` and `AIEngine` patterns -- **Response Validation**: Robust parsing and validation of AI responses - ---- - -## AI FRAMEWORK INTEGRATION - -### 9.1 AI Framework Integration - -**Purpose**: Document and ensure proper integration with existing AI framework. - -#### Current AI Framework Architecture - -The Site Builder uses the existing AI framework: - -``` -AIEngine - ├─ BaseAIFunction (interface) - │ ├─ validate() - │ ├─ prepare() - │ ├─ build_prompt() - │ ├─ parse_response() - │ └─ save_output() - │ - └─ GenerateSiteStructureFunction - ├─ Uses PromptRegistry for prompts - ├─ Integrates with CreditService - └─ Saves to SiteBlueprint + PageBlueprint models -``` - -#### AI Function Lifecycle - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **AI Function Registration** | `ai/registry.py` | Existing | Register `generate_site_structure` | -| **Prompt Integration** | `ai/prompts.py` | Existing | Add `site_structure_generation` to DEFAULT_PROMPTS | -| **Credit Cost Configuration** | `business/billing/services/credit_service.py` | Phase 0 | Add `site_structure_generation` operation type | - -**AI Function Flow**: -```python -# infrastructure/ai/functions/generate_site_structure.py -class GenerateSiteStructureFunction(BaseAIFunction): - def get_name(self) -> str: - return 'generate_site_structure' - - def validate(self, payload, account=None): - # Validates blueprint ID exists - # Returns {'valid': True/False, 'error': '...'} - - def prepare(self, payload, account=None): - # Loads SiteBlueprint - # Extracts business_brief, objectives, style - # Returns context dict - - def build_prompt(self, data, account=None): - # Uses PromptRegistry.get_prompt('site_structure_generation') - # Injects: BUSINESS_BRIEF, OBJECTIVES, STYLE, SITE_INFO - # Returns formatted prompt string - - def parse_response(self, response, step_tracker=None): - # Parses JSON from AI response - # Handles noisy responses (extracts JSON from text) - # Validates structure is dict - # Returns parsed structure dict - - def save_output(self, parsed, original_data, account=None): - # Saves structure_json to SiteBlueprint - # Syncs PageBlueprint records (create/update/delete) - # Updates blueprint status to 'ready' - # Returns summary dict -``` - -#### Prompt Variable Injection - -The prompt system supports variable injection: - -**Available Variables**: -- `[IGNY8_BUSINESS_BRIEF]` - Business description -- `[IGNY8_OBJECTIVES]` - List of site objectives -- `[IGNY8_STYLE]` - Style preferences JSON -- `[IGNY8_SITE_INFO]` - Site metadata JSON - -**Prompt Template** (from `ai/prompts.py`): -```python -'site_structure_generation': """You are a senior UX architect... -BUSINESS BRIEF: -[IGNY8_BUSINESS_BRIEF] - -PRIMARY OBJECTIVES: -[IGNY8_OBJECTIVES] - -STYLE & BRAND NOTES: -[IGNY8_STYLE] - -SITE INFO: -[IGNY8_SITE_INFO] -... -""" -``` - ---- - -## PROMPT MANAGEMENT UI - -### 9.2 Prompt Management UI - -**Purpose**: Add Site Builder prompt to Thinker `/prompts` interface. - -#### Add Prompt Type to Backend - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Add prompt type choice** | `modules/system/models.py` | Existing | Add `'site_structure_generation'` to PROMPT_TYPE_CHOICES | - -**AIPrompt Model Update**: -```python -# modules/system/models.py -class AIPrompt(AccountBaseModel): - PROMPT_TYPE_CHOICES = [ - ('clustering', 'Clustering'), - ('ideas', 'Ideas Generation'), - ('content_generation', 'Content Generation'), - ('image_prompt_extraction', 'Image Prompt Extraction'), - ('image_prompt_template', 'Image Prompt Template'), - ('negative_prompt', 'Negative Prompt'), - ('site_structure_generation', 'Site Structure Generation'), # NEW - ] -``` - -#### Add Prompt Type to Frontend - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Add prompt type config** | `frontend/src/pages/Thinker/Prompts.tsx` | Existing | Add site_structure_generation to PROMPT_TYPES array | - -**Frontend Prompt Type Config**: -```typescript -// frontend/src/pages/Thinker/Prompts.tsx -const PROMPT_TYPES = [ - // ... existing prompts - { - key: 'site_structure_generation', - label: 'Site Structure Generation', - description: 'Generate site structure from business brief. Use [IGNY8_BUSINESS_BRIEF], [IGNY8_OBJECTIVES], [IGNY8_STYLE], and [IGNY8_SITE_INFO] to inject data.', - icon: '🏗️', - color: 'teal', - }, -]; -``` - -#### Prompt UI Section - -The prompt will appear in a new "Site Builder" section in the Thinker Prompts page: - -```typescript -{/* Site Builder Prompts Section */} -
-
-

- Site Builder -

-

- Configure prompts for AI-powered site structure generation -

-
- - {/* Site Structure Generation Prompt */} - -
-``` - -#### Migration for Prompt Type - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Create migration** | `modules/system/migrations/XXXX_add_site_structure_prompt_type.py` | Existing | Add new choice to PROMPT_TYPE_CHOICES | - ---- - -## RESPONSE HANDLING & STRUCTURE GENERATION - -### 9.3 Response Handling & Structure Generation - -**Purpose**: Document and enhance AI response parsing and structure generation. - -#### Response Format - -The AI returns a JSON structure: - -```json -{ - "site": { - "name": "Acme Robotics", - "primary_navigation": ["home", "services", "about", "contact"], - "secondary_navigation": ["blog", "faq"], - "hero_message": "Transform your warehouse operations", - "tone": "Confident, professional, innovative" - }, - "pages": [ - { - "slug": "home", - "title": "Home", - "type": "home", - "status": "draft", - "objective": "Convert visitors to demo requests", - "primary_cta": "Book a demo", - "blocks": [ - { - "type": "hero", - "heading": "Warehouse Automation That Scales", - "subheading": "AI-powered robotics for modern fulfillment", - "layout": "full-width", - "content": ["Hero section with CTA"] - }, - { - "type": "features", - "heading": "Why Choose Us", - "subheading": "Industry-leading solutions", - "layout": "three-column", - "content": ["Feature 1", "Feature 2", "Feature 3"] - } - ] - } - ] -} -``` - -#### Response Parsing Flow - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Parse Response** | `ai/functions/generate_site_structure.py` | Existing | `parse_response()` method | -| **Extract JSON** | `ai/functions/generate_site_structure.py` | Existing | `_extract_json_object()` helper | -| **Validate Structure** | `ai/functions/generate_site_structure.py` | Existing | `_ensure_dict()` validation | - -**Parsing Logic**: -```python -def parse_response(self, response: str, step_tracker=None) -> Dict[str, Any]: - """ - Parse AI response into structure dict. - - Handles: - 1. Direct JSON response - 2. JSON wrapped in text/markdown - 3. Noisy responses with commentary - """ - response = response.strip() - - # Try direct JSON parse - try: - return self._ensure_dict(json.loads(response)) - except json.JSONDecodeError: - # Extract JSON from text - cleaned = self._extract_json_object(response) - if cleaned: - return self._ensure_dict(json.loads(cleaned)) - raise ValueError("Unable to parse AI response into JSON") -``` - -#### Structure Persistence - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Save Structure** | `ai/functions/generate_site_structure.py` | Existing | `save_output()` method | -| **Sync Page Blueprints** | `ai/functions/generate_site_structure.py` | Existing | `_sync_page_blueprints()` method | - -**Persistence Flow**: -```python -def save_output(self, parsed, original_data, account=None): - """ - Save structure and sync page blueprints. - - 1. Save structure_json to SiteBlueprint - 2. Create/update PageBlueprint records - 3. Delete pages not in new structure - 4. Update blueprint status to 'ready' - """ - blueprint = original_data['blueprint'] - structure = self._ensure_dict(parsed) - pages = structure.get('pages', []) - - # Save structure - blueprint.structure_json = structure - blueprint.status = 'ready' - blueprint.save() - - # Sync pages (create/update/delete) - created, updated, deleted = self._sync_page_blueprints(blueprint, pages) - - return { - 'success': True, - 'pages_created': created, - 'pages_updated': updated, - 'pages_deleted': deleted, - } -``` - -#### Error Handling - -**Error Scenarios**: -1. **Invalid JSON**: Extract JSON from text, fallback to error -2. **Missing Required Fields**: Validate structure has `site` and `pages` -3. **Invalid Page Types**: Map to allowed types, default to 'custom' -4. **Duplicate Slugs**: Use `update_or_create` to handle conflicts - -**Error Response Format**: -```python -{ - 'success': False, - 'error': 'Error message', - 'error_type': 'ParseError' | 'ValidationError' | 'SaveError' -} -``` - ---- - -## BLUEPRINT-TO-WRITER TASK QUEUING - -### 9.4 Blueprint-to-Writer Task Queuing - -**Purpose**: Enable blueprint pages to be queued as Writer tasks, similar to how ideas are queued. - -#### Current Pattern (Ideas → Writer) - -The existing pattern for ideas: - -``` -ContentIdeas → Writer Tasks → Content Generation -``` - -**Flow**: -1. User selects ideas in Planner -2. Click "Generate Content" -3. Creates `Tasks` records for each idea -4. Queues `generate_content` AI task -5. Generates HTML content - -#### New Pattern (Blueprint Pages → Writer) - -The new pattern for blueprint pages: - -``` -PageBlueprint → Writer Tasks → Content Generation -``` - -**Flow**: -1. User has generated SiteBlueprint with PageBlueprints -2. User selects pages (or all pages) -3. Click "Generate Content for Pages" -4. Creates `Tasks` records for each page -5. Queues `generate_content` AI task -6. Generates HTML content - -#### Bulk Page Content Generation - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Bulk Generate Action** | `modules/site_builder/views.py` | PageGenerationService | Add `bulk_generate_content` action | -| **Task Creation Service** | `business/site_building/services/page_generation_service.py` | Existing | Add `create_tasks_for_pages()` method | -| **Bulk Queue Service** | `business/site_building/services/page_generation_service.py` | ContentGenerationService | Add `bulk_generate_pages()` method | - -**Bulk Generation API**: -```python -# modules/site_builder/views.py -class SiteBlueprintViewSet(SiteSectorModelViewSet): - @action(detail=True, methods=['post']) - def generate_all_pages(self, request, pk=None): - """ - Generate content for all pages in blueprint. - - Request body: - { - "page_ids": [1, 2, 3], # Optional: specific pages, or all if omitted - "force": false # Optional: force regenerate existing content - } - """ - blueprint = self.get_object() - page_ids = request.data.get('page_ids') - force = request.data.get('force', False) - - service = PageGenerationService() - result = service.bulk_generate_pages( - blueprint, - page_ids=page_ids, - force_regenerate=force - ) - return success_response(result, request=request) -``` - -**Bulk Generation Service**: -```python -# business/site_building/services/page_generation_service.py -class PageGenerationService: - def bulk_generate_pages( - self, - site_blueprint: SiteBlueprint, - page_ids: Optional[List[int]] = None, - force_regenerate: bool = False - ) -> dict: - """ - Generate content for multiple pages in a blueprint. - - Similar to how ideas are queued to writer: - 1. Get pages (filtered by page_ids if provided) - 2. Create/update Writer Tasks for each page - 3. Queue content generation for all tasks - 4. Return task IDs for progress tracking - """ - # Get pages - pages = site_blueprint.pages.all() - if page_ids: - pages = pages.filter(id__in=page_ids) - - # Create tasks for all pages - task_ids = [] - for page in pages: - task = self._ensure_task(page, force_regenerate=force_regenerate) - task_ids.append(task.id) - page.status = 'generating' - page.save(update_fields=['status', 'updated_at']) - - # Queue content generation (same as ideas → writer) - account = site_blueprint.account - result = self.content_service.generate_content(task_ids, account) - - return { - 'success': True, - 'pages_queued': len(task_ids), - 'task_ids': task_ids, - 'celery_task_id': result.get('task_id'), - } - - def create_tasks_for_pages( - self, - site_blueprint: SiteBlueprint, - page_ids: Optional[List[int]] = None, - force_regenerate: bool = False - ) -> List[Tasks]: - """ - Create Writer Tasks for blueprint pages without generating content. - - Useful for: - - Previewing what tasks will be created - - Manual task management - - Integration with existing Writer UI - """ - pages = site_blueprint.pages.all() - if page_ids: - pages = pages.filter(id__in=page_ids) - - tasks = [] - for page in pages: - task = self._ensure_task(page, force_regenerate=force_regenerate) - tasks.append(task) - - return tasks -``` - -#### Frontend Integration - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Bulk Generate UI** | `site-builder/src/pages/dashboard/SiteDashboard.tsx` | API client | Add "Generate All Pages" button | -| **Page Selection UI** | `site-builder/src/pages/preview/PreviewCanvas.tsx` | State store | Add checkbox selection for pages | -| **Progress Tracking** | `site-builder/src/components/common/ProgressModal.tsx` | Existing | Track bulk generation progress | - -**Frontend API Client**: -```typescript -// site-builder/src/api/builder.api.ts -export const builderApi = { - // ... existing methods - - async generateAllPages( - blueprintId: number, - options?: { pageIds?: number[]; force?: boolean } - ): Promise<{ task_id: string; pages_queued: number }> { - const res = await client.post( - `/blueprints/${blueprintId}/generate_all_pages/`, - options || {} - ); - return res.data; - }, - - async createTasksForPages( - blueprintId: number, - pageIds?: number[] - ): Promise<{ tasks: Task[] }> { - const res = await client.post( - `/blueprints/${blueprintId}/create_tasks/`, - { page_ids: pageIds } - ); - return res.data; - }, -}; -``` - -#### Task Mapping - -**PageBlueprint → Task Mapping**: - -| PageBlueprint Field | Task Field | Notes | -|---------------------|-----------|-------| -| `title` | `title` | Prefixed with "[Site Builder]" | -| `slug` | `keywords` | Used as keyword hint | -| `type` | `content_structure` | Mapped (home → landing_page, etc.) | -| `blocks_json` | `description` | Extracts headings for context | -| `site_blueprint.name` | `description` | Added to description | -| `account`, `site`, `sector` | Same | Inherited from blueprint | - -**Content Structure Mapping**: -```python -PAGE_TYPE_TO_STRUCTURE = { - 'home': 'landing_page', - 'about': 'supporting_page', - 'services': 'pillar_page', - 'products': 'pillar_page', - 'blog': 'cluster_hub', - 'contact': 'supporting_page', - 'custom': 'landing_page', -} -``` - -#### Integration with Writer UI - -| Task | File | Dependencies | Implementation | -|------|------|--------------|----------------| -| **Show Site Builder Tasks** | `frontend/src/pages/Writer/Content.tsx` | Existing | Filter tasks with "[Site Builder]" prefix | -| **Link to Blueprint** | `frontend/src/pages/Writer/Content.tsx` | API | Add link to source blueprint | -| **Bulk Actions** | `frontend/src/pages/Writer/Content.tsx` | Existing | Include Site Builder tasks in bulk actions | - -**Task Identification**: -- Tasks created from Site Builder have title prefix: `"[Site Builder] {page_title}"` -- Can filter Writer tasks by this prefix -- Can link back to source PageBlueprint via task description - ---- - -## TESTING & VALIDATION - -### 9.5 Testing - -**Test Cases**: - -1. **Prompt Management**: - - ✅ Site structure prompt appears in Thinker UI - - ✅ Prompt can be edited and saved - - ✅ Prompt reset works correctly - - ✅ Custom prompt is used in structure generation - -2. **Response Handling**: - - ✅ Valid JSON response is parsed correctly - - ✅ JSON wrapped in text is extracted - - ✅ Invalid responses show proper errors - - ✅ Structure validation works - -3. **Bulk Page Generation**: - - ✅ All pages can be queued to writer - - ✅ Specific pages can be selected - - ✅ Tasks are created with correct mapping - - ✅ Content generation is queued correctly - - ✅ Progress tracking works - -4. **Task Integration**: - - ✅ Site Builder tasks appear in Writer UI - - ✅ Tasks link back to source blueprint - - ✅ Bulk actions work with Site Builder tasks - ---- - -## IMPLEMENTATION CHECKLIST - -### Backend Tasks - -- [ ] Add `site_structure_generation` to `AIPrompt.PROMPT_TYPE_CHOICES` -- [ ] Create migration for new prompt type -- [ ] Add `bulk_generate_pages()` to `PageGenerationService` -- [ ] Add `create_tasks_for_pages()` to `PageGenerationService` -- [ ] Add `generate_all_pages` action to `SiteBlueprintViewSet` -- [ ] Add `create_tasks` action to `SiteBlueprintViewSet` -- [ ] Document response handling in code comments -- [ ] Add error handling for bulk operations - -### Frontend Tasks - -- [ ] Add `site_structure_generation` to `PROMPT_TYPES` in `Prompts.tsx` -- [ ] Add "Site Builder" section to Prompts page -- [ ] Add prompt editor for site structure generation -- [ ] Add "Generate All Pages" button to Site Dashboard -- [ ] Add page selection UI to Preview Canvas -- [ ] Add bulk generation API methods to `builder.api.ts` -- [ ] Add progress tracking for bulk generation -- [ ] Update Writer UI to show Site Builder tasks -- [ ] Add link from Writer tasks to source blueprint - -### Testing Tasks - -- [ ] Test prompt management UI -- [ ] Test response parsing with various formats -- [ ] Test bulk page generation -- [ ] Test task creation and mapping -- [ ] Test integration with Writer UI -- [ ] Test error handling - ---- - -## RISK ASSESSMENT - -| Risk | Level | Mitigation | -|------|-------|------------| -| **Prompt changes break existing blueprints** | LOW | Version prompts, validate before save | -| **Bulk generation overloads system** | MEDIUM | Rate limiting, queue management | -| **Task mapping inconsistencies** | LOW | Comprehensive tests, validation | -| **Response parsing failures** | MEDIUM | Robust error handling, fallbacks | - ---- - -## SUCCESS CRITERIA - -- ✅ Site structure prompt is manageable in Thinker UI -- ✅ Response handling is robust and handles edge cases -- ✅ Blueprint pages can be queued to writer like ideas -- ✅ Bulk generation works for all pages -- ✅ Tasks appear correctly in Writer UI -- ✅ Integration is seamless and follows existing patterns - ---- - -## RELATED PHASES - -- **Phase 3**: Site Builder foundation -- **Phase 1**: Service layer (ContentGenerationService) -- **Phase 0**: Credit system (for AI operations) - ---- - -**END OF PHASE 9 DOCUMENT** -