Remove obsolete migration and workflow files; delete Site Builder Wizard references and related components. Update documentation to reflect the removal of the WorkflowState model and streamline the site building process.

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-21 00:59:34 +00:00
parent 6bb918bad6
commit c8adfe06d1
23 changed files with 1914 additions and 3493 deletions

View File

@@ -0,0 +1,178 @@
# Documentation vs Codebase Discrepancies Report
**Date:** 2025-01-XX
**Purpose:** Identify mismatches between master documentation (01-05) and actual codebase
---
## Summary
The master documentation files (01-05) are **mostly accurate** but have some **missing modules** and minor version discrepancies.
---
## ✅ Accurate Sections
### 1. Technology Stack (01-TECH-STACK-AND-INFRASTRUCTURE.md)
- ✅ Django 5.2.7+ - **MATCHES** (requirements.txt: `Django>=5.2.7`)
- ✅ React 19.0.0 - **MATCHES** (package.json: `"react": "^19.0.0"`)
- ✅ TypeScript 5.7.2 - **MATCHES** (package.json: `"typescript": "~5.7.2"`)
- ✅ Vite 6.1.0 - **MATCHES** (package.json: `"vite": "^6.1.0"`)
- ✅ Tailwind CSS 4.0.8 - **MATCHES** (package.json: `"tailwindcss": "^4.0.8"`)
- ✅ Zustand 5.0.8 - **MATCHES** (package.json: `"zustand": "^5.0.8"`)
- ✅ All UI libraries versions - **MATCHES**
### 2. Frontend Architecture (03-FRONTEND-ARCHITECTURE.md)
- ✅ Project structure - **MATCHES**
- ✅ Component architecture - **MATCHES**
- ✅ State management (Zustand stores) - **MATCHES**
- ✅ Routing structure - **MATCHES**
### 3. AI Framework (05-AI-FRAMEWORK-IMPLEMENTATION.md)
- ✅ AI framework structure - **MATCHES**
- ✅ Base classes and engine - **MATCHES**
- ✅ Function registry - **MATCHES**
---
## ⚠️ Discrepancies Found
### 1. Missing Modules in Documentation
**Issue:** Backend documentation (04-BACKEND-IMPLEMENTATION.md) only lists 4 modules, but codebase has **10 modules**.
**Documented Modules:**
- ✅ planner
- ✅ writer
- ✅ system
- ✅ billing
**Missing Modules (in codebase but not documented):**
-**automation** - Not documented
-**integration** - Not documented
-**linker** - Not documented
-**optimizer** - Not documented
-**publisher** - Not documented
-**site_builder** - Not documented
**Location:** `backend/igny8_core/modules/`
**Impact:** Medium - These modules exist and are functional but not documented.
---
### 2. React Router Version Discrepancy
**Issue:** Minor version difference in documentation.
**Documentation says:**
- React Router: v7.9.5
**Actual codebase:**
- `react-router`: ^7.1.5
- `react-router-dom`: ^7.9.5
**Impact:** Low - Both are v7, minor version difference. Documentation should note both packages.
---
### 3. Module Organization Documentation
**Issue:** Application Architecture (02-APPLICATION-ARCHITECTURE.md) only mentions 5 core modules, but there are more.
**Documented:**
- Planner
- Writer
- Thinker (mentioned but may not exist)
- System
- Billing
**Actual modules in codebase:**
- planner ✅
- writer ✅
- system ✅
- billing ✅
- automation ❌ (not documented)
- integration ❌ (not documented)
- linker ❌ (not documented)
- optimizer ❌ (not documented)
- publisher ❌ (not documented)
- site_builder ❌ (not documented)
**Impact:** Medium - Complete module list is missing.
---
### 4. Site Builder Module Status
**Issue:** Site Builder module exists but documentation may not reflect current state after wizard removal.
**Current State:**
-`backend/igny8_core/modules/site_builder/` exists
- ✅ Site Builder APIs are active
- ✅ Models are active (SiteBlueprint, PageBlueprint, etc.)
- ❌ Wizard UI removed (correctly documented in 06-FUNCTIONAL-BUSINESS-LOGIC.md)
**Impact:** Low - Status is correctly documented in workflow docs, but module structure may need updating in 04-BACKEND-IMPLEMENTATION.md.
---
## 📋 Recommended Updates
### Priority 1: Update Module Documentation
**File:** `master-docs/04-BACKEND-IMPLEMENTATION.md`
**Action:** Add missing modules to Project Structure section:
```markdown
├── modules/ # Feature modules
│ ├── planner/ # Keywords, Clusters, Ideas
│ ├── writer/ # Tasks, Content, Images
│ ├── system/ # Settings, Prompts, Integration
│ ├── billing/ # Credits, Transactions, Usage
│ ├── automation/ # Automation workflows
│ ├── integration/ # External integrations
│ ├── linker/ # Internal linking
│ ├── optimizer/ # Content optimization
│ ├── publisher/ # Publishing workflows
│ └── site_builder/ # Site blueprint management
```
### Priority 2: Update Application Architecture
**File:** `master-docs/02-APPLICATION-ARCHITECTURE.md`
**Action:** Add complete module list with descriptions for all 10 modules.
### Priority 3: Minor Version Updates
**File:** `master-docs/01-TECH-STACK-AND-INFRASTRUCTURE.md`
**Action:** Update React Router to show both packages:
- `react-router`: ^7.1.5
- `react-router-dom`: ^7.9.5
---
## ✅ Overall Assessment
**Accuracy Level:** ~85%
**Strengths:**
- Technology stack versions are accurate
- Core architecture is well documented
- Frontend structure matches
- AI framework documentation is complete
**Weaknesses:**
- Missing 6 backend modules in documentation
- Module organization incomplete
- Minor version discrepancies
**Recommendation:** Update module documentation to include all 10 modules for complete accuracy.
---
**Last Updated:** 2025-01-XX

View File

@@ -0,0 +1,166 @@
# IGNY8 Current Workflow Status
**Last Updated:** 2025-01-XX
**Purpose:** Single source of truth for current system state, active work, and recent changes
---
## Current System State
### Workflow Path (Current)
```
PLANNING → WRITER → OPTIMIZE → PUBLISH
```
**Direct Path:** Keywords/Clusters → Ideas → Tasks → Content (no wizard intermediary)
### Removed Features (2025-11-20)
- **Site Builder Wizard** - 6-step guided wizard process completely removed
- **WorkflowState Model** - Backend model and services removed
- **Wizard Routes** - `/sites/builder`, `/sites/builder/preview`, `/sites/blueprints` routes removed
- **Wizard UI Components** - All wizard step components removed from frontend
### Active Features
-**Site Blueprint APIs** - All backend APIs for creating/managing blueprints still work
-**Site Builder Models** - SiteBlueprint, PageBlueprint, SiteBlueprintCluster, SiteBlueprintTaxonomy models active
-**Direct Workflow** - Users can go directly from Planning → Writer → Optimize → Publish
-**All Core Modules** - Planner, Writer, Optimizer, Publisher all functional
---
## Recent Changes
### Site Builder Wizard Removal (2025-11-20)
**What Was Deleted:**
#### Frontend Files
- `/frontend/src/pages/Sites/Builder/Wizard.tsx`
- `/frontend/src/pages/Sites/Builder/Preview.tsx`
- `/frontend/src/pages/Sites/Builder/Blueprints.tsx`
- All wizard step components (`steps/*.tsx`)
- Wizard components (`components/WizardProgress.tsx`, `components/HelperDrawer.tsx`)
- `/frontend/src/store/builderStore.ts`
#### Backend Files
- `/backend/igny8_core/business/site_building/services/workflow_state_service.py`
- `/backend/igny8_core/business/site_building/services/wizard_context_service.py`
- `/backend/igny8_core/business/site_building/services/validators.py`
#### Backend Model
- `WorkflowState` model removed from `models.py`
#### Database
- Table: `igny8_site_blueprint_workflow_states` (dropped)
### Leftover Code Cleanup (2025-01-XX)
**Additional Cleanup Completed:**
#### Frontend API Functions Removed
- `fetchWizardContext()` - Called non-existent `/workflow/context/` endpoint
- `updateWorkflowStep()` - Called non-existent `/workflow/step/` endpoint
#### TypeScript Interfaces Removed
- `WorkflowState` interface - No longer needed (model removed)
- `WizardContext` interface - No longer needed (wizard removed)
- `workflow_state` field removed from `SiteBlueprint` interface
#### Frontend Components Fixed
- **Planner Dashboard** (`frontend/src/pages/Planner/Dashboard.tsx`):
- Removed `incompleteBlueprints` state and filtering logic
- Removed incomplete workflows alert banner
- Removed unused `Alert` import
**Files Modified:**
1. `frontend/src/services/api.ts` - Removed wizard/workflow functions and interfaces
2. `frontend/src/pages/Planner/Dashboard.tsx` - Removed workflow state references
**Status:** ✅ All leftover wizard/workflow code has been cleaned up
---
## What's Still Active (Site Builder)
### Models Still Active
1. **SiteBlueprint** (`igny8_site_blueprints`)
2. **PageBlueprint** (`igny8_page_blueprints`)
3. **SiteBlueprintCluster** (`igny8_site_blueprint_clusters`)
4. **SiteBlueprintTaxonomy** (`igny8_site_blueprint_taxonomies`)
5. **BusinessType** (`igny8_site_builder_business_types`)
6. **AudienceProfile** (`igny8_site_builder_audience_profiles`)
7. **BrandPersonality** (`igny8_site_builder_brand_personalities`)
8. **HeroImageryDirection** (`igny8_site_builder_hero_imagery`)
### API Endpoints Still Available
- `GET/POST /api/v1/site-builder/blueprints/`
- `GET/POST /api/v1/site-builder/pages/`
- `POST /api/v1/site-builder/blueprints/{id}/generate_structure/`
- `POST /api/v1/site-builder/blueprints/{id}/generate_all_pages/`
- `POST /api/v1/site-builder/blueprints/{id}/clusters/attach`
- `POST /api/v1/site-builder/blueprints/{id}/taxonomies/`
- `GET /api/v1/site-builder/metadata/`
### Services Still Active
- `StructureGenerationService` - AI structure generation
- `PageGenerationService` - Page content generation
- `TaxonomyService` - Taxonomy management
- `SiteBuilderFileService` - File management
---
## Migration & Database State
### Migration State
- All apps have single `0001_initial.py` migrations
- Clean migration state (no migration history)
- Database structure matches current models
- WorkflowState table removed from database
### Database Backup
- **Backup:** `backup_postgres_20251120_232816.sql` (646KB)
- Contains all data except WorkflowState (intentionally excluded)
---
## Current Workflow Details
### Phase 1: Planning
- Keyword import and management
- Auto-clustering (1 credit per 30 keywords)
- Content idea generation (1 credit per idea)
- Queue ideas to Writer
### Phase 2: Writer
- Task creation from ideas
- Content generation (3 credits per content)
- Image generation (1 credit per image)
- Content review and editing
### Phase 3: Optimize
- Internal linking suggestions
- Content optimization scoring
- Apply improvements
### Phase 4: Publish
- WordPress publishing
- Site deployment (for IGNY8-hosted sites)
- Content validation
---
## Notes
- Site blueprints can still be created/managed through API endpoints
- No guided UI wizard available
- Direct path from Planning to Writer is the standard workflow
- All core functionality remains intact
---
**Last Updated:** 2025-01-XX
**Status:** Current and Active

View File

@@ -1,219 +0,0 @@
# Complete Migration Reset Plan - Backup, Recreate, Restore
## Overview
This plan will:
1. Backup all database data
2. Remove WorkflowState from migrations
3. Delete all migration files
4. Generate fresh 0001_initial.py migrations
5. Recreate database
6. Restore data
## Database Detection
- **Primary**: PostgreSQL (from DATABASE_URL or DB_* env vars)
- **Fallback**: SQLite (if no PostgreSQL config)
- **Detection**: Check DATABASE_URL or DB_ENGINE env vars
---
## Step-by-Step Execution Plan
### PHASE 1: PREPARATION & BACKUP
#### Step 1.1: Detect Database Type
- Read `settings.py` to determine database engine
- Check environment variables: `DATABASE_URL`, `DB_ENGINE`, `DB_HOST`, etc.
- Determine if PostgreSQL or SQLite
#### Step 1.2: Create Backup Script
**For PostgreSQL:**
```bash
# Backup script: backup_db.sh
pg_dump -h $DB_HOST -U $DB_USER -d $DB_NAME -F c -f backup_$(date +%Y%m%d_%H%M%S).dump
```
**For SQLite:**
```bash
# Backup script: backup_db.sh
cp $DB_PATH backup_$(date +%Y%m%d_%H%M%S).sqlite3
```
#### Step 1.3: Execute Backup
- Run backup script
- Verify backup file created
- Store backup path for restore
---
### PHASE 2: MIGRATION CLEANUP
#### Step 2.1: Remove WorkflowState from Migration 0003
**File**: `backend/igny8_core/business/site_building/migrations/0003_workflow_and_taxonomies.py`
**Actions:**
- Remove `CreateModel` for WorkflowState (lines 37-59)
- Remove 3 `AddIndex` operations for WorkflowState (lines 98-109)
- Keep: SiteBlueprintCluster, SiteBlueprintTaxonomy, and their indexes
#### Step 2.2: Identify All Apps with Migrations
Apps to process:
1. `igny8_core.auth` (label: `igny8_core_auth`)
2. `igny8_core.modules.planner` (label: `planner`)
3. `igny8_core.modules.writer` (label: `writer`)
4. `igny8_core.modules.system` (label: `system`)
5. `igny8_core.modules.billing` (label: `billing`)
6. `igny8_core.business.site_building` (label: `site_building`)
7. `igny8_core.business.optimization` (label: `optimization`)
8. `igny8_core.business.publishing` (label: `publishing`)
9. `igny8_core.business.integration` (label: `integration`)
10. `igny8_core.modules.automation` (label: `automation`)
11. `igny8_core.business.automation` (label: `automation`)
#### Step 2.3: Delete All Migration Files
**For each app:**
- List all files in `*/migrations/` directory
- Delete all `*.py` files EXCEPT `__init__.py`
- Keep `__pycache__/` directory (will be regenerated)
**Files to delete:**
- `0001_initial.py`
- `0002_*.py`
- `0003_*.py`
- ... (all numbered migrations)
---
### PHASE 3: GENERATE NEW MIGRATIONS
#### Step 3.1: Generate Fresh Migrations
**Command:**
```bash
cd backend
python manage.py makemigrations
```
This will create new `0001_initial.py` for each app based on current models.
#### Step 3.2: Verify New Migrations
- Check each app has new `0001_initial.py`
- Verify WorkflowState is NOT in site_building migration
- Verify all other models are present
---
### PHASE 4: DATABASE RECREATION
#### Step 4.1: Drop Database
**For PostgreSQL:**
```bash
# Connect to postgres database (not app database)
psql -h $DB_HOST -U postgres -c "DROP DATABASE IF EXISTS $DB_NAME;"
psql -h $DB_HOST -U postgres -c "CREATE DATABASE $DB_NAME OWNER $DB_USER;"
```
**For SQLite:**
```bash
rm $DB_PATH # Delete SQLite file
```
#### Step 4.2: Run New Migrations
```bash
cd backend
python manage.py migrate
```
This creates all tables with new structure (no WorkflowState table).
---
### PHASE 5: DATA RESTORATION
#### Step 5.1: Restore Data
**For PostgreSQL:**
```bash
pg_restore -h $DB_HOST -U $DB_USER -d $DB_NAME -c backup_*.dump
```
**For SQLite:**
```bash
# SQLite backup is just a copy, so:
cp backup_*.sqlite3 $DB_PATH
```
#### Step 5.2: Handle WorkflowState Data
**Important**: The backup contains WorkflowState table data, but new schema doesn't have it.
**Options:**
- **Option A**: Restore will fail on WorkflowState table - ignore error (table doesn't exist)
- **Option B**: Use `pg_restore --exclude-table=igny8_site_blueprint_workflow_states` to skip it
- **Option C**: Manually edit backup to remove WorkflowState data before restore
**Recommended**: Option B - exclude WorkflowState table during restore
#### Step 5.3: Verify Data Restored
- Check row counts match original
- Verify critical tables have data
- Test application functionality
---
## Execution Script Structure
```python
# reset_migrations.py
1. detect_database_type()
2. backup_database()
3. remove_workflowstate_from_migration()
4. delete_all_migration_files()
5. generate_new_migrations()
6. drop_and_recreate_database()
7. run_migrations()
8. restore_data(exclude_workflowstate=True)
9. verify_restoration()
```
---
## Safety Checks
### Before Starting:
- [ ] Verify database connection works
- [ ] Check disk space for backup
- [ ] Confirm backup location is writable
- [ ] Document current migration state
### After Each Phase:
- [ ] Verify backup file exists and is valid
- [ ] Confirm migrations deleted correctly
- [ ] Verify new migrations generated
- [ ] Check database recreated successfully
- [ ] Validate data restored
---
## Rollback Plan
If something goes wrong:
1. **Stop immediately**
2. **Restore from backup**: Use backup file to restore original database
3. **Restore migrations**: Git checkout original migration files
4. **Verify**: Test application works
---
## Estimated Time
- Backup: 1-5 minutes (depends on data size)
- Migration cleanup: 2-3 minutes
- Generate migrations: 1-2 minutes
- Database recreation: 1-2 minutes
- Data restoration: 2-10 minutes (depends on data size)
- **Total**: ~10-25 minutes
---
## Notes
- WorkflowState table data will be lost (intentional)
- All other data preserved
- Migration history reset to clean state
- All apps start with fresh 0001_initial.py

View File

@@ -1,171 +0,0 @@
# Site Builder Wizard Removal - Reference Document
**Date:** 2025-11-20
**Status:** Complete
---
## What Was Deleted
### Frontend Files
- `/frontend/src/pages/Sites/Builder/Wizard.tsx`
- `/frontend/src/pages/Sites/Builder/Preview.tsx`
- `/frontend/src/pages/Sites/Builder/Blueprints.tsx`
- `/frontend/src/pages/Sites/Builder/steps/BusinessDetailsStep.tsx`
- `/frontend/src/pages/Sites/Builder/steps/BriefStep.tsx`
- `/frontend/src/pages/Sites/Builder/steps/ObjectivesStep.tsx`
- `/frontend/src/pages/Sites/Builder/steps/StyleStep.tsx`
- `/frontend/src/pages/Sites/Builder/steps/ClusterAssignmentStep.tsx`
- `/frontend/src/pages/Sites/Builder/steps/TaxonomyBuilderStep.tsx`
- `/frontend/src/pages/Sites/Builder/steps/SitemapReviewStep.tsx`
- `/frontend/src/pages/Sites/Builder/steps/CoverageValidationStep.tsx`
- `/frontend/src/pages/Sites/Builder/steps/IdeasHandoffStep.tsx`
- `/frontend/src/pages/Sites/Builder/components/WizardProgress.tsx`
- `/frontend/src/pages/Sites/Builder/components/HelperDrawer.tsx`
- `/frontend/src/store/builderStore.ts`
### Backend Files
- `/backend/igny8_core/business/site_building/services/workflow_state_service.py`
- `/backend/igny8_core/business/site_building/services/wizard_context_service.py`
- `/backend/igny8_core/business/site_building/services/validators.py`
### Backend Model
- `WorkflowState` model removed from `models.py`
### Routes Removed
- `/sites/builder` (Wizard route)
- `/sites/builder/preview` (Preview route)
- `/sites/blueprints` (Blueprints route)
### Database
- Table: `igny8_site_blueprint_workflow_states` (dropped)
---
## What's Missing from Workflow Now
**PHASE 2: SITE BUILDER WIZARD** - Completely removed
The 6-step wizard process is gone:
1. ❌ Business Details Step
2. ❌ Cluster Assignment Step
3. ❌ Taxonomy Builder Step
4. ❌ AI Sitemap Review Step
5. ❌ Coverage Validation Step
6. ❌ Ideas Hand-off Step
**Impact:** Users can no longer use the guided wizard to build sites. Site blueprints must be created/managed through other means.
---
## What Changed in Workflow
### Before (Workflow A)
```
PLANNING → WIZARD (6 steps) → WRITER → OPTIMIZE → PUBLISH
```
### After (Workflow A)
```
PLANNING → WRITER → OPTIMIZE → PUBLISH
```
**Direct Path:** Keywords/Clusters → Ideas → Tasks → Content (no wizard intermediary)
---
## Migration & Database Changes
### Migrations Reset
- **Deleted:** 101 migration files (all numbered migrations)
- **Created:** Fresh `0001_initial.py` for all 11 apps
- **Removed:** WorkflowState from `0003_workflow_and_taxonomies.py` before deletion
### Database Actions
1. **Backup:** `backup_postgres_20251120_232816.sql` (646KB)
2. **Dropped:** Database recreated
3. **Migrations Applied:** 34 new migrations
4. **Data Restored:** All data preserved (except WorkflowState)
5. **WorkflowState Table:** Dropped from database
### Migration State
- All apps now have single `0001_initial.py`
- No migration history (clean slate)
- Database structure matches current models
---
## What's Still Kept (Site Builder Tables & Columns)
### Models Still Active
1. **SiteBlueprint** (`igny8_site_blueprints`)
2. **PageBlueprint** (`igny8_page_blueprints`)
3. **SiteBlueprintCluster** (`igny8_site_blueprint_clusters`)
4. **SiteBlueprintTaxonomy** (`igny8_site_blueprint_taxonomies`)
5. **BusinessType** (`igny8_site_builder_business_types`)
6. **AudienceProfile** (`igny8_site_builder_audience_profiles`)
7. **BrandPersonality** (`igny8_site_builder_brand_personalities`)
8. **HeroImageryDirection** (`igny8_site_builder_hero_imagery`)
### Complete Table Structure
#### `igny8_site_blueprints`
- id, name, description, config_json, structure_json
- status, hosting_type, version, deployed_version
- tenant_id, site_id, sector_id
- created_at, updated_at
#### `igny8_page_blueprints`
- id, slug, title, type, blocks_json, status, order
- site_blueprint_id, tenant_id, site_id, sector_id
- created_at, updated_at
#### `igny8_site_blueprint_clusters`
- id, role, coverage_status, metadata
- site_blueprint_id, cluster_id, tenant_id, site_id, sector_id
- created_at, updated_at
#### `igny8_site_blueprint_taxonomies`
- id, name, slug, taxonomy_type, description, metadata, external_reference
- site_blueprint_id, tenant_id, site_id, sector_id
- created_at, updated_at
#### `igny8_site_blueprint_taxonomies_clusters` (M2M)
- id, siteblueprinttaxonomy_id, clusters_id
#### Metadata Tables (Still Active)
- `igny8_site_builder_business_types`
- `igny8_site_builder_audience_profiles`
- `igny8_site_builder_brand_personalities`
- `igny8_site_builder_hero_imagery`
---
## API Endpoints Still Available
- `GET/POST /api/v1/site-builder/blueprints/`
- `GET/POST /api/v1/site-builder/pages/`
- `POST /api/v1/site-builder/blueprints/{id}/generate_structure/`
- `POST /api/v1/site-builder/blueprints/{id}/generate_all_pages/`
- `POST /api/v1/site-builder/blueprints/{id}/clusters/attach`
- `POST /api/v1/site-builder/blueprints/{id}/taxonomies/`
- `GET /api/v1/site-builder/metadata/`
---
## Services Still Active
- `StructureGenerationService` - AI structure generation
- `PageGenerationService` - Page content generation
- `TaxonomyService` - Taxonomy management
- `SiteBuilderFileService` - File management
---
## Summary
**Removed:** Wizard UI, WorkflowState model/service, 6-step guided process
**Kept:** All Site Builder models, tables, API endpoints, services
**Changed:** Workflow now bypasses wizard, goes directly Planning → Writer
**Database:** Clean migration state, WorkflowState table removed, all other data preserved

Binary file not shown.

View File

@@ -32,7 +32,6 @@ import {
} from "../../services/api"; } from "../../services/api";
import { useSiteStore } from "../../store/siteStore"; import { useSiteStore } from "../../store/siteStore";
import { useSectorStore } from "../../store/sectorStore"; import { useSectorStore } from "../../store/sectorStore";
import Alert from "../../components/ui/alert/Alert";
interface DashboardStats { interface DashboardStats {
keywords: { keywords: {
@@ -73,7 +72,6 @@ export default function PlannerDashboard() {
const [stats, setStats] = useState<DashboardStats | null>(null); const [stats, setStats] = useState<DashboardStats | null>(null);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);
const [lastUpdated, setLastUpdated] = useState<Date>(new Date()); const [lastUpdated, setLastUpdated] = useState<Date>(new Date());
const [incompleteBlueprints, setIncompleteBlueprints] = useState<SiteBlueprint[]>([]);
// Fetch real data // Fetch real data
const fetchDashboardData = async () => { const fetchDashboardData = async () => {
@@ -88,15 +86,6 @@ export default function PlannerDashboard() {
activeSite?.id ? fetchSiteBlueprints({ site_id: activeSite.id, page_size: 100 }) : Promise.resolve({ results: [] }) activeSite?.id ? fetchSiteBlueprints({ site_id: activeSite.id, page_size: 100 }) : Promise.resolve({ results: [] })
]); ]);
// Check for incomplete blueprints
if (blueprintsRes.results) {
const incomplete = blueprintsRes.results.filter((bp: SiteBlueprint) => {
const workflow = bp.workflow_state;
return workflow && !workflow.completed && workflow.blocking_reason;
});
setIncompleteBlueprints(incomplete);
}
const keywords = keywordsRes.results || []; const keywords = keywordsRes.results || [];
const mappedKeywords = keywords.filter(k => k.cluster && k.cluster.length > 0); const mappedKeywords = keywords.filter(k => k.cluster && k.cluster.length > 0);
const unmappedKeywords = keywords.filter(k => !k.cluster || k.cluster.length === 0); const unmappedKeywords = keywords.filter(k => !k.cluster || k.cluster.length === 0);
@@ -472,37 +461,6 @@ export default function PlannerDashboard() {
onRefresh={fetchDashboardData} onRefresh={fetchDashboardData}
/> />
{/* Incomplete Blueprints Banner */}
{incompleteBlueprints.length > 0 && (
<Alert variant="warning" className="mb-6">
<div className="flex items-start justify-between">
<div className="flex-1">
<strong className="block mb-2">Incomplete Site Builder Workflows</strong>
<p className="text-sm mb-3">
{incompleteBlueprints.length} blueprint{incompleteBlueprints.length > 1 ? 's' : ''} {incompleteBlueprints.length > 1 ? 'have' : 'has'} incomplete workflows that need attention:
</p>
<ul className="list-disc list-inside space-y-1 text-sm mb-3">
{incompleteBlueprints.map((bp) => (
<li key={bp.id}>
<Link
to={`/sites/builder/workflow/${bp.id}`}
className="text-blue-600 dark:text-blue-400 hover:underline"
>
{bp.name}
</Link>
{bp.workflow_state?.blocking_reason && (
<span className="text-gray-600 dark:text-gray-400 ml-2">
- {bp.workflow_state.blocking_reason}
</span>
)}
</li>
))}
</ul>
</div>
</div>
</Alert>
)}
<div className="space-y-6"> <div className="space-y-6">
{/* Key Metrics */} {/* Key Metrics */}
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6"> <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">

View File

@@ -2140,7 +2140,6 @@ export interface SiteBlueprint {
created_at: string; created_at: string;
updated_at: string; updated_at: string;
pages?: PageBlueprint[]; pages?: PageBlueprint[];
workflow_state?: WorkflowState;
gating_messages?: string[]; gating_messages?: string[];
} }
@@ -2158,65 +2157,6 @@ export interface PageBlueprint {
updated_at: string; updated_at: string;
} }
export interface WorkflowState {
current_step: string;
completed: boolean;
blocking_reason?: string;
steps: Array<{
step: string;
status: string;
code?: string;
message?: string;
updated_at?: string;
}>;
updated_at: string;
}
export interface WizardContext {
workflow: WorkflowState;
cluster_summary: {
attached_count: number;
coverage_counts: Record<string, number>;
clusters: Array<{
id: number;
name: string;
keyword_count: number;
volume: number;
context_type?: string;
dimension_meta?: Record<string, any>;
coverage_status: string;
role: string;
metadata?: Record<string, any>;
suggested_taxonomies?: string[];
attribute_hints?: string[];
}>;
};
taxonomy_summary: {
total_taxonomies: number;
counts_by_type: Record<string, number>;
taxonomies: Array<{
id: number;
name: string;
slug: string;
taxonomy_type: string;
description?: string;
cluster_ids: number[];
metadata?: Record<string, any>;
external_reference?: string;
}>;
};
sitemap_summary?: {
pages_total: number;
pages_by_status: Record<string, number>;
pages_by_type: Record<string, number>;
};
next_actions?: {
step: string | null;
status: string;
message: string | null;
code: string | null;
};
}
export async function fetchSiteBlueprints(filters?: { export async function fetchSiteBlueprints(filters?: {
site_id?: number; site_id?: number;
@@ -2431,21 +2371,6 @@ export async function updateSiteBlueprint(id: number, data: Partial<SiteBlueprin
}); });
} }
export async function fetchWizardContext(blueprintId: number): Promise<WizardContext> {
return fetchAPI(`/v1/site-builder/blueprints/${blueprintId}/workflow/context/`);
}
export async function updateWorkflowStep(
blueprintId: number,
step: string,
status: string,
metadata?: Record<string, any>
): Promise<WorkflowState> {
return fetchAPI(`/v1/site-builder/blueprints/${blueprintId}/workflow/step/`, {
method: 'POST',
body: JSON.stringify({ step, status, metadata }),
});
}
// Cluster attachment endpoints // Cluster attachment endpoints
export async function attachClustersToBlueprint( export async function attachClustersToBlueprint(

View File

@@ -139,30 +139,23 @@ Each entry must include:
### Documentation Files Structure ### Documentation Files Structure
``` ```
docs/ master-docs/ # Master documentation (permanent reference)
├── 00-DOCUMENTATION-MANAGEMENT.md # This file (management guide) ├── 00-DOCUMENTATION-MANAGEMENT.md # This file (management guide)
├── 01-TECH-STACK-AND-INFRASTRUCTURE.md ├── 01-TECH-STACK-AND-INFRASTRUCTURE.md
├── 02-APPLICATION-ARCHITECTURE.md ├── 02-APPLICATION-ARCHITECTURE.md
├── 03-FRONTEND-ARCHITECTURE.md ├── 03-FRONTEND-ARCHITECTURE.md
├── 04-BACKEND-IMPLEMENTATION.md ├── 04-BACKEND-IMPLEMENTATION.md
├── 05-AI-FRAMEWORK-IMPLEMENTATION.md ├── 05-AI-FRAMEWORK-IMPLEMENTATION.md
├── 06-FUNCTIONAL-BUSINESS-LOGIC.md ├── 06-FUNCTIONAL-BUSINESS-LOGIC.md # Includes complete workflow documentation
├── API-COMPLETE-REFERENCE.md ├── API-COMPLETE-REFERENCE.md
── WORDPRESS-PLUGIN-INTEGRATION.md ── WORDPRESS-PLUGIN-INTEGRATION.md
├── planning/ # Architecture & implementation planning
│ ├── IGNY8-HOLISTIC-ARCHITECTURE-PLAN.md active-workflow-docs/ # Current state and active work (single file)
│ ├── IGNY8-IMPLEMENTATION-PLAN.md └── CURRENT_WORKFLOW_STATUS.md # Single source of truth for current system state
│ ├── Igny8-phase-2-plan.md
│ ├── CONTENT-WORKFLOW-DIAGRAM.md
│ ├── ARCHITECTURE_CONTEXT.md
│ └── sample-usage-limits-credit-system
└── refactor/ # Refactoring plans and documentation
├── README.md
├── routes/
├── folder-structure/
└── migrations/
``` ```
**Note:** The `refactor-plan/` folder has been removed after consolidating relevant content into master docs.
### Documentation Update Checklist ### Documentation Update Checklist
- [ ] Identify which documentation file(s) need updating - [ ] Identify which documentation file(s) need updating
@@ -405,7 +398,7 @@ This system is finalized and should not be changed without explicit user approva
--- ---
**Last Updated:** 2025-01-XX **Last Updated:** 2025-01-XX (Documentation structure updated)
**Version:** 1.0.0 **Version:** 1.0.0
**Status:** Locked **Status:** Locked

View File

@@ -1,6 +1,6 @@
# IGNY8 Technology Stack & Infrastructure # IGNY8 Technology Stack & Infrastructure
**Last Updated:** 2025-01-XX **Last Updated:** 2025-01-XX (Added Sites Renderer container, updated module count, fixed React Router versions)
**Purpose:** Complete technology stack, infrastructure setup, Docker deployment, and fresh installation guide for the IGNY8 platform. **Purpose:** Complete technology stack, infrastructure setup, Docker deployment, and fresh installation guide for the IGNY8 platform.
--- ---
@@ -32,7 +32,7 @@
- **Deployment**: Docker-based containerization - **Deployment**: Docker-based containerization
- **Reverse Proxy**: Caddy (HTTPS termination) - **Reverse Proxy**: Caddy (HTTPS termination)
- **AI Functions**: 5 primary AI operations - **AI Functions**: 5 primary AI operations
- **Modules**: 5 core modules (Planner, Writer, Thinker, System, Billing) - **Modules**: 10 backend modules (Planner, Writer, System, Billing, Automation, Integration, Linker, Optimizer, Publisher, Site Builder)
--- ---
@@ -68,7 +68,8 @@
| **Build Tool** | Vite | 6.1.0 | Build tool & dev server | | **Build Tool** | Vite | 6.1.0 | Build tool & dev server |
| **Styling** | Tailwind CSS | 4.0.8 | Utility-first CSS | | **Styling** | Tailwind CSS | 4.0.8 | Utility-first CSS |
| **State Management** | Zustand | 5.0.8 | Lightweight state | | **State Management** | Zustand | 5.0.8 | Lightweight state |
| **Routing** | React Router | v7.9.5 | Client-side routing | | **Routing** | react-router | ^7.1.5 | Core routing library |
| **Routing** | react-router-dom | ^7.9.5 | DOM bindings for React Router |
| **HTTP Client** | Fetch API | Native | API communication | | **HTTP Client** | Fetch API | Native | API communication |
| **SEO** | react-helmet-async | 2.0.5 | Dynamic head management | | **SEO** | react-helmet-async | 2.0.5 | Dynamic head management |
@@ -304,12 +305,17 @@
**Principle**: Clear module boundaries with shared utilities. **Principle**: Clear module boundaries with shared utilities.
**Modules**: **Backend Modules**:
- **Planner**: Keywords, Clusters, Ideas - **Planner**: Keywords, Clusters, Ideas
- **Writer**: Tasks, Content, Images - **Writer**: Tasks, Content, Images
- **Thinker**: Prompts, Author Profiles, Strategies, Image Testing
- **System**: Settings, Integrations, AI Configuration - **System**: Settings, Integrations, AI Configuration
- **Billing**: Credits, Transactions, Usage - **Billing**: Credits, Transactions, Usage
- **Automation**: Automation workflows
- **Integration**: External integrations
- **Linker**: Internal linking
- **Optimizer**: Content optimization
- **Publisher**: Publishing workflows
- **Site Builder**: Site blueprint management
- **Auth**: Accounts, Users, Sites, Sectors - **Auth**: Accounts, Users, Sites, Sectors
--- ---
@@ -341,6 +347,7 @@ The system uses a two-stack Docker architecture:
| **Backend** | `igny8_backend` | 8011:8010 | Django REST API | | **Backend** | `igny8_backend` | 8011:8010 | Django REST API |
| **Frontend** | `igny8_frontend` | 8021:5173 | React application (main app) | | **Frontend** | `igny8_frontend` | 8021:5173 | React application (main app) |
| **Marketing Dev** | `igny8_marketing_dev` | 8023:5174 | Marketing site (dev server) | | **Marketing Dev** | `igny8_marketing_dev` | 8023:5174 | Marketing site (dev server) |
| **Sites Renderer** | `igny8_sites` | 8024:5176 | Serves deployed public sites (sites.igny8.com) |
| **Celery Worker** | `igny8_celery_worker` | - | Async task processing | | **Celery Worker** | `igny8_celery_worker` | - | Async task processing |
| **Celery Beat** | `igny8_celery_beat` | - | Scheduled tasks | | **Celery Beat** | `igny8_celery_beat` | - | Scheduled tasks |
@@ -376,6 +383,7 @@ The system uses a two-stack Docker architecture:
| **Backend** | 8011 | 8010 | http://localhost:8011 | | **Backend** | 8011 | 8010 | http://localhost:8011 |
| **Frontend** | 8021 | 5173 | http://localhost:8021 | | **Frontend** | 8021 | 5173 | http://localhost:8021 |
| **Marketing Dev** | 8023 | 5174 | http://localhost:8023 | | **Marketing Dev** | 8023 | 5174 | http://localhost:8023 |
| **Sites Renderer** | 8024 | 5176 | http://localhost:8024 |
--- ---
@@ -809,6 +817,18 @@ docker images | grep igny8-frontend
docker images | grep igny8-marketing docker images | grep igny8-marketing
``` ```
#### 7.3 Build Sites Renderer Image
```bash
cd /data/app/igny8/sites
# Build sites renderer dev image
docker build -t igny8-sites-dev:latest -f Dockerfile.dev .
# Verify image
docker images | grep igny8-sites
```
**Note**: For production, also build production images: **Note**: For production, also build production images:
```bash ```bash
# Production frontend image # Production frontend image
@@ -857,6 +877,7 @@ VITE_BACKEND_URL=https://api.igny8.com/api
**Edit Caddyfile** for domain routing: **Edit Caddyfile** for domain routing:
- `igny8.com` → Marketing site - `igny8.com` → Marketing site
- `app.igny8.com` → Main application - `app.igny8.com` → Main application
- `sites.igny8.com` → Sites renderer (deployed public sites)
- `api.igny8.com` → Backend API - `api.igny8.com` → Backend API
--- ---
@@ -960,9 +981,10 @@ docker compose -f docker-compose.app.yml -p igny8-app ps
1. **Marketing Site**: `https://igny8.com` (or `http://your-ip:8023` for dev) 1. **Marketing Site**: `https://igny8.com` (or `http://your-ip:8023` for dev)
2. **Main App**: `https://app.igny8.com` (or `http://your-ip:8021` for dev) 2. **Main App**: `https://app.igny8.com` (or `http://your-ip:8021` for dev)
3. **Backend API**: `https://api.igny8.com/api/v1/system/status/` 3. **Sites Renderer**: `https://sites.igny8.com` (or `http://your-ip:8024` for dev)
4. **Portainer**: `http://your-ip:9000` 4. **Backend API**: `https://api.igny8.com/api/v1/system/status/`
5. **pgAdmin**: `http://your-ip:5050` 5. **Portainer**: `http://your-ip:9000`
6. **pgAdmin**: `http://your-ip:5050`
#### 12.3 Check Logs #### 12.3 Check Logs
@@ -976,6 +998,9 @@ docker logs igny8_frontend
# Marketing logs # Marketing logs
docker logs igny8_marketing_dev docker logs igny8_marketing_dev
# Sites renderer logs
docker logs igny8_sites
# Check for errors # Check for errors
docker logs igny8_backend 2>&1 | grep -i error docker logs igny8_backend 2>&1 | grep -i error
``` ```
@@ -1094,6 +1119,8 @@ git pull
# Rebuild images # Rebuild images
docker build -t igny8-backend:latest -f backend/Dockerfile ./backend docker build -t igny8-backend:latest -f backend/Dockerfile ./backend
docker build -t igny8-frontend-dev:latest -f frontend/Dockerfile.dev ./frontend docker build -t igny8-frontend-dev:latest -f frontend/Dockerfile.dev ./frontend
docker build -t igny8-marketing-dev:latest -f frontend/Dockerfile.marketing.dev ./frontend
docker build -t igny8-sites-dev:latest -f sites/Dockerfile.dev ./sites
# Restart services # Restart services
docker compose -f docker-compose.app.yml -p igny8-app up -d docker compose -f docker-compose.app.yml -p igny8-app up -d

View File

@@ -1,6 +1,6 @@
# IGNY8 Application Architecture # IGNY8 Application Architecture
**Last Updated:** 2025-01-XX **Last Updated:** 2025-01-XX (Added 6 missing modules: Linker, Optimizer, Publisher, Site Builder, Automation, Integration)
**Purpose:** Complete application architecture documentation covering system hierarchy, user roles, access control, modules, workflows, data models, multi-tenancy, API architecture, and security. **Purpose:** Complete application architecture documentation covering system hierarchy, user roles, access control, modules, workflows, data models, multi-tenancy, API architecture, and security.
--- ---
@@ -34,6 +34,12 @@
| **Content Generation** | AI-powered blog post and article generation | Writer | | **Content Generation** | AI-powered blog post and article generation | Writer |
| **Image Generation** | AI-powered image generation (DALL-E, Runware) | Writer | | **Image Generation** | AI-powered image generation (DALL-E, Runware) | Writer |
| **WordPress Integration** | Direct publishing to WordPress sites | Writer | | **WordPress Integration** | Direct publishing to WordPress sites | Writer |
| **Internal Linking** | AI-powered internal linking suggestions | Linker |
| **Content Optimization** | Content scoring and optimization suggestions | Optimizer |
| **Site Publishing** | Publishing records and site deployment | Publisher |
| **Site Blueprints** | Site structure and page blueprint management | Site Builder |
| **Automation** | Automation rules and scheduled tasks | Automation |
| **Site Integration** | External platform integrations and sync | Integration |
| **Account Management** | Multi-account SaaS with user roles | Auth | | **Account Management** | Multi-account SaaS with user roles | Auth |
| **Billing & Credits** | Credit-based billing system | Billing | | **Billing & Credits** | Credit-based billing system | Billing |
| **AI Configuration** | Customizable AI prompts and settings | System | | **AI Configuration** | Customizable AI prompts and settings | System |
@@ -145,7 +151,13 @@ Task (1) ──< (N) Images
| Module | Purpose | Models | ViewSets | Celery Tasks | | Module | Purpose | Models | ViewSets | Celery Tasks |
|--------|---------|--------|----------|--------------| |--------|---------|--------|----------|--------------|
| **Planner** | Keyword management & content planning | Keywords, Clusters, ContentIdeas | KeywordViewSet, ClusterViewSet, ContentIdeasViewSet | auto_cluster_keywords_task, auto_generate_ideas_task | | **Planner** | Keyword management & content planning | Keywords, Clusters, ContentIdeas | KeywordViewSet, ClusterViewSet, ContentIdeasViewSet | auto_cluster_keywords_task, auto_generate_ideas_task |
| **Writer** | Content generation & management | Tasks, Content, Images | TasksViewSet, ImagesViewSet | auto_generate_content_task, auto_generate_images_task | | **Writer** | Content generation & management | Tasks, Content, Images | TasksViewSet, ContentViewSet, ImagesViewSet | auto_generate_content_task, auto_generate_images_task |
| **Linker** | Internal linking operations | - | LinkerViewSet | - |
| **Optimizer** | Content optimization & scoring | - | OptimizerViewSet | - |
| **Publisher** | Publishing records & site deployment | PublishingRecord, DeploymentRecord | PublishingRecordViewSet, DeploymentRecordViewSet, PublisherViewSet | - |
| **Site Builder** | Site blueprint management | SiteBlueprint, PageBlueprint, SiteBlueprintCluster, SiteBlueprintTaxonomy | SiteBlueprintViewSet, PageBlueprintViewSet, SiteAssetView, SiteBuilderMetadataView | - |
| **Automation** | Automation rules & scheduled tasks | AutomationRule, ScheduledTask | AutomationRuleViewSet, ScheduledTaskViewSet | - |
| **Integration** | External platform integrations | SiteIntegration | IntegrationViewSet | - |
| **System** | Settings, prompts, integrations | AIPrompt, IntegrationSettings, AuthorProfile, Strategy | AIPromptViewSet, IntegrationSettingsViewSet, AuthorProfileViewSet | - | | **System** | Settings, prompts, integrations | AIPrompt, IntegrationSettings, AuthorProfile, Strategy | AIPromptViewSet, IntegrationSettingsViewSet, AuthorProfileViewSet | - |
| **Billing** | Credits, transactions, usage | CreditTransaction, CreditUsageLog | CreditTransactionViewSet, CreditUsageLogViewSet | - | | **Billing** | Credits, transactions, usage | CreditTransaction, CreditUsageLog | CreditTransactionViewSet, CreditUsageLogViewSet | - |
| **Auth** | Multi-tenancy, users, accounts | Account, User, Plan, Site, Sector | AccountViewSet, UserViewSet, SiteViewSet, SectorViewSet | - | | **Auth** | Multi-tenancy, users, accounts | Account, User, Plan, Site, Sector | AccountViewSet, UserViewSet, SiteViewSet, SectorViewSet | - |
@@ -156,6 +168,12 @@ Task (1) ──< (N) Images
Auth (Core) Auth (Core)
├── Planner (depends on Auth) ├── Planner (depends on Auth)
├── Writer (depends on Auth, Planner) ├── Writer (depends on Auth, Planner)
├── Linker (depends on Auth, Writer)
├── Optimizer (depends on Auth, Writer)
├── Publisher (depends on Auth, Writer, Site Builder)
├── Site Builder (depends on Auth, Planner)
├── Automation (depends on Auth, Planner, Writer)
├── Integration (depends on Auth, Writer)
├── System (depends on Auth) ├── System (depends on Auth)
└── Billing (depends on Auth) └── Billing (depends on Auth)
``` ```
@@ -213,6 +231,117 @@ Auth (Core)
- `AuthorProfile`: Writing style profiles - `AuthorProfile`: Writing style profiles
- `Strategy`: Content strategies - `Strategy`: Content strategies
#### Linker Module
**Purpose**: Internal linking operations for content
**Features**:
- AI-powered internal linking suggestions
- Content-to-content link analysis
- Cluster-based link recommendations
- Batch linking operations
- Link validation and management
**ViewSets**:
- `LinkerViewSet`: Process content for internal linking
#### Optimizer Module
**Purpose**: Content optimization and scoring
**Features**:
- Content analysis and scoring
- SEO optimization suggestions
- Readability improvements
- Content quality metrics
- Batch optimization operations
**ViewSets**:
- `OptimizerViewSet`: Optimize and analyze content
#### Publisher Module
**Purpose**: Publishing records and site deployment
**Features**:
- Publishing record tracking
- Deployment record management
- Site definition management
- Publishing status tracking
- Multi-destination publishing support
**Models**:
- `PublishingRecord`: Records of content publishing
- `DeploymentRecord`: Site deployment records
**ViewSets**:
- `PublishingRecordViewSet`: Manage publishing records
- `DeploymentRecordViewSet`: Manage deployment records
- `PublisherViewSet`: Publishing operations
#### Site Builder Module
**Purpose**: Site blueprint and structure management
**Features**:
- Site blueprint creation and management
- Page blueprint management
- Cluster attachment to blueprints
- Taxonomy management
- Site structure generation
- Page content generation
- Site asset management
**Models**:
- `SiteBlueprint`: Site structure blueprints
- `PageBlueprint`: Individual page blueprints
- `SiteBlueprintCluster`: Cluster-to-blueprint links
- `SiteBlueprintTaxonomy`: Taxonomy definitions
**ViewSets**:
- `SiteBlueprintViewSet`: Manage site blueprints
- `PageBlueprintViewSet`: Manage page blueprints
- `SiteAssetView`: File management for site assets
- `SiteBuilderMetadataView`: Metadata for site builder
**Note**: Site Builder Wizard UI has been removed. Blueprints can be managed via API.
#### Automation Module
**Purpose**: Automation rules and scheduled tasks
**Features**:
- Automation rule creation and management
- Scheduled task management
- Rule execution tracking
- Trigger-based automation
- Conditional automation workflows
**Models**:
- `AutomationRule`: Automation rule definitions
- `ScheduledTask`: Scheduled task records
**ViewSets**:
- `AutomationRuleViewSet`: Manage automation rules
- `ScheduledTaskViewSet`: Manage scheduled tasks
#### Integration Module
**Purpose**: External platform integrations and synchronization
**Features**:
- Site integration management (WordPress, etc.)
- Integration connection testing
- Content synchronization
- Sync health monitoring
- Multi-platform publishing support
**Models**:
- `SiteIntegration`: Site-to-platform integration records
**ViewSets**:
- `IntegrationViewSet`: Manage site integrations
#### Billing Module #### Billing Module
**Purpose**: Credit management and usage tracking **Purpose**: Credit management and usage tracking
@@ -634,6 +763,12 @@ Results (Account-Isolated)
- `/api/v1/auth/` - Accounts, users, sites, sectors, plans - `/api/v1/auth/` - Accounts, users, sites, sectors, plans
- `/api/v1/planner/` - Keywords, clusters, ideas - `/api/v1/planner/` - Keywords, clusters, ideas
- `/api/v1/writer/` - Tasks, content, images - `/api/v1/writer/` - Tasks, content, images
- `/api/v1/linker/` - Internal linking operations
- `/api/v1/optimizer/` - Content optimization operations
- `/api/v1/publisher/` - Publishing records, deployment records
- `/api/v1/site-builder/` - Site blueprints, page blueprints, assets
- `/api/v1/automation/` - Automation rules, scheduled tasks
- `/api/v1/integration/` - Site integrations, sync operations
- `/api/v1/system/` - Prompts, integrations, author-profiles, strategies - `/api/v1/system/` - Prompts, integrations, author-profiles, strategies
- `/api/v1/billing/` - Credits, transactions, usage - `/api/v1/billing/` - Credits, transactions, usage
@@ -783,13 +918,18 @@ The IGNY8 application architecture provides:
1. **Multi-Tenancy**: Complete account isolation with automatic filtering 1. **Multi-Tenancy**: Complete account isolation with automatic filtering
2. **Hierarchical Organization**: Account > Site > Sector > Content structure 2. **Hierarchical Organization**: Account > Site > Sector > Content structure
3. **Role-Based Access**: Granular permissions for different user roles 3. **Role-Based Access**: Granular permissions for different user roles
4. **Module-Based Design**: Clear separation of concerns across modules 4. **Module-Based Design**: Clear separation of concerns across 10 backend modules
5. **Complete Workflows**: End-to-end workflows from keyword import to publishing 5. **Complete Workflows**: End-to-end workflows from keyword import to publishing
6. **AI Integration**: Unified AI framework for all AI operations 6. **AI Integration**: Unified AI framework for all AI operations
7. **WordPress Integration**: Direct publishing to WordPress sites 7. **Content Optimization**: Internal linking and content optimization tools
8. **Credit System**: Credit-based billing and usage tracking 8. **Publishing System**: Multi-destination publishing with deployment tracking
9. **Security First**: JWT auth, RBAC, data isolation 9. **Site Builder**: Site blueprint and structure management (API-based)
10. **Scalable Design**: Supports multiple accounts, sites, and users 10. **Automation**: Rule-based automation and scheduled tasks
11. **Integration**: External platform integrations and synchronization
12. **WordPress Integration**: Direct publishing to WordPress sites
13. **Credit System**: Credit-based billing and usage tracking
14. **Security First**: JWT auth, RBAC, data isolation
15. **Scalable Design**: Supports multiple accounts, sites, and users
This architecture ensures scalability, maintainability, and extensibility while providing a robust foundation for the IGNY8 platform. This architecture ensures scalability, maintainability, and extensibility while providing a robust foundation for the IGNY8 platform.

View File

@@ -1,6 +1,6 @@
# IGNY8 Frontend Architecture Documentation # IGNY8 Frontend Architecture Documentation
**Last Updated:** 2025-01-XX **Last Updated:** 2025-01-XX (Added Sites Renderer application, updated routing with Linker/Optimizer/Sites modules, fixed React Router versions)
**Version:** 1.0 **Version:** 1.0
**Purpose:** Master-level architecture and functional documentation for the IGNY8 frontend application, covering structure, routing, state management, build system, and all functional details. **Purpose:** Master-level architecture and functional documentation for the IGNY8 frontend application, covering structure, routing, state management, build system, and all functional details.
@@ -30,12 +30,13 @@
## Executive Summary ## Executive Summary
The IGNY8 frontend is a modern, dual-application React-based system consisting of: The IGNY8 frontend is a modern, triple-application React-based system consisting of:
1. **Main Application** (`app.igny8.com`): A full-featured SaaS platform for SEO content management with authentication, multi-tenancy, and complex workflows 1. **Main Application** (`app.igny8.com`): A full-featured SaaS platform for SEO content management with authentication, multi-tenancy, and complex workflows
2. **Marketing Site** (`igny8.com`): A public-facing marketing website with SEO-optimized pages 2. **Marketing Site** (`igny8.com`): A public-facing marketing website with SEO-optimized pages
3. **Sites Renderer** (`sites.igny8.com`): A public-facing site renderer that serves deployed IGNY8-hosted sites
Both applications share the same codebase but are built and deployed separately, using different entry points, routing, and build configurations. All three applications share components and utilities but are built and deployed separately, using different entry points, routing, and build configurations.
### Key Characteristics ### Key Characteristics
@@ -67,7 +68,8 @@ Both applications share the same codebase but are built and deployed separately,
|------------|---------|---------| |------------|---------|---------|
| **React** | 19.0.0 | UI library | | **React** | 19.0.0 | UI library |
| **React DOM** | 19.0.0 | DOM rendering | | **React DOM** | 19.0.0 | DOM rendering |
| **React Router** | 7.9.5 | Client-side routing | | **react-router** | ^7.1.5 | Core routing library |
| **react-router-dom** | ^7.9.5 | DOM bindings for React Router |
| **Zustand** | 5.0.8 | State management | | **Zustand** | 5.0.8 | State management |
| **Vite** | 6.1.0 | Build tool & dev server | | **Vite** | 6.1.0 | Build tool & dev server |
@@ -87,6 +89,7 @@ Both applications share the same codebase but are built and deployed separately,
{ {
"react": "^19.0.0", "react": "^19.0.0",
"react-dom": "^19.0.0", "react-dom": "^19.0.0",
"react-router": "^7.1.5",
"react-router-dom": "^7.9.5", "react-router-dom": "^7.9.5",
"zustand": "^5.0.8", "zustand": "^5.0.8",
"typescript": "~5.7.2" "typescript": "~5.7.2"
@@ -144,15 +147,15 @@ Both applications share the same codebase but are built and deployed separately,
│ Frontend Application │ │ Frontend Application │
├─────────────────────────────────────────────────────────────┤ ├─────────────────────────────────────────────────────────────┤
│ │ │ │
│ ┌──────────────────────┐ ┌──────────────────────┐ │ │ ┌──────────────────────┐ ┌──────────────────────┐ ┌──────────────────────┐
│ │ Main Application │ │ Marketing Site │ │ │ │ Main Application │ │ Marketing Site │ │ Sites Renderer │ │
│ │ (app.igny8.com) │ │ (igny8.com) │ │ │ │ (app.igny8.com) │ │ (igny8.com) │ │ (sites.igny8.com) │ │
│ ├──────────────────────┤ ├──────────────────────┤ │ │ ├──────────────────────┤ ├──────────────────────┤ ├──────────────────────┤
│ │ • Authentication │ │ • Public Pages │ │ │ │ • Authentication │ │ • Public Pages │ │ • Public Sites │ │
│ │ • Multi-tenant │ │ • SEO Optimized │ │ │ │ • Multi-tenant │ │ • SEO Optimized │ │ • Dynamic Content │ │
│ │ • Protected Routes │ │ • No Authentication │ │ │ │ • Protected Routes │ │ • No Authentication │ │ • No Authentication │ │
│ │ • Complex Workflows │ │ • Static Content │ │ │ │ • Complex Workflows │ │ • Static Content │ │ • Site Blueprints │ │
│ └──────────────────────┘ └──────────────────────┘ │ │ └──────────────────────┘ └──────────────────────┘ └──────────────────────┘
│ │ │ │ │ │ │ │
│ └──────────┬───────────────────┘ │ │ └──────────┬───────────────────┘ │
│ │ │ │ │ │
@@ -187,6 +190,13 @@ Both applications share the same codebase but are built and deployed separately,
- **Port**: 5174 (dev), 8023 (Docker) - **Port**: 5174 (dev), 8023 (Docker)
- **Domain**: `igny8.com` - **Domain**: `igny8.com`
#### Sites Renderer Entry
- **File**: `sites/src/main.tsx` (separate repository/package)
- **HTML**: `sites/index.html`
- **Port**: 5176 (dev), 8024 (Docker)
- **Domain**: `sites.igny8.com`
- **Purpose**: Renders deployed public sites from Site Blueprints
--- ---
## Project Structure ## Project Structure
@@ -274,12 +284,18 @@ frontend/
├── vite.config.ts # Vite configuration ├── vite.config.ts # Vite configuration
├── tsconfig.json # TypeScript config ├── tsconfig.json # TypeScript config
├── package.json # Dependencies ├── package.json # Dependencies
── Dockerfile* # Docker files ── Dockerfile* # Docker files
└── sites/ # Sites Renderer (separate app)
├── src/ # Sites renderer source
├── index.html # Sites renderer HTML
├── vite.config.ts # Sites Vite config
├── package.json # Sites dependencies
└── Dockerfile.dev # Sites dev Dockerfile
``` ```
--- ---
## Dual Application Architecture ## Triple Application Architecture
### Main Application (`app.igny8.com`) ### Main Application (`app.igny8.com`)
@@ -358,6 +374,42 @@ frontend/
- Open Graph tags - Open Graph tags
- Twitter Card tags - Twitter Card tags
### Sites Renderer (`sites.igny8.com`)
**Purpose**: Public-facing site renderer for deployed IGNY8-hosted sites
**Characteristics**:
- No authentication required
- Dynamic content from Site Blueprints
- Public access to deployed sites
- Separate codebase (`sites/` directory)
- React Router for site navigation
- API integration for blueprint data
**Entry Point**: `sites/src/main.tsx``sites/src/App.tsx`
**Technology Stack**:
- React 19.2.0
- React Router DOM 7.9.6
- TypeScript 5.9.3
- Vite 7.2.2
- Zustand 5.0.8
- Axios 1.13.2
**Features**:
- Loads site definitions from backend API
- Renders pages from Page Blueprints
- Dynamic routing based on site structure
- SEO-optimized pages
- Responsive design
**Data Flow**:
1. Site slug extracted from URL
2. API call to fetch Site Blueprint
3. Page Blueprints loaded
4. Content rendered from blueprints
5. Navigation generated from site structure
--- ---
## Routing Architecture ## Routing Architecture
@@ -411,10 +463,34 @@ frontend/
<Route path="/reference/seed-keywords" element={<SeedKeywords />} /> <Route path="/reference/seed-keywords" element={<SeedKeywords />} />
<Route path="/reference/industries" element={<ReferenceIndustries />} /> <Route path="/reference/industries" element={<ReferenceIndustries />} />
{/* Linker Module */}
<Route path="/linker" element={<Navigate to="/linker/content" replace />} />
<Route path="/linker/content" element={<LinkerContent />} />
{/* Optimizer Module */}
<Route path="/optimizer" element={<Navigate to="/optimizer/content" replace />} />
<Route path="/optimizer/content" element={<OptimizerContent />} />
<Route path="/optimizer/analyze/:id" element={<OptimizerAnalyze />} />
{/* Automation */} {/* Automation */}
<Route path="/automation" element={<AutomationDashboard />} /> <Route path="/automation" element={<AutomationDashboard />} />
{/* Note: Schedules functionality is integrated into Automation Dashboard */} {/* Note: Schedules functionality is integrated into Automation Dashboard */}
{/* Sites Module */}
<Route path="/sites" element={<SiteList />} />
<Route path="/sites/manage" element={<SiteManage />} />
<Route path="/sites/:id" element={<SiteDashboard />} />
<Route path="/sites/:id/content" element={<SiteContent />} />
<Route path="/sites/:id/editor" element={<SiteEditor />} />
<Route path="/sites/:id/pages" element={<PageManager />} />
<Route path="/sites/:id/pages/new" element={<PageManager />} />
<Route path="/sites/:id/pages/:pageId/edit" element={<PageManager />} />
<Route path="/sites/:id/posts/:postId" element={<PostEditor />} />
<Route path="/sites/:id/preview" element={<SitePreview />} />
<Route path="/sites/:id/settings" element={<SiteSettings />} />
<Route path="/sites/:id/sync" element={<SyncDashboard />} />
<Route path="/sites/:id/deploy" element={<DeploymentPanel />} />
{/* Settings */} {/* Settings */}
<Route path="/settings" element={<GeneralSettings />} /> <Route path="/settings" element={<GeneralSettings />} />
<Route path="/settings/users" element={<Users />} /> <Route path="/settings/users" element={<Users />} />
@@ -458,6 +534,26 @@ frontend/
- Reduces initial bundle size - Reduces initial bundle size
- Improves time-to-interactive - Improves time-to-interactive
### Sites Renderer Routing
**Router**: React Router v7 (`BrowserRouter`)
**Structure**:
- Dynamic routing based on Site Blueprint structure
- Routes generated from Page Blueprints
- Public access (no authentication)
- SEO-friendly URLs
**Key Routes**:
- `/:siteSlug` - Site home page
- `/:siteSlug/:pageSlug` - Individual pages
- Dynamic navigation from site structure
**Data Loading**:
- Site Blueprint loaded on mount
- Page Blueprints loaded per route
- Content rendered from blueprint data
### Marketing Site Routing ### Marketing Site Routing
**Router**: React Router v7 (`BrowserRouter`) **Router**: React Router v7 (`BrowserRouter`)
@@ -1051,6 +1147,12 @@ build: {
- Marketing-specific configuration - Marketing-specific configuration
- SEO-friendly development - SEO-friendly development
**Sites Renderer** (Port 5176):
- Separate Vite configuration (`sites/vite.config.ts`)
- Public site rendering
- API integration for blueprints
- Dynamic routing from site structure
#### 4. Custom Plugins #### 4. Custom Plugins
**bypassHostCheck**: **bypassHostCheck**:
@@ -1128,6 +1230,13 @@ npm run dev:marketing
# Runs on http://localhost:5174 # Runs on http://localhost:5174
``` ```
**Sites Renderer**:
```bash
cd sites
npm run dev
# Runs on http://localhost:5176
```
#### 3. Build for Production #### 3. Build for Production
**Main Application**: **Main Application**:
@@ -1142,6 +1251,13 @@ npm run build:marketing
# Output: dist/marketing.html # Output: dist/marketing.html
``` ```
**Sites Renderer**:
```bash
cd sites
npm run build
# Output: sites/dist/
```
### Docker Development ### Docker Development
#### Main App Container #### Main App Container
@@ -1177,6 +1293,8 @@ docker run -p 8023:5174 \
| `dev:marketing` | `PORT=5174 vite --port 5174` | Start marketing dev server | | `dev:marketing` | `PORT=5174 vite --port 5174` | Start marketing dev server |
| `build` | `vite build` | Build main app | | `build` | `vite build` | Build main app |
| `build:marketing` | `vite build --mode marketing` | Build marketing site | | `build:marketing` | `vite build --mode marketing` | Build marketing site |
| `sites:dev` | `cd sites && npm run dev` | Start sites renderer dev server (Port 5176) |
| `sites:build` | `cd sites && npm run build` | Build sites renderer |
| `type-check` | `tsc -b --noEmit` | Type checking | | `type-check` | `tsc -b --noEmit` | Type checking |
| `lint` | `eslint .` | Lint code | | `lint` | `eslint .` | Lint code |
@@ -1206,6 +1324,25 @@ dist/
- Static file serving - Static file serving
- SPA routing fallback - SPA routing fallback
#### Sites Renderer
**Build Output**:
```
sites/dist/
├── index.html
├── assets/
│ ├── js/
│ │ └── [hash].js
│ └── css/
│ └── [hash].css
```
**Deployment**:
- Separate Docker container (`igny8_sites`)
- Served via Caddy reverse proxy
- Dynamic routing from Site Blueprints
- Public access (no authentication)
#### Marketing Site #### Marketing Site
**Build Output**: **Build Output**:
@@ -1277,6 +1414,21 @@ CMD ["caddy", "run", "--config", "/etc/caddy/Caddyfile"]
} }
``` ```
#### Sites Renderer (`Caddyfile.sites`)
```caddy
sites.igny8.com {
reverse_proxy igny8_sites:5176
encode gzip zstd
}
```
**Features**:
- Public access (no authentication)
- Dynamic routing from Site Blueprints
- SEO-friendly URLs
- HTTPS via Caddy
#### Marketing Site (`Caddyfile.marketing`) #### Marketing Site (`Caddyfile.marketing`)
```caddy ```caddy

View File

@@ -1,6 +1,6 @@
# IGNY8 Backend Implementation Reference # IGNY8 Backend Implementation Reference
**Last Updated:** 2025-01-XX **Last Updated:** 2025-01-XX (Added 6 missing modules: Linker, Optimizer, Publisher, Site Builder, Automation, Integration)
**Purpose:** Complete backend implementation reference covering project structure, models, ViewSets, serializers, Celery tasks, API endpoints, base classes, middleware, and utilities. **Purpose:** Complete backend implementation reference covering project structure, models, ViewSets, serializers, Celery tasks, API endpoints, base classes, middleware, and utilities.
--- ---
@@ -67,26 +67,56 @@ backend/igny8_core/
│ └── urls.py # Auth module URLs │ └── urls.py # Auth module URLs
├── modules/ # Feature modules ├── modules/ # Feature modules
│ ├── planner/ # Keywords, Clusters, Ideas │ ├── planner/ # Keywords, Clusters, Ideas
│ │ ├── models.py # Keywords, Clusters, ContentIdeas models
│ │ ├── views.py # KeywordViewSet, ClusterViewSet, ContentIdeasViewSet │ │ ├── views.py # KeywordViewSet, ClusterViewSet, ContentIdeasViewSet
│ │ ├── tasks.py # Celery tasks for AI operations
│ │ ├── serializers.py # Model serializers │ │ ├── serializers.py # Model serializers
│ │ └── urls.py # Planner module URLs │ │ └── urls.py # Planner module URLs
│ ├── writer/ # Tasks, Content, Images │ ├── writer/ # Tasks, Content, Images
│ │ ├── models.py # Tasks, Content, Images models │ │ ├── views.py # TasksViewSet, ContentViewSet, ImagesViewSet
│ │ ├── views.py # TasksViewSet, ImagesViewSet │ │ ├── serializers.py # Model serializers
│ │ ├── tasks.py # Celery tasks for content/image generation
│ │ └── urls.py # Writer module URLs │ │ └── urls.py # Writer module URLs
│ ├── linker/ # Internal linking
│ │ ├── views.py # LinkerViewSet
│ │ ├── serializers.py # Link serializers
│ │ └── urls.py # Linker module URLs
│ ├── optimizer/ # Content optimization
│ │ ├── views.py # OptimizerViewSet
│ │ ├── serializers.py # Optimizer serializers
│ │ └── urls.py # Optimizer module URLs
│ ├── publisher/ # Publishing & deployment
│ │ ├── views.py # PublishingRecordViewSet, DeploymentRecordViewSet, PublisherViewSet
│ │ └── urls.py # Publisher module URLs
│ ├── site_builder/ # Site blueprint management
│ │ ├── views.py # SiteBlueprintViewSet, PageBlueprintViewSet, SiteAssetView
│ │ ├── serializers.py # Site builder serializers
│ │ └── urls.py # Site Builder module URLs
│ ├── automation/ # Automation rules
│ │ ├── views.py # AutomationRuleViewSet, ScheduledTaskViewSet
│ │ ├── serializers.py # Automation serializers
│ │ └── urls.py # Automation module URLs
│ ├── integration/ # External integrations
│ │ ├── views.py # IntegrationViewSet
│ │ └── urls.py # Integration module URLs
│ ├── system/ # Settings, Prompts, Integration │ ├── system/ # Settings, Prompts, Integration
│ │ ├── models.py # AIPrompt, IntegrationSettings, AuthorProfile, Strategy │ │ ├── models.py # AIPrompt, IntegrationSettings, AuthorProfile, Strategy
│ │ ├── views.py # AIPromptViewSet, AuthorProfileViewSet │ │ ├── views.py # AIPromptViewSet, AuthorProfileViewSet
│ │ ├── settings_views.py # SystemSettingsViewSet, AccountSettingsViewSet
│ │ ├── integration_views.py # IntegrationSettingsViewSet, task_progress │ │ ├── integration_views.py # IntegrationSettingsViewSet, task_progress
│ │ ├── utils.py # Default prompts, prompt loading │ │ ├── utils.py # Default prompts, prompt loading
│ │ └── urls.py # System module URLs │ │ └── urls.py # System module URLs
│ └── billing/ # Credits, Transactions, Usage │ └── billing/ # Credits, Transactions, Usage
│ ├── models.py # CreditTransaction, CreditUsageLog models │ ├── views.py # CreditTransactionViewSet, CreditBalanceViewSet, CreditUsageViewSet
│ ├── views.py # Billing ViewSets │ ├── services.py # CreditService
│ └── services.py # CreditService │ └── urls.py # Billing module URLs
├── business/ # Business logic layer
│ ├── planning/ # Planner models (Keywords, Clusters, ContentIdeas)
│ ├── content/ # Writer models (Tasks, Content, Images)
│ ├── linking/ # Linker services
│ ├── optimization/ # Optimizer services
│ ├── publishing/ # Publisher models (PublishingRecord, DeploymentRecord)
│ ├── site_building/ # Site Builder models (SiteBlueprint, PageBlueprint, etc.)
│ ├── automation/ # Automation models (AutomationRule, ScheduledTask)
│ ├── integration/ # Integration models (SiteIntegration)
│ └── billing/ # Billing models (CreditTransaction, CreditUsageLog)
├── api/ # API base classes ├── api/ # API base classes
│ ├── base.py # AccountModelViewSet, SiteSectorModelViewSet │ ├── base.py # AccountModelViewSet, SiteSectorModelViewSet
│ └── pagination.py # CustomPageNumberPagination │ └── pagination.py # CustomPageNumberPagination
@@ -489,6 +519,17 @@ backend/igny8_core/
- Filters: `status`, `cluster_id`, `content_type`, `content_structure` - Filters: `status`, `cluster_id`, `content_type`, `content_structure`
- Ordering: `title`, `created_at`, `word_count`, `status` - Ordering: `title`, `created_at`, `word_count`, `status`
#### ContentViewSet
**Inherits**: `SiteSectorModelViewSet`
**Actions**:
- `list()`: List content
- `create()`: Create content
- `retrieve()`: Get content details
- `update()`: Update content
- `destroy()`: Delete content
- `publish_to_wordpress()`: Publish content to WordPress
#### ImagesViewSet #### ImagesViewSet
**Inherits**: `SiteSectorModelViewSet` **Inherits**: `SiteSectorModelViewSet`
@@ -500,6 +541,150 @@ backend/igny8_core/
- `destroy()`: Delete image - `destroy()`: Delete image
- `generate_images()`: Generate images using AI - `generate_images()`: Generate images using AI
### Linker ViewSets
#### LinkerViewSet
**Inherits**: `viewsets.ViewSet`
**Actions**:
- `process()`: Process a single content item for internal linking
- `batch_process()`: Process multiple content items for internal linking
**Purpose**: AI-powered internal linking suggestions based on cluster matches
### Optimizer ViewSets
#### OptimizerViewSet
**Inherits**: `viewsets.ViewSet`
**Actions**:
- `optimize()`: Optimize content (auto-detects entry point)
- `batch_optimize()`: Batch optimize multiple content items
- `analyze()`: Analyze content without optimization
**Purpose**: Content optimization and scoring
### Publisher ViewSets
#### PublishingRecordViewSet
**Inherits**: `SiteSectorModelViewSet`
**Actions**:
- `list()`: List publishing records
- `create()`: Create publishing record
- `retrieve()`: Get publishing record details
- `update()`: Update publishing record
- `destroy()`: Delete publishing record
#### DeploymentRecordViewSet
**Inherits**: `SiteSectorModelViewSet`
**Actions**:
- `list()`: List deployment records
- `create()`: Create deployment record
- `retrieve()`: Get deployment record details
- `update()`: Update deployment record
- `destroy()`: Delete deployment record
#### PublisherViewSet
**Inherits**: `viewsets.ViewSet`
**Actions**:
- `publish()`: Publish content to destination
- `deploy()`: Deploy site blueprint
- `check_readiness()`: Check deployment readiness
#### SiteDefinitionView
**Inherits**: `APIView`
**Purpose**: Public endpoint for Sites Renderer to fetch site definitions
### Site Builder ViewSets
#### SiteBlueprintViewSet
**Inherits**: `SiteSectorModelViewSet`
**Actions**:
- `list()`: List site blueprints
- `create()`: Create site blueprint
- `retrieve()`: Get site blueprint details
- `update()`: Update site blueprint
- `destroy()`: Delete site blueprint
- `generate_structure()`: Generate site structure using AI
- `generate_all_pages()`: Generate all pages for blueprint
- `create_tasks()`: Create Writer tasks for pages
- `progress()`: Get cluster-level completion status
- `attach_clusters()`: Attach planner clusters to blueprint
- `detach_clusters()`: Detach clusters from blueprint
- `list_taxonomies()`: List taxonomies for blueprint
- `create_taxonomy()`: Create taxonomy for blueprint
- `import_taxonomies()`: Import taxonomies from external source
- `bulk_delete()`: Bulk delete blueprints
#### PageBlueprintViewSet
**Inherits**: `SiteSectorModelViewSet`
**Actions**:
- `list()`: List page blueprints
- `create()`: Create page blueprint
- `retrieve()`: Get page blueprint details
- `update()`: Update page blueprint
- `destroy()`: Delete page blueprint
- `generate_content()`: Generate content for page
- `regenerate()`: Regenerate page content
#### SiteAssetView
**Inherits**: `APIView`
**Actions**:
- `GET`: List files for site
- `POST`: Upload file
- `DELETE`: Delete file
#### SiteBuilderMetadataView
**Inherits**: `APIView`
**Actions**:
- `GET`: Get metadata (business types, audience profiles, brand personalities, hero imagery)
### Automation ViewSets
#### AutomationRuleViewSet
**Inherits**: `SiteSectorModelViewSet`
**Actions**:
- `list()`: List automation rules
- `create()`: Create automation rule
- `retrieve()`: Get automation rule details
- `update()`: Update automation rule
- `destroy()`: Delete automation rule
- `execute()`: Manually execute automation rule
#### ScheduledTaskViewSet
**Inherits**: `AccountModelViewSet`
**Actions**:
- `list()`: List scheduled tasks
- `create()`: Create scheduled task
- `retrieve()`: Get scheduled task details
- `update()`: Update scheduled task
- `destroy()`: Delete scheduled task
### Integration ViewSets
#### IntegrationViewSet
**Inherits**: `SiteSectorModelViewSet`
**Actions**:
- `list()`: List site integrations
- `create()`: Create site integration
- `retrieve()`: Get integration details
- `update()`: Update integration
- `destroy()`: Delete integration
- `test_connection()`: Test connection to integrated platform
- `sync()`: Sync content with integrated platform
- `sync_health()`: Check sync health status
### System ViewSets ### System ViewSets
#### IntegrationSettingsViewSet #### IntegrationSettingsViewSet
@@ -575,6 +760,57 @@ backend/igny8_core/
#### IntegrationSettingsSerializer #### IntegrationSettingsSerializer
**Fields**: All IntegrationSettings model fields **Fields**: All IntegrationSettings model fields
### Linker Serializers
#### LinkContentSerializer
**Fields**: `content_id`
#### BatchLinkContentSerializer
**Fields**: `content_ids` (array)
### Optimizer Serializers
#### OptimizeContentSerializer
**Fields**: `content_id`, `entry_point` (optional)
#### BatchOptimizeContentSerializer
**Fields**: `content_ids` (array), `entry_point` (optional)
#### AnalyzeContentSerializer
**Fields**: `content_id`
### Publisher Serializers
#### PublishingRecordSerializer
**Fields**: All PublishingRecord model fields
#### DeploymentRecordSerializer
**Fields**: All DeploymentRecord model fields
### Site Builder Serializers
#### SiteBlueprintSerializer
**Fields**: All SiteBlueprint model fields, includes nested `pages`
#### PageBlueprintSerializer
**Fields**: All PageBlueprint model fields
#### SiteBuilderMetadataSerializer
**Fields**: `business_types`, `audience_profiles`, `brand_personalities`, `hero_imagery_directions`
### Automation Serializers
#### AutomationRuleSerializer
**Fields**: All AutomationRule model fields
#### ScheduledTaskSerializer
**Fields**: All ScheduledTask model fields
### Integration Serializers
#### SiteIntegrationSerializer
**Fields**: All SiteIntegration model fields
--- ---
## Celery Tasks ## Celery Tasks
@@ -675,9 +911,77 @@ backend/igny8_core/
### Writer Endpoints ### Writer Endpoints
- `GET /api/v1/writer/tasks/` - List tasks - `GET /api/v1/writer/tasks/` - List tasks
- `POST /api/v1/writer/tasks/` - Create task
- `GET /api/v1/writer/tasks/{id}/` - Get task details
- `POST /api/v1/writer/tasks/auto_generate_content/` - Auto-generate content - `POST /api/v1/writer/tasks/auto_generate_content/` - Auto-generate content
- `GET /api/v1/writer/content/` - List content
- `GET /api/v1/writer/content/{id}/` - Get content details
- `POST /api/v1/writer/images/generate_images/` - Generate images - `POST /api/v1/writer/images/generate_images/` - Generate images
### Linker Endpoints
- `POST /api/v1/linker/process/` - Process content for internal linking
- `POST /api/v1/linker/batch_process/` - Batch process content for linking
### Optimizer Endpoints
- `POST /api/v1/optimizer/optimize/` - Optimize content
- `POST /api/v1/optimizer/batch_optimize/` - Batch optimize content
- `POST /api/v1/optimizer/analyze/` - Analyze content
### Publisher Endpoints
- `GET /api/v1/publisher/publishing-records/` - List publishing records
- `POST /api/v1/publisher/publishing-records/` - Create publishing record
- `GET /api/v1/publisher/deployments/` - List deployment records
- `POST /api/v1/publisher/deployments/` - Create deployment record
- `POST /api/v1/publisher/publish/` - Publish content
- `POST /api/v1/publisher/deploy/` - Deploy site blueprint
- `GET /api/v1/publisher/sites/{site_id}/definition/` - Get site definition (public)
### Site Builder Endpoints
- `GET /api/v1/site-builder/blueprints/` - List site blueprints
- `POST /api/v1/site-builder/blueprints/` - Create site blueprint
- `GET /api/v1/site-builder/blueprints/{id}/` - Get blueprint details
- `POST /api/v1/site-builder/blueprints/{id}/generate_structure/` - Generate structure
- `POST /api/v1/site-builder/blueprints/{id}/generate_all_pages/` - Generate all pages
- `POST /api/v1/site-builder/blueprints/{id}/create_tasks/` - Create tasks for pages
- `GET /api/v1/site-builder/blueprints/{id}/progress/` - Get progress
- `POST /api/v1/site-builder/blueprints/{id}/clusters/attach/` - Attach clusters
- `POST /api/v1/site-builder/blueprints/{id}/clusters/detach/` - Detach clusters
- `GET /api/v1/site-builder/blueprints/{id}/taxonomies/` - List taxonomies
- `POST /api/v1/site-builder/blueprints/{id}/taxonomies/` - Create taxonomy
- `POST /api/v1/site-builder/blueprints/{id}/taxonomies/import/` - Import taxonomies
- `POST /api/v1/site-builder/blueprints/bulk_delete/` - Bulk delete blueprints
- `GET /api/v1/site-builder/pages/` - List page blueprints
- `POST /api/v1/site-builder/pages/` - Create page blueprint
- `GET /api/v1/site-builder/pages/{id}/` - Get page details
- `POST /api/v1/site-builder/pages/{id}/generate_content/` - Generate content
- `POST /api/v1/site-builder/pages/{id}/regenerate/` - Regenerate page
- `GET /api/v1/site-builder/assets/` - List assets
- `POST /api/v1/site-builder/assets/` - Upload asset
- `DELETE /api/v1/site-builder/assets/` - Delete asset
- `GET /api/v1/site-builder/metadata/` - Get metadata
### Automation Endpoints
- `GET /api/v1/automation/rules/` - List automation rules
- `POST /api/v1/automation/rules/` - Create automation rule
- `GET /api/v1/automation/rules/{id}/` - Get rule details
- `POST /api/v1/automation/rules/{id}/execute/` - Execute rule
- `GET /api/v1/automation/scheduled-tasks/` - List scheduled tasks
- `POST /api/v1/automation/scheduled-tasks/` - Create scheduled task
### Integration Endpoints
- `GET /api/v1/integration/integrations/` - List site integrations
- `POST /api/v1/integration/integrations/` - Create integration
- `GET /api/v1/integration/integrations/{id}/` - Get integration details
- `POST /api/v1/integration/integrations/{id}/test_connection/` - Test connection
- `POST /api/v1/integration/integrations/{id}/sync/` - Sync content
- `GET /api/v1/integration/integrations/{id}/sync_health/` - Get sync health
### System Endpoints ### System Endpoints
- `GET /api/v1/system/settings/integrations/{pk}/` - Get integration settings - `GET /api/v1/system/settings/integrations/{pk}/` - Get integration settings
@@ -772,29 +1076,170 @@ backend/igny8_core/
**Purpose**: Content generation and management **Purpose**: Content generation and management
**Models**: Tasks, Content, Images **Models** (in `business/content/`):
- `Tasks`: Content generation tasks
- `Content`: Generated content pieces
- `Images`: Generated images
- `ContentClusterMap`: Content-to-cluster mapping
- `ContentTaxonomyMap`: Content taxonomy mapping
- `ContentAttributeMap`: Content attribute mapping
**ViewSets**: TasksViewSet, ImagesViewSet **ViewSets**:
- `TasksViewSet`: CRUD + auto-generate content, bulk operations
- `ContentViewSet`: CRUD + publish to WordPress
- `ImagesViewSet`: CRUD + generate images
**Tasks**: Auto-generate content, Generate images **URLs**: `/api/v1/writer/`
### Linker Module
**Purpose**: Internal linking operations
**ViewSets**:
- `LinkerViewSet`: Process content for internal linking
**Actions**:
- `process()`: Process single content item
- `batch_process()`: Process multiple content items
**URLs**: `/api/v1/linker/`
### Optimizer Module
**Purpose**: Content optimization and scoring
**ViewSets**:
- `OptimizerViewSet`: Content optimization operations
**Actions**:
- `optimize()`: Optimize content (auto-detects entry point)
- `batch_optimize()`: Batch optimize content
- `analyze()`: Analyze content without optimization
**URLs**: `/api/v1/optimizer/`
### Publisher Module
**Purpose**: Publishing records and site deployment
**Models** (in `business/publishing/`):
- `PublishingRecord`: Records of content publishing
- `DeploymentRecord`: Records of site deployments
**ViewSets**:
- `PublishingRecordViewSet`: CRUD for publishing records
- `DeploymentRecordViewSet`: CRUD for deployment records
- `PublisherViewSet`: Publishing and deployment actions
- `SiteDefinitionView`: Public endpoint for Sites Renderer
**Actions**:
- `publish()`: Publish content to destination
- `deploy()`: Deploy site blueprint
- `check_readiness()`: Check deployment readiness
**URLs**: `/api/v1/publisher/`
### Site Builder Module
**Purpose**: Site blueprint management
**Models** (in `business/site_building/`):
- `SiteBlueprint`: Site structure definitions
- `PageBlueprint`: Page structure definitions
- `SiteBlueprintCluster`: Cluster-to-blueprint mapping
- `SiteBlueprintTaxonomy`: Taxonomy definitions
- `SiteBuilderOption`: Site builder configuration options
**ViewSets**:
- `SiteBlueprintViewSet`: CRUD + structure generation, cluster management
- `PageBlueprintViewSet`: CRUD + content generation
- `SiteAssetView`: Asset management
- `SiteBuilderMetadataView`: Metadata retrieval
**Actions**:
- `generate_structure()`: Generate site structure using AI
- `generate_all_pages()`: Generate all pages for blueprint
- `create_tasks()`: Create Writer tasks for pages
- `progress()`: Get cluster-level completion status
- `attach_clusters()`: Attach planner clusters
- `detach_clusters()`: Detach clusters
- `generate_content()`: Generate content for page
- `regenerate()`: Regenerate page content
**URLs**: `/api/v1/site-builder/`
**Note**: Site Builder Wizard UI has been removed. Only API-based blueprint management remains.
### Automation Module
**Purpose**: Automation rules and scheduled tasks
**Models** (in `business/automation/`):
- `AutomationRule`: Rule-based automation definitions
- `ScheduledTask`: Scheduled task definitions
**ViewSets**:
- `AutomationRuleViewSet`: CRUD + execute rule
- `ScheduledTaskViewSet`: CRUD for scheduled tasks
**Actions**:
- `execute()`: Manually execute automation rule
**URLs**: `/api/v1/automation/`
### Integration Module
**Purpose**: External platform integrations
**Models** (in `business/integration/`):
- `SiteIntegration`: Site-level integration configurations
**ViewSets**:
- `IntegrationViewSet`: CRUD + sync operations
**Actions**:
- `test_connection()`: Test connection to integrated platform
- `sync()`: Sync content with integrated platform
- `sync_health()`: Check sync health status
**URLs**: `/api/v1/integration/`
### System Module ### System Module
**Purpose**: System configuration and AI settings **Purpose**: System configuration and AI settings
**Models**: AIPrompt, IntegrationSettings, AuthorProfile, Strategy **Models**:
- `AIPrompt`: AI prompt templates
- `IntegrationSettings`: Account-level integration settings
- `AuthorProfile`: Author profile definitions
- `Strategy`: Content strategy definitions
**ViewSets**: AIPromptViewSet, IntegrationSettingsViewSet, AuthorProfileViewSet **ViewSets**:
- `AIPromptViewSet`: CRUD + reset to default
- `IntegrationSettingsViewSet`: Integration settings management
- `AuthorProfileViewSet`: CRUD for author profiles
- `SystemSettingsViewSet`: System settings management
- `AccountSettingsViewSet`: Account settings management
**URLs**: `/api/v1/system/`
### Billing Module ### Billing Module
**Purpose**: Credit management and usage tracking **Purpose**: Credit management and usage tracking
**Models**: CreditTransaction, CreditUsageLog **Models** (in `business/billing/`):
- `CreditTransaction`: Credit transaction records
- `CreditUsageLog`: Credit usage logging
**ViewSets**: CreditTransactionViewSet, CreditUsageLogViewSet **ViewSets**:
- `CreditTransactionViewSet`: CRUD for transactions
- `CreditBalanceViewSet`: Credit balance retrieval
- `CreditUsageViewSet`: Credit usage tracking
**Services**: CreditService (check, deduct, add, calculate credits) **Services**:
- `CreditService`: Credit operations (check, deduct, add, calculate)
**URLs**: `/api/v1/billing/`
--- ---
@@ -808,10 +1253,16 @@ The IGNY8 backend provides:
4. **Hierarchical Organization**: Account > Site > Sector > Content structure 4. **Hierarchical Organization**: Account > Site > Sector > Content structure
5. **AI Framework**: Unified AI framework for all AI operations 5. **AI Framework**: Unified AI framework for all AI operations
6. **Progress Tracking**: Real-time progress updates for Celery tasks 6. **Progress Tracking**: Real-time progress updates for Celery tasks
7. **Module-Based Design**: Clear separation of concerns 7. **Module-Based Design**: Clear separation of concerns across 10 modules
8. **Base Classes**: Reusable ViewSets for common patterns 8. **Base Classes**: Reusable ViewSets for common patterns
9. **Middleware**: Account context and resource tracking 9. **Middleware**: Account context and resource tracking
10. **Utilities**: Content processing and AI integration 10. **Utilities**: Content processing and AI integration
11. **Internal Linking**: AI-powered internal linking suggestions
12. **Content Optimization**: Content optimization and scoring
13. **Publishing System**: Multi-destination publishing with deployment tracking
14. **Site Builder**: Site blueprint and structure management (API-based)
15. **Automation**: Rule-based automation and scheduled tasks
16. **Integration**: External platform integrations and synchronization
This architecture ensures scalability, maintainability, and extensibility while providing a robust foundation for the IGNY8 platform. This architecture ensures scalability, maintainability, and extensibility while providing a robust foundation for the IGNY8 platform with 10 backend modules covering the complete content workflow from planning to publishing.

View File

@@ -1,7 +1,7 @@
# IGNY8 AI Framework Implementation Reference # IGNY8 AI Framework Implementation Reference
**Last Updated:** 2025-01-XX **Last Updated:** 2025-01-XX (Added 3 missing AI functions: generate_site_structure, optimize_content, generate_page_content)
**Purpose:** Complete AI framework implementation reference covering architecture, code structure, all 5 AI functions, execution flow, progress tracking, cost tracking, prompt management, and model configuration. **Purpose:** Complete AI framework implementation reference covering architecture, code structure, all 8 AI functions, execution flow, progress tracking, cost tracking, prompt management, and model configuration.
--- ---
@@ -39,6 +39,9 @@ The IGNY8 AI framework provides a unified interface for all AI operations. All A
3. **Generate Content**: Generate blog post and article content 3. **Generate Content**: Generate blog post and article content
4. **Generate Image Prompts**: Extract image prompts from content 4. **Generate Image Prompts**: Extract image prompts from content
5. **Generate Images**: Generate images using OpenAI DALL-E or Runware 5. **Generate Images**: Generate images using OpenAI DALL-E or Runware
6. **Generate Site Structure**: Create site/page architecture from business brief
7. **Optimize Content**: Optimize content for SEO, readability, and engagement
8. **Generate Page Content**: Generate structured page content with JSON blocks for Site Builder
--- ---
@@ -87,6 +90,17 @@ The IGNY8 AI framework provides a unified interface for all AI operations. All A
- `get_function_instance` - Gets function instance by name - `get_function_instance` - Gets function instance by name
- `list_functions` - Lists all registered functions - `list_functions` - Lists all registered functions
**Registered Functions** (7 lazy-loaded):
1. `auto_cluster` - AutoClusterFunction
2. `generate_ideas` - GenerateIdeasFunction
3. `generate_content` - GenerateContentFunction
4. `generate_images` - GenerateImagesFunction
5. `generate_image_prompts` - GenerateImagePromptsFunction
6. `generate_site_structure` - GenerateSiteStructureFunction
7. `optimize_content` - OptimizeContentFunction
**Note**: `generate_page_content` exists as a function but may be called directly without registry registration.
#### AI Core Handler #### AI Core Handler
**File**: `backend/igny8_core/ai/ai_core.py` **File**: `backend/igny8_core/ai/ai_core.py`
**Class**: `AICore` **Class**: `AICore`
@@ -111,6 +125,9 @@ The IGNY8 AI framework provides a unified interface for all AI operations. All A
- `image_prompt_extraction` - For extract_image_prompts function - `image_prompt_extraction` - For extract_image_prompts function
- `image_prompt_template` - Template for formatting image prompts - `image_prompt_template` - Template for formatting image prompts
- `negative_prompt` - Negative prompt for Runware image generation - `negative_prompt` - Negative prompt for Runware image generation
- `site_structure_generation` - For generate_site_structure function
- `content_optimization` - For optimize_content function
- `page_content_generation` - For generate_page_content function
#### Model Settings #### Model Settings
**File**: `backend/igny8_core/ai/settings.py` **File**: `backend/igny8_core/ai/settings.py`
@@ -352,6 +369,118 @@ The IGNY8 AI framework provides a unified interface for all AI operations. All A
- PARSE: "Processing image response" - PARSE: "Processing image response"
- SAVE: "Saving generated image(s)" - SAVE: "Saving generated image(s)"
### 6. Generate Site Structure
**Purpose**: Create site/page architecture from business brief, objectives, and style guides
**Function Class**: `GenerateSiteStructureFunction`
**File**: `backend/igny8_core/ai/functions/generate_site_structure.py`
**API Endpoint**:
- **ViewSet**: `SiteBlueprintViewSet`
- **Action**: `generate_structure`
- **Method**: POST
- **URL Path**: `/v1/site-builder/blueprints/{id}/generate_structure/`
- **Payload**: `ids` (list[int]) - Site Blueprint IDs
**Function Methods**:
- `get_name()`: Returns `'generate_site_structure'`
- `validate(payload, account)`: Validates blueprint ID exists
- `prepare(payload, account)`: Loads site blueprint with related data
- `build_prompt(data, account)`: Builds site structure generation prompt with business brief, objectives, style guides
- `parse_response(response, step_tracker)`: Parses site structure JSON (pages, blocks, navigation)
- `save_output(parsed, original_data, account, progress_tracker, step_tracker)`: Creates PageBlueprint records with blocks
**Input**: Site Blueprint ID
**Output**: PageBlueprint records created with structured blocks
**Progress Messages**:
- INIT: "Validating blueprint data…"
- PREP: "Preparing site context…"
- AI_CALL: "Generating site structure with AI…"
- PARSE: "Parsing generated blueprint…"
- SAVE: "Saving pages and blocks…"
- DONE: "Site structure ready!"
### 7. Optimize Content
**Purpose**: Optimize content for SEO, readability, and engagement
**Function Class**: `OptimizeContentFunction`
**File**: `backend/igny8_core/ai/functions/optimize_content.py`
**API Endpoint**:
- **ViewSet**: `OptimizerViewSet`
- **Action**: `optimize` or `analyze`
- **Method**: POST
- **URL Path**: `/v1/optimizer/optimize/` or `/v1/optimizer/analyze/`
- **Payload**: `ids` (list[int]) - Content IDs, `entry_point` (optional, str)
**Function Methods**:
- `get_name()`: Returns `'optimize_content'`
- `validate(payload, account)`: Validates content IDs exist
- `prepare(payload, account)`: Loads content with related data
- `build_prompt(data, account)`: Builds optimization prompt with content, SEO targets, readability goals
- `parse_response(response, step_tracker)`: Parses optimized content JSON
- `save_output(parsed, original_data, account, progress_tracker, step_tracker)`: Updates Content records with optimized content and scores
**Input**: List of content IDs
**Output**: Content records updated with optimized content, SEO scores, readability scores
**Optimization Features**:
- SEO optimization (keyword density, meta descriptions, headings)
- Readability improvements (sentence length, paragraph structure)
- Engagement enhancements (call-to-actions, internal links)
- Content scoring (SEO score, readability score, engagement score)
**Progress Messages**:
- INIT: "Validating content data…"
- PREP: "Preparing content context…"
- AI_CALL: "Optimizing content with AI…"
- PARSE: "Parsing optimized content…"
- SAVE: "Saving optimized content…"
- DONE: "Content optimized!"
### 8. Generate Page Content
**Purpose**: Generate structured page content with JSON blocks for Site Builder pages
**Function Class**: `GeneratePageContentFunction`
**File**: `backend/igny8_core/ai/functions/generate_page_content.py`
**API Endpoint**:
- **ViewSet**: `PageBlueprintViewSet`
- **Action**: `generate_content` or `regenerate`
- **Method**: POST
- **URL Path**: `/v1/site-builder/pages/{id}/generate_content/` or `/v1/site-builder/pages/{id}/regenerate/`
- **Payload**: `ids` (list[int]) - Page Blueprint IDs (max 20)
**Function Methods**:
- `get_name()`: Returns `'generate_page_content'`
- `get_max_items()`: Returns `20` (max pages per batch)
- `validate(payload, account)`: Validates page blueprint IDs exist
- `prepare(payload, account)`: Loads page blueprints with related data
- `build_prompt(data, account)`: Builds page content generation prompt optimized for Site Builder
- `parse_response(response, step_tracker)`: Parses JSON blocks format
- `save_output(parsed, original_data, account, progress_tracker, step_tracker)`: Updates PageBlueprint records with blocks_json
**Input**: List of page blueprint IDs
**Output**: PageBlueprint records updated with structured blocks_json
**Key Differences from Generate Content**:
- Outputs structured JSON blocks format instead of HTML
- Optimized prompts for site builder pages
- Supports page-specific context (site structure, navigation, related pages)
- Blocks can include: headings, paragraphs, images, CTAs, forms, etc.
**Progress Messages**:
- INIT: "Initializing page content generation..."
- PREP: "Loading page blueprint and building prompt..."
- AI_CALL: "Generating structured content with AI..."
- PARSE: "Parsing JSON blocks..."
- SAVE: "Saving blocks to page..."
- DONE: "Page content generated!"
--- ---
## Progress Tracking ## Progress Tracking
@@ -539,6 +668,9 @@ The IGNY8 AI framework provides:
8. **Database Logging**: Automatic logging to AITaskLog 8. **Database Logging**: Automatic logging to AITaskLog
9. **Extensibility**: Easy to add new AI functions 9. **Extensibility**: Easy to add new AI functions
10. **Reliability**: Retry logic and error recovery 10. **Reliability**: Retry logic and error recovery
11. **8 AI Functions**: Complete coverage from planning to publishing
12. **Site Builder Integration**: Specialized functions for site structure and page content
13. **Content Optimization**: AI-powered content optimization and scoring
This architecture ensures consistency, maintainability, and extensibility while providing a robust foundation for all AI operations in the IGNY8 platform. This architecture ensures consistency, maintainability, and extensibility while providing a robust foundation for all AI operations in the IGNY8 platform, supporting 8 AI functions across the complete content workflow.

View File

@@ -1,6 +1,6 @@
# IGNY8 Functional Business Logic Documentation # IGNY8 Functional Business Logic Documentation
**Last Updated:** 2025-01-XX **Last Updated:** 2025-01-XX (Workflow updated - Wizard removed)
**Purpose:** Complete functional and business logic documentation covering all workflows, functions, features, and how the application works from a business perspective. **Purpose:** Complete functional and business logic documentation covering all workflows, functions, features, and how the application works from a business perspective.
--- ---
@@ -9,17 +9,18 @@
1. [Prerequisites](#prerequisites) 1. [Prerequisites](#prerequisites)
2. [System Overview](#system-overview) 2. [System Overview](#system-overview)
3. [Account and User Management](#account-and-user-management) 3. [Complete User Workflow](#complete-user-workflow)
4. [Planner Module - Complete Workflows](#planner-module---complete-workflows) 4. [Account and User Management](#account-and-user-management)
5. [Writer Module - Complete Workflows](#writer-module---complete-workflows) 5. [Planner Module - Complete Workflows](#planner-module---complete-workflows)
6. [Thinker Module - Complete Workflows](#thinker-module---complete-workflows) 6. [Writer Module - Complete Workflows](#writer-module---complete-workflows)
7. [System Module - Complete Workflows](#system-module---complete-workflows) 7. [Thinker Module - Complete Workflows](#thinker-module---complete-workflows)
8. [Billing Module - Complete Workflows](#billing-module---complete-workflows) 8. [System Module - Complete Workflows](#system-module---complete-workflows)
9. [AI Functions - Complete Details](#ai-functions---complete-details) 9. [Billing Module - Complete Workflows](#billing-module---complete-workflows)
10. [Credit System - How It Works](#credit-system---how-it-works) 10. [AI Functions - Complete Details](#ai-functions---complete-details)
11. [WordPress Integration](#wordpress-integration) 11. [Credit System - How It Works](#credit-system---how-it-works)
12. [Data Flow and State Management](#data-flow-and-state-management) 12. [WordPress Integration](#wordpress-integration)
13. [Complete Feature List](#complete-feature-list) 13. [Data Flow and State Management](#data-flow-and-state-management)
14. [Complete Feature List](#complete-feature-list)
--- ---
@@ -83,6 +84,156 @@ IGNY8 is a SaaS platform for SEO keyword management and AI-driven content genera
--- ---
## Complete User Workflow
### Current Workflow Path (Updated 2025-01-XX)
The Site Builder Wizard has been removed. The workflow now follows a direct path:
```
PLANNING → WRITER → OPTIMIZE → PUBLISH
```
**Direct Path:** Keywords/Clusters → Ideas → Tasks → Content (no wizard intermediary)
### Phase Flow Summary
```
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│ PLANNING │ --> │ WRITER │ --> │OPTIMIZE │ --> │ PUBLISH │
│ │ │ │ │ │ │ │
│Keywords │ │Content │ │Link & │ │Deploy │
│Clusters │ │Generate │ │Optimize │ │Site │
│ Ideas │ │ Images │ │ │ │ │
└──────────┘ └──────────┘ └──────────┘ └──────────┘
```
### Complete Workflow Steps
#### Phase 1: Planning & Keyword Research
1. **Keyword Discovery**
- Navigate to `/planner/keyword-opportunities`
- Browse keyword database
- Identify target keywords
2. **Keyword Import**
- Navigate to `/planner/keywords`
- Import CSV or manual entry
- Keywords stored by sector
3. **Keyword Clustering**
- Select keywords → "Auto-Cluster"
- AI clustering (1 credit per 30 keywords)
- Clusters created automatically
4. **Cluster Management**
- Navigate to `/planner/clusters`
- Review & refine clusters
- Merge/split clusters as needed
- Clusters ready for content generation
5. **Content Ideas Generation**
- Navigate to `/planner/ideas`
- Generate ideas from clusters (1 credit per idea)
- Review and refine ideas
- Queue ideas to Writer
#### Phase 2: Content Creation (Writer)
1. **Task Creation**
- Ideas automatically create tasks
- Navigate to `/writer/tasks`
- Review tasks from ideas
2. **Content Generation**
- Select tasks → "Generate Content"
- AI content generation (3 credits per content)
- HTML content with structured blocks
- Meta tags automatically generated
3. **Content Review**
- Navigate to `/writer/content`
- Review & edit HTML content
- Update metadata (title, description, keywords)
- Validate content structure
4. **Image Generation**
- Navigate to `/writer/images`
- Generate image prompts (optional)
- Generate images (1 credit per image)
- Featured and in-article images
#### Phase 3: Optimization & Linking
1. **Internal Linking**
- Navigate to `/linker/content`
- System analyzes content
- Suggests internal links (cluster matches prioritized)
- Accept/reject link suggestions
2. **Content Optimization**
- Navigate to `/optimizer/content`
- System scores content
- Review optimization suggestions
- Apply improvements
#### Phase 4: Publishing
1. **Content Validation**
- Navigate to `/sites/:id/posts/:postId`
- Validate entity type, cluster mapping, taxonomy
- Ensure all attributes complete
2. **WordPress Publishing**
- Select content → "Publish to WordPress"
- System validates WordPress connection
- Content published to WordPress site
- Images uploaded and linked
3. **Site Deployment** (for IGNY8-hosted sites)
- Navigate to `/sites/:id/deploy`
- Review cluster coverage
- Validate content completeness
- Deploy site to sites.igny8.com/{slug}
### Workflow Variations
#### Workflow A: New IGNY8-Hosted Site
- Complete build from scratch
- Full workflow: Planning → Writer → Optimize → Publish → Deploy
#### Workflow B: Existing Site Management
- Add new content to existing site
- Manage existing content
- Update and republish content
#### Workflow C: WordPress Sync - New Site
- Connect new WordPress site
- Sync existing content
- Continue with normal workflow
#### Workflow D: WordPress Sync - Existing Site
- Connect existing WordPress site
- Import existing posts
- Sync and manage content
### Site Builder Status
**Removed Features:**
- ❌ Site Builder Wizard (6-step guided process)
- ❌ WorkflowState model and services
- ❌ Wizard UI components and routes
**Available Features:**
- ✅ Site Blueprint APIs (create/manage via API)
- ✅ Site Builder models (SiteBlueprint, PageBlueprint, etc.)
- ✅ Direct workflow path (Planning → Writer)
**Note:** Site blueprints can still be created and managed through API endpoints, but there is no guided UI wizard. Users proceed directly from Planning to Writer.
---
## Account and User Management ## Account and User Management
### Account Creation and Setup ### Account Creation and Setup

View File

@@ -2,7 +2,7 @@
**Base URL**: `https://api.igny8.com/api/v1/` **Base URL**: `https://api.igny8.com/api/v1/`
**Version**: 1.0.0 **Version**: 1.0.0
**Last Updated**: 2025-01-XX **Last Updated**: 2025-01-XX (Added 6 missing modules: Linker, Optimizer, Publisher, Site Builder, Automation, Integration)
**Status**: ✅ **100% IMPLEMENTED** - All endpoints use unified format **Status**: ✅ **100% IMPLEMENTED** - All endpoints use unified format
**Purpose**: Complete, unified reference for IGNY8 API covering authentication, endpoints, response formats, error handling, rate limiting, permissions, and integration examples. **Purpose**: Complete, unified reference for IGNY8 API covering authentication, endpoints, response formats, error handling, rate limiting, permissions, and integration examples.
@@ -97,6 +97,12 @@ Development: http://localhost:8000/api/v1/
├── auth/ # Authentication and user management ├── auth/ # Authentication and user management
├── planner/ # Keywords, clusters, content ideas ├── planner/ # Keywords, clusters, content ideas
├── writer/ # Tasks, content, images ├── writer/ # Tasks, content, images
├── linker/ # Internal linking operations
├── optimizer/ # Content optimization and scoring
├── publisher/ # Publishing records and site deployment
├── site-builder/ # Site blueprint management
├── automation/ # Automation rules and scheduled tasks
├── integration/ # External platform integrations
├── system/ # Settings, prompts, integrations ├── system/ # Settings, prompts, integrations
└── billing/ # Credits, transactions, usage └── billing/ # Credits, transactions, usage
``` ```
@@ -219,6 +225,7 @@ Content-Type: application/json
- `GET /api/v1/auth/industries/` - List industries - `GET /api/v1/auth/industries/` - List industries
- `GET /api/v1/system/status/` - System health check - `GET /api/v1/system/status/` - System health check
- `GET /api/v1/system/ping/` - Health check endpoint - `GET /api/v1/system/ping/` - Health check endpoint
- `GET /api/v1/publisher/sites/{site_id}/definition/` - Get site definition for Sites Renderer
**All other endpoints require JWT authentication.** **All other endpoints require JWT authentication.**
@@ -988,6 +995,414 @@ class KeywordViewSet(SiteSectorModelViewSet):
- `GET /api/v1/system/ping/` - Health check endpoint (AllowAny) - `GET /api/v1/system/ping/` - Health check endpoint (AllowAny)
- `GET /api/v1/system/request-metrics/{request_id}/` - Get request metrics for debugging - `GET /api/v1/system/request-metrics/{request_id}/` - Get request metrics for debugging
### Linker Module Endpoints
**Base Path**: `/api/v1/linker/`
**Permission**: IsAuthenticatedAndActive + HasTenantAccess
#### Process Content for Internal Linking
- `POST /api/v1/linker/process/` - Process single content item for internal linking
**Request:**
```json
{
"content_id": 123
}
```
**Response:**
```json
{
"success": true,
"data": {
"content_id": 123,
"suggested_links": [
{
"target_content_id": 456,
"target_title": "Related Article",
"anchor_text": "relevant keyword",
"confidence": 0.85
}
]
}
}
```
#### Batch Process Content
- `POST /api/v1/linker/batch_process/` - Process multiple content items for linking
**Request:**
```json
{
"content_ids": [123, 456, 789]
}
```
### Optimizer Module Endpoints
**Base Path**: `/api/v1/optimizer/`
**Permission**: IsAuthenticatedAndActive + HasTenantAccess
#### Optimize Content
- `POST /api/v1/optimizer/optimize/` - Optimize content (auto-detects entry point)
**Request:**
```json
{
"ids": [123, 456],
"entry_point": "seo" // Optional: "seo", "readability", "engagement"
}
```
**Response:**
```json
{
"success": true,
"data": {
"optimized_content": "...",
"seo_score": 85,
"readability_score": 78,
"engagement_score": 82
}
}
```
#### Batch Optimize Content
- `POST /api/v1/optimizer/batch_optimize/` - Batch optimize multiple content items
**Request:**
```json
{
"ids": [123, 456, 789],
"entry_point": "seo" // Optional
}
```
#### Analyze Content
- `POST /api/v1/optimizer/analyze/` - Analyze content without optimization
**Request:**
```json
{
"id": 123
}
```
**Response:**
```json
{
"success": true,
"data": {
"seo_score": 75,
"readability_score": 70,
"engagement_score": 68,
"recommendations": [
"Add more internal links",
"Improve heading structure"
]
}
}
```
### Publisher Module Endpoints
**Base Path**: `/api/v1/publisher/`
**Permission**: IsAuthenticatedAndActive + HasTenantAccess
#### Publishing Records
**Base Path**: `/api/v1/publisher/publishing-records/`
**Inherits**: SiteSectorModelViewSet
**Standard CRUD:**
- `GET /api/v1/publisher/publishing-records/` - List publishing records (paginated)
- `POST /api/v1/publisher/publishing-records/` - Create publishing record
- `GET /api/v1/publisher/publishing-records/{id}/` - Get publishing record
- `PUT /api/v1/publisher/publishing-records/{id}/` - Update publishing record
- `DELETE /api/v1/publisher/publishing-records/{id}/` - Delete publishing record
**Filtering:**
- `status` - Filter by publishing status
- `destination_type` - Filter by destination (wordpress, sites_renderer, etc.)
- `site_id` - Filter by site
- `sector_id` - Filter by sector
#### Deployment Records
**Base Path**: `/api/v1/publisher/deployments/`
**Inherits**: SiteSectorModelViewSet
**Standard CRUD:**
- `GET /api/v1/publisher/deployments/` - List deployment records (paginated)
- `POST /api/v1/publisher/deployments/` - Create deployment record
- `GET /api/v1/publisher/deployments/{id}/` - Get deployment record
- `PUT /api/v1/publisher/deployments/{id}/` - Update deployment record
- `DELETE /api/v1/publisher/deployments/{id}/` - Delete deployment record
#### Publishing Actions
- `POST /api/v1/publisher/publish/` - Publish content to destination
**Request:**
```json
{
"content_id": 123,
"destination_type": "wordpress",
"destination_id": 1
}
```
- `POST /api/v1/publisher/deploy/` - Deploy site blueprint
**Request:**
```json
{
"blueprint_id": 456,
"environment": "production"
}
```
- `POST /api/v1/publisher/check_readiness/` - Check deployment readiness
**Request:**
```json
{
"blueprint_id": 456
}
```
#### Public Endpoint (No Authentication)
- `GET /api/v1/publisher/sites/{site_id}/definition/` - Get site definition for Sites Renderer
**Response:**
```json
{
"success": true,
"data": {
"site_id": 1,
"slug": "example-site",
"blueprints": [...],
"pages": [...]
}
}
```
### Site Builder Module Endpoints
**Base Path**: `/api/v1/site-builder/`
**Permission**: IsAuthenticatedAndActive + HasTenantAccess
#### Site Blueprints
**Base Path**: `/api/v1/site-builder/blueprints/`
**Inherits**: SiteSectorModelViewSet
**Standard CRUD:**
- `GET /api/v1/site-builder/blueprints/` - List site blueprints (paginated)
- `POST /api/v1/site-builder/blueprints/` - Create site blueprint
- `GET /api/v1/site-builder/blueprints/{id}/` - Get blueprint details
- `PUT /api/v1/site-builder/blueprints/{id}/` - Update blueprint
- `DELETE /api/v1/site-builder/blueprints/{id}/` - Delete blueprint
**Custom Actions:**
- `POST /api/v1/site-builder/blueprints/{id}/generate_structure/` - Generate site structure using AI
- `POST /api/v1/site-builder/blueprints/{id}/generate_all_pages/` - Generate all pages for blueprint
- `POST /api/v1/site-builder/blueprints/{id}/create_tasks/` - Create Writer tasks for pages
- `GET /api/v1/site-builder/blueprints/{id}/progress/` - Get cluster-level completion status
- `POST /api/v1/site-builder/blueprints/{id}/clusters/attach/` - Attach planner clusters
- `POST /api/v1/site-builder/blueprints/{id}/clusters/detach/` - Detach clusters
- `GET /api/v1/site-builder/blueprints/{id}/taxonomies/` - List taxonomies
- `POST /api/v1/site-builder/blueprints/{id}/taxonomies/` - Create taxonomy
- `POST /api/v1/site-builder/blueprints/{id}/taxonomies/import/` - Import taxonomies
- `POST /api/v1/site-builder/blueprints/bulk_delete/` - Bulk delete blueprints
**Filtering:**
- `status` - Filter by blueprint status
- `site_id` - Filter by site
- `sector_id` - Filter by sector
#### Page Blueprints
**Base Path**: `/api/v1/site-builder/pages/`
**Inherits**: SiteSectorModelViewSet
**Standard CRUD:**
- `GET /api/v1/site-builder/pages/` - List page blueprints (paginated)
- `POST /api/v1/site-builder/pages/` - Create page blueprint
- `GET /api/v1/site-builder/pages/{id}/` - Get page details
- `PUT /api/v1/site-builder/pages/{id}/` - Update page
- `DELETE /api/v1/site-builder/pages/{id}/` - Delete page
**Custom Actions:**
- `POST /api/v1/site-builder/pages/{id}/generate_content/` - Generate content for page
- `POST /api/v1/site-builder/pages/{id}/regenerate/` - Regenerate page content
**Filtering:**
- `site_blueprint_id` - Filter by site blueprint
- `status` - Filter by page status
#### Site Assets
- `GET /api/v1/site-builder/assets/` - List files for site
**Query Parameters:**
- `site_id` - Filter by site
- `file_type` - Filter by file type
- `POST /api/v1/site-builder/assets/` - Upload file
**Request:** Multipart form data
```json
{
"file": "<file>",
"site_id": 1,
"file_type": "image"
}
```
- `DELETE /api/v1/site-builder/assets/` - Delete file
**Request:**
```json
{
"file_path": "path/to/file.jpg",
"site_id": 1
}
```
#### Site Builder Metadata
- `GET /api/v1/site-builder/metadata/` - Get metadata (business types, audience profiles, etc.)
**Response:**
```json
{
"success": true,
"data": {
"business_types": [...],
"audience_profiles": [...],
"brand_personalities": [...],
"hero_imagery_directions": [...]
}
}
```
### Automation Module Endpoints
**Base Path**: `/api/v1/automation/`
**Permission**: IsAuthenticatedAndActive + HasTenantAccess
#### Automation Rules
**Base Path**: `/api/v1/automation/rules/`
**Inherits**: SiteSectorModelViewSet
**Standard CRUD:**
- `GET /api/v1/automation/rules/` - List automation rules (paginated)
- `POST /api/v1/automation/rules/` - Create automation rule
- `GET /api/v1/automation/rules/{id}/` - Get rule details
- `PUT /api/v1/automation/rules/{id}/` - Update rule
- `DELETE /api/v1/automation/rules/{id}/` - Delete rule
**Custom Actions:**
- `POST /api/v1/automation/rules/{id}/execute/` - Manually execute automation rule
**Filtering:**
- `status` - Filter by rule status (active, inactive)
- `trigger_type` - Filter by trigger type
- `site_id` - Filter by site
- `sector_id` - Filter by sector
#### Scheduled Tasks
**Base Path**: `/api/v1/automation/scheduled-tasks/`
**Inherits**: AccountModelViewSet
**Standard CRUD:**
- `GET /api/v1/automation/scheduled-tasks/` - List scheduled tasks (paginated)
- `POST /api/v1/automation/scheduled-tasks/` - Create scheduled task
- `GET /api/v1/automation/scheduled-tasks/{id}/` - Get task details
- `PUT /api/v1/automation/scheduled-tasks/{id}/` - Update task
- `DELETE /api/v1/automation/scheduled-tasks/{id}/` - Delete task
**Filtering:**
- `status` - Filter by task status
- `task_type` - Filter by task type
- `next_run_date` - Filter by next run date
### Integration Module Endpoints
**Base Path**: `/api/v1/integration/`
**Permission**: IsAuthenticatedAndActive + HasTenantAccess
#### Site Integrations
**Base Path**: `/api/v1/integration/integrations/`
**Inherits**: SiteSectorModelViewSet
**Standard CRUD:**
- `GET /api/v1/integration/integrations/` - List site integrations (paginated)
- `POST /api/v1/integration/integrations/` - Create integration
- `GET /api/v1/integration/integrations/{id}/` - Get integration details
- `PUT /api/v1/integration/integrations/{id}/` - Update integration
- `DELETE /api/v1/integration/integrations/{id}/` - Delete integration
**Custom Actions:**
- `POST /api/v1/integration/integrations/{id}/test_connection/` - Test connection to integrated platform
**Request:**
```json
{}
```
**Response:**
```json
{
"success": true,
"data": {
"connected": true,
"message": "Connection successful"
}
}
```
- `POST /api/v1/integration/integrations/{id}/sync/` - Sync content with integrated platform
**Request:**
```json
{
"content_ids": [123, 456],
"sync_type": "full" // or "incremental"
}
```
- `GET /api/v1/integration/integrations/{id}/sync_health/` - Get sync health status
**Response:**
```json
{
"success": true,
"data": {
"last_sync": "2025-01-XXT...",
"sync_status": "healthy",
"pending_items": 0,
"failed_items": 0
}
}
```
**Filtering:**
- `platform_type` - Filter by platform (wordpress, shopify, etc.)
- `status` - Filter by integration status
- `site_id` - Filter by site
- `sector_id` - Filter by sector
### Billing Module Endpoints ### Billing Module Endpoints
**Base Path**: `/api/v1/billing/` **Base Path**: `/api/v1/billing/`
@@ -1386,7 +1801,7 @@ All API changes are documented in `CHANGELOG.md` with:
--- ---
**Last Updated**: 2025-01-XX **Last Updated**: 2025-01-XX (Added 6 missing modules: Linker, Optimizer, Publisher, Site Builder, Automation, Integration)
**API Version**: 1.0.0 **API Version**: 1.0.0
**Status**: ✅ **100% IMPLEMENTED** **Status**: ✅ **100% IMPLEMENTED** - All 10 modules documented with complete endpoint reference

View File

@@ -1,7 +1,7 @@
# WordPress Plugin Integration Guide # WordPress Plugin Integration Guide
**Version**: 1.0.0 **Version**: 1.0.0
**Last Updated**: 2025-11-16 **Last Updated**: 2025-01-XX (Added Publisher module endpoints for content publishing)
Complete guide for integrating WordPress plugins with IGNY8 API v1.0. Complete guide for integrating WordPress plugins with IGNY8 API v1.0.
@@ -1092,11 +1092,21 @@ if (!wp_next_scheduled('igny8_sync_post_statuses')) {
## Complete Integration Flow ## Complete Integration Flow
### IGNY8 → WordPress Flow ### IGNY8 → WordPress Flow (Using Publisher Module)
1. Content generated in IGNY8
2. Content created/updated in IGNY8
3. Call `POST /api/v1/publisher/publish/` with `content_id` and `destinations: ['wordpress']`
4. Publisher module creates WordPress post via REST API
5. Publishing record created in IGNY8
6. WordPress post ID stored in publishing record
7. Content updated with WordPress post URL
### IGNY8 → WordPress Flow (Legacy/Direct)
1. Content generated in IGNY8 1. Content generated in IGNY8
2. Task created/updated in IGNY8 2. Task created/updated in IGNY8
3. WordPress post created via `wp_insert_post()` 3. WordPress post created via `wp_insert_post()` (if using WordPress plugin)
4. Post meta saved with `_igny8_task_id` 4. Post meta saved with `_igny8_task_id`
5. IGNY8 task updated with WordPress post ID 5. IGNY8 task updated with WordPress post ID
@@ -1572,8 +1582,9 @@ function igny8_send_site_data_to_igny8($site_id) {
$site_data = igny8_collect_site_data(); $site_data = igny8_collect_site_data();
// Send to IGNY8 API // Send to IGNY8 API
// Note: This endpoint may need to be created in IGNY8 API // Note: This endpoint is planned/future feature - may not be available yet
$response = $api->post("/system/sites/{$site_id}/import/", [ // Alternative: Use Integration module endpoints for site data sync
$response = $api->post("/integration/integrations/{$integration_id}/sync/", [
'site_data' => $site_data, 'site_data' => $site_data,
'import_type' => 'full_site_scan' 'import_type' => 'full_site_scan'
]); ]);
@@ -1632,7 +1643,8 @@ function igny8_sync_incremental_site_data($site_id) {
} }
// Send incremental update to IGNY8 // Send incremental update to IGNY8
$response = $api->post("/system/sites/{$site_id}/sync/", [ // Note: Use Integration module for site sync
$response = $api->post("/integration/integrations/{$integration_id}/sync/", [
'posts' => $formatted_posts, 'posts' => $formatted_posts,
'sync_type' => 'incremental', 'sync_type' => 'incremental',
'last_sync' => $last_sync 'last_sync' => $last_sync
@@ -1728,6 +1740,8 @@ function igny8_map_site_to_semantic_strategy($site_id, $site_data) {
} }
// Send semantic map to IGNY8 // Send semantic map to IGNY8
// Note: This endpoint is planned/future feature - may not be available yet
// Alternative: Use Planner module to create sectors/clusters/keywords manually
$response = $api->post("/planner/sites/{$site_id}/semantic-map/", [ $response = $api->post("/planner/sites/{$site_id}/semantic-map/", [
'semantic_map' => $semantic_map, 'semantic_map' => $semantic_map,
'site_data' => $site_data 'site_data' => $site_data
@@ -1811,6 +1825,7 @@ function igny8_analyze_and_restructure_site($site_id) {
$site_data = igny8_collect_site_data(); $site_data = igny8_collect_site_data();
// Step 2: Send to IGNY8 for analysis // Step 2: Send to IGNY8 for analysis
// Note: This endpoint is planned/future feature - may not be available yet
$analysis_response = $api->post("/system/sites/{$site_id}/analyze/", [ $analysis_response = $api->post("/system/sites/{$site_id}/analyze/", [
'site_data' => $site_data, 'site_data' => $site_data,
'analysis_type' => 'full_site_restructure' 'analysis_type' => 'full_site_restructure'
@@ -1830,6 +1845,7 @@ function igny8_analyze_and_restructure_site($site_id) {
} }
// Step 4: Get restructuring recommendations // Step 4: Get restructuring recommendations
// Note: This endpoint is planned/future feature - may not be available yet
$recommendations_response = $api->get("/system/sites/{$site_id}/recommendations/"); $recommendations_response = $api->get("/system/sites/{$site_id}/recommendations/");
if (!$recommendations_response['success']) { if (!$recommendations_response['success']) {
@@ -1908,7 +1924,8 @@ class Igny8SiteIntegration {
$site_data = igny8_collect_site_data(); $site_data = igny8_collect_site_data();
// Send to IGNY8 // Send to IGNY8
$response = $this->api->post("/system/sites/{$this->site_id}/import/", [ // Note: Use Integration module for site data import
$response = $this->api->post("/integration/integrations/{$integration_id}/sync/", [
'site_data' => $site_data, 'site_data' => $site_data,
'import_type' => 'full_scan' 'import_type' => 'full_scan'
]); ]);
@@ -1937,6 +1954,7 @@ class Igny8SiteIntegration {
* Get semantic strategy recommendations * Get semantic strategy recommendations
*/ */
public function get_recommendations() { public function get_recommendations() {
// Note: This endpoint is planned/future feature - may not be available yet
$response = $this->api->get("/planner/sites/{$this->site_id}/recommendations/"); $response = $this->api->get("/planner/sites/{$this->site_id}/recommendations/");
if ($response['success']) { if ($response['success']) {
@@ -1950,6 +1968,7 @@ class Igny8SiteIntegration {
* Apply restructuring recommendations * Apply restructuring recommendations
*/ */
public function apply_restructuring($recommendations) { public function apply_restructuring($recommendations) {
// Note: This endpoint is planned/future feature - may not be available yet
$response = $this->api->post("/planner/sites/{$this->site_id}/restructure/", [ $response = $this->api->post("/planner/sites/{$this->site_id}/restructure/", [
'recommendations' => $recommendations 'recommendations' => $recommendations
]); ]);

File diff suppressed because it is too large Load Diff

View File

@@ -1,413 +0,0 @@
# Final Refactor Tasks - Account/Plan Validation & Design Consistency
**Status:** All Phases Complete - Ready for QA/Testing
**Last Updated:** 2025-01-27
**Objective:** Enforce account/plan requirements at authentication level, fix design inconsistencies in Sites pages, and add welcome/guide screen for new user onboarding.
---
## 📋 Implementation Tasks
### 1. Remove Account Fallback - Fail Authentication
| Location | Current State | Required Changes | Priority |
|----------|---------------|------------------|----------|
| `backend/igny8_core/auth/views.py:912-953` | Login allows `account = None` (line 934) | Add validation: if `user.account is None`, return error: `"No account exists for this user. Please contact support."` with status 403 | **HIGH** |
| `backend/igny8_core/auth/urls.py:76-89` | Same issue in legacy LoginView | Same validation | **HIGH** |
| `frontend/src/store/authStore.ts:48-89` | No account validation after login | After login success, check `user.account` - if null, throw error and prevent login | **HIGH** |
| `frontend/src/components/auth/SignInForm.tsx:30` | No account validation | Display error message if account is missing | **HIGH** |
**Implementation Details:**
- After line 934 in `views.py`, add: `if not account: return error_response(error='No account exists for this user', status_code=403)`
- After line 74 in `authStore.ts`, add: `if (!user.account) { throw new Error('No account exists') }`
---
### 2. Remove Plan Fallback - Fail Authentication & Redirect
| Location | Current State | Required Changes | Priority |
|----------|---------------|------------------|----------|
| `backend/igny8_core/auth/views.py:912-953` | No plan validation | Add validation: if `user.account.plan is None`, return error: `"No plan subscribed. Please subscribe to a plan."` with status 403 and error code `NO_PLAN` | **HIGH** |
| `frontend/src/store/authStore.ts:48-89` | No plan validation | After login, check `user.account?.plan` - if null, logout and redirect to `https://igny8.com/pricing` | **HIGH** |
| `frontend/src/components/auth/SignInForm.tsx:30-36` | No plan validation | Catch `NO_PLAN` error and redirect to pricing page | **HIGH** |
**Implementation Details:**
- After account check in `views.py`, add: `if not account.plan: return error_response(error='No plan subscribed', error_code='NO_PLAN', status_code=403)`
- After account check in `authStore.ts`, add: `if (!user.account.plan) { logout(); window.location.href = 'https://igny8.com/pricing'; throw new Error('No plan subscribed') }`
---
### 3. Account Settings - Specific Error Handling
| Location | Current State | Required Changes | Priority |
|----------|---------------|------------------|----------|
| `frontend/src/services/api.ts:1479-1485` | No try-catch, throws generic error | Add try-catch with specific error types: `ACCOUNT_SETTINGS_API_ERROR`, `ACCOUNT_SETTINGS_NOT_FOUND`, `ACCOUNT_SETTINGS_VALIDATION_ERROR` | **MEDIUM** |
| Components using `fetchAccountSettings()` | Generic error handling | Display specific error messages based on error type | **MEDIUM** |
**Implementation Details:**
- Wrap `fetchAccountSettings()` in try-catch
- Return structured error with type
- Update components to display specific error messages
---
### 4. User/Account Access - Component Null Handling Review
| Location | Current State | Required Changes | Priority |
|----------|---------------|------------------|----------|
| All components using `user.account` | Uses optional chaining `user?.account?.slug` but no enforcement | Audit all components, add validation: if `user.account` is null during session, logout user immediately | **HIGH** |
| `frontend/src/components/common/SiteAndSectorSelector.tsx:50` | Uses `user?.account?.id` | Add validation check | **MEDIUM** |
| `frontend/src/layout/AppSidebar.tsx:45` | Uses `user?.account?.slug` | Add validation check | **MEDIUM** |
| `frontend/src/components/header/SiteSwitcher.tsx:93` | Uses `user?.account?.id` | Add validation check | **MEDIUM** |
| `frontend/src/store/authStore.ts:192-217` | `refreshUser()` doesn't validate account | After refresh, validate `user.account` - if null, logout | **HIGH** |
**Implementation Details:**
- Create utility function to validate user account/plan
- Add validation in `refreshUser()` method
- Add validation checks in components that access `user.account`
---
### 5. Site/Sector Null Handling Review
| Location | Current State | Required Changes | Priority |
|----------|---------------|------------------|----------|
| Components using `activeSite` | Can be `null`, some components may not handle | Audit all components, ensure null checks before accessing `activeSite` properties | **MEDIUM** |
| Components using `activeSector` | Can be `null`, some components may not handle | Audit all components, ensure null checks before accessing `activeSector` properties | **MEDIUM** |
| `frontend/src/pages/Planner/Dashboard.tsx:84-88` | Uses `activeSector?.id` and `activeSite?.id` | Already has optional chaining - verify all usages | **LOW** |
| `frontend/src/services/api.ts:453-466` | Uses `getActiveSiteId()` and `getActiveSectorId()` | Already has null checks - verify all usages | **LOW** |
**Implementation Details:**
- Audit all components using `activeSite` and `activeSector`
- Ensure all components handle null cases gracefully
- Add null checks where missing
---
### 6. Optimize Missing Fallbacks - Session Validation
| Location | Current State | Required Changes | Priority |
|----------|---------------|------------------|----------|
| `frontend/src/components/auth/ProtectedRoute.tsx:15-95` | Only checks `isAuthenticated` | Add validation: check `user.account` and `user.account.plan` - if null, logout and redirect | **HIGH** |
| `frontend/src/store/authStore.ts:192-217` | `refreshUser()` doesn't validate | After refresh, validate account/plan - if null, logout immediately | **HIGH** |
| `frontend/src/App.tsx` | No global validation | Add useEffect hook to validate account/plan on route changes | **HIGH** |
| `backend/igny8_core/auth/middleware.py:24-121` | Sets `request.account = None` on error | Should return 403 if account is required but missing | **MEDIUM** |
| `backend/igny8_core/api/authentication.py:21-73` | Sets `account = None` if not found | Should fail authentication if account is required | **MEDIUM** |
**Implementation Details:**
- Add validation function to check account/plan
- Add validation in `ProtectedRoute` before returning children
- Add global validation in `App.tsx` useEffect
- Update middleware to fail on missing account
---
### 7. Design Consistency - Sites Pages
**Issue:** Sites pages use completely different layouts, components, and colors compared to the standard app design used in Planner, Writer, Thinker, and Automation dashboards.
| Location | Current State | Required Changes | Priority |
|----------|---------------|------------------|----------|
| `frontend/src/pages/Sites/Dashboard.tsx` | Custom header, raw `Card` components | Replace with `PageHeader` and `ComponentCard` | **HIGH** |
| `frontend/src/pages/Sites/List.tsx` | Custom styling, different layout | Use standard components and spacing patterns | **HIGH** |
| `frontend/src/pages/Sites/Builder/*` | Different components and colors | Use standard design system components | **HIGH** |
| `frontend/src/pages/Sites/Settings.tsx` | Custom layout | Use standard components | **MEDIUM** |
| `frontend/src/pages/Sites/Content.tsx` | Custom styling | Use standard components | **MEDIUM** |
| `frontend/src/pages/Sites/PageManager.tsx` | Custom layout | Use standard components | **MEDIUM** |
| `frontend/src/pages/Sites/SyncDashboard.tsx` | Custom styling | Use standard components | **MEDIUM** |
| `frontend/src/pages/Sites/DeploymentPanel.tsx` | Custom styling | Use standard components | **MEDIUM** |
**Design Consistency Details:**
| Issue | Reference (Planner/Writer) | Sites Pages (Broken) | Fix Required |
|-------|---------------------------|----------------------|-------------|
| **Page Headers** | Uses `PageHeader` component with `title`, `lastUpdated`, `showRefresh` | Custom `<h1>` and manual layout | Replace with `PageHeader` |
| **Info Cards** | Uses `ComponentCard` with `title` and `desc` props | Raw `Card` with custom styling | Replace with `ComponentCard` |
| **Metric Cards** | Uses `EnhancedMetricCard` with consistent styling | Custom stat cards with different styling | Replace with `EnhancedMetricCard` |
| **Spacing** | Uses `space-y-6` for consistent vertical spacing | Mixed spacing (`mb-6`, `mb-4`, etc.) | Standardize to `space-y-6` |
| **Colors** | Uses CSS variables (`var(--color-primary)`) | Hardcoded colors (`text-gray-900`, `bg-blue-500`) | Replace with CSS variables |
| **Loading States** | Consistent loading spinner pattern | Different loading patterns | Standardize loading states |
| **Button Styles** | Standard `Button` component with variants | Mixed button styles | Use standard `Button` component |
| **Layout Patterns** | Consistent grid layouts (`grid-cols-1 md:grid-cols-2 lg:grid-cols-4`) | Inconsistent grid patterns | Standardize grid layouts |
**Implementation Details:**
- Replace all custom headers with `PageHeader` component
- Replace raw `Card` components with `ComponentCard` where appropriate
- Replace custom metric cards with `EnhancedMetricCard`
- Standardize spacing to `space-y-6` pattern
- Replace hardcoded colors with CSS variables
- Standardize loading states
- Use standard `Button` component consistently
- Standardize grid layout patterns
---
### 8. Welcome/Guide Screen - Workflow Explainer for New Users
**Issue:** The Dashboard home page (`frontend/src/pages/Dashboard/Home.tsx`) lacks onboarding guidance for new users. After signup, users see generic metrics without understanding the complete workflow or next steps.
| Location | Current State | Required Changes | Priority |
|----------|---------------|------------------|----------|
| `frontend/src/pages/Dashboard/Home.tsx` | ✅ Inline `WorkflowGuide` rendered above dashboard content | Keep guide responsive, continue iterating on progress tracking & backend dismissal | **HIGH** |
| `frontend/src/components/onboarding/WorkflowGuide.tsx` | ✅ Component created with Build vs Integrate flows and CTA grid | Add advanced progress logic + backend persistence once API is ready | **HIGH** |
| `frontend/src/components/header/AppHeader.tsx` | ✅ Orange "Show/Hide Guide" button added next to metrics | Ensure button state syncs with backend dismissal when implemented | **HIGH** |
| `frontend/src/store/onboardingStore.ts` | ✅ Store created with dismiss + toggle actions (persisted) | Wire to backend `guide_dismissed` field once available | **MEDIUM** |
| Backend - User model/settings | No field for guide dismissal | Add `guide_dismissed` or `show_workflow_guide` field | **MEDIUM** |
**Workflow Guide Features:**
| Feature | Description | Implementation Details |
|---------|-------------|----------------------|
| **Inline Page Display** | Shows directly in Home page content area (not modal/overlay) | Appears at top of page, pushes dashboard content below |
| **Dismissible** | User can hide it with "Don't show this again" checkbox | Store preference in `localStorage` + backend |
| **Re-open Button** | Orange-colored button in top right header | Text: "Show Guide" or "Workflow Guide" - stands out with orange color scheme |
| **Progress Tracking** | Show completed steps (✓) vs pending (○) | Track via `WorkflowState`, sites, clusters, content, published posts |
| **Contextual CTAs** | "Start Building Site", "Explore Planner", etc. based on progress | Conditional rendering based on user state |
**Workflow Flow Structure:**
| Main Choice | Sub-Option 1 | Sub-Option 2 | Description |
|-------------|--------------|-------------|-------------|
| **Build New Site** | WordPress Self-Hosted Site | IGNY8-Powered IGNY8-Hosted Site | User wants to create a new site from scratch |
| **Integrate Existing Site** | Integrate WordPress/Shopify | Custom Site | User wants to connect an existing site |
**Button Specifications:**
| Property | Value | Notes |
|----------|-------|-------|
| **Location** | Top right corner of header | Next to user profile/notifications |
| **Color** | Orange color scheme | Distinct from primary/secondary colors |
| **Text** | "Show Guide" or "Workflow Guide" | Clear, action-oriented label |
| **Behavior** | Toggles guide visibility | Shows/hides inline guide component |
| **Icon** | Book/Guide icon (optional) | Visual indicator |
**Implementation Details:**
- Create `<WorkflowGuide>` component with inline display (not modal)
- Include complete workflow visualization from `COMPLETE_USER_WORKFLOW_GUIDE.md`
- Track user progress: check if user has sites, clusters, content, published posts
- Show progress percentage (0% → 100%) based on completion
- Add "Don't show again" checkbox at bottom
- Store dismissal preference in `useOnboardingStore` and backend
- Add orange "Show Guide" button in `AppHeader` or header component
- Guide appears at top of Home page, dashboard content appears below it
- Use standard `Card`, `Button`, `Badge` components for consistency
- Make responsive for mobile/tablet views
---
### 9. Sidebar Restructuring - Simplified Navigation with In-Page Tabs
**Issue:** Current sidebar has too many dropdown menus, making navigation cluttered. Dashboard pages are redundant when metrics can be shown on table pages. Need clearer organization: Setup → Workflow → Settings.
| Location | Current State | Required Changes | Priority |
|----------|---------------|------------------|----------|
| `frontend/src/layout/AppSidebar.tsx` | Multiple dropdown menus, dashboard sub-items | Restructure to single items with in-page navigation | **HIGH** |
| `frontend/src/pages/Planner/*` | Separate dashboard page | Remove dashboard, add in-page navigation tabs | **HIGH** |
| `frontend/src/pages/Writer/*` | Separate dashboard page | Remove dashboard, add in-page navigation tabs | **HIGH** |
| `frontend/src/pages/Linker/*` | Separate dashboard page | Remove dashboard, add in-page navigation tabs | **HIGH** |
| `frontend/src/pages/Optimizer/*` | Separate dashboard page | Remove dashboard, add in-page navigation tabs | **HIGH** |
| `frontend/src/pages/Thinker/*` | Separate dashboard page | Remove dashboard, add in-page navigation tabs | **HIGH** |
| `frontend/src/pages/Automation/*` | Separate dashboard page | Remove dashboard, add in-page navigation tabs | **HIGH** |
| `frontend/src/pages/Setup/IndustriesSectorsKeywords.tsx` | Does not exist | Create merged page for Industry/Sectors/Keywords | **HIGH** |
| `frontend/src/components/navigation/ModuleNavigationTabs.tsx` | Does not exist | Create reusable tab navigation component | **HIGH** |
| `frontend/src/components/dashboard/ModuleMetricsFooter.tsx` | Does not exist | Create compact metrics footer for table pages | **MEDIUM** |
**New Sidebar Structure:**
| Section | Menu Items | Type | Default Route | Notes |
|---------|------------|------|---------------|-------|
| **(No Section)** | Dashboard | Single | `/` | Standalone, no section header |
| **SETUP** | Industry/Sectors/Keywords | Single | `/setup/industries-sectors-keywords` | Merged page: Industry/Sectors + Keyword Opportunities, saved to user account |
| | Sites | Single | `/sites` | Submenus shown as in-page navigation |
| | Automation | Single | `/automation/rules` | Submenus shown as in-page navigation |
| | Thinker | Single | `/thinker/prompts` | Submenus shown as in-page navigation |
| **WORKFLOW** | Planner | Single | `/planner/keywords` | Submenus shown as in-page navigation |
| | Writer | Single | `/writer/content` | Submenus shown as in-page navigation |
| | Linker | Single | `/linker/content` | Submenus shown as in-page navigation |
| | Optimizer | Single | `/optimizer/content` | Submenus shown as in-page navigation |
| **SETTINGS** | Settings | Dropdown | `/settings` | Keep dropdown (General, Plans, Integration, Publishing, Import/Export) |
| | Billing | Dropdown | `/billing/credits` | Keep dropdown (Credits, Transactions, Usage) |
| | Help & Documentation | Single | `/help` | No dropdown |
**In-Page Navigation Details:**
| Module | In-Page Navigation Tabs | Tab Routes |
|--------|-------------------------|------------|
| **Industry/Sectors/Keywords** | Industry/Sectors \| Keyword Opportunities | Single page with tabs/sections |
| **Sites** | All Sites \| Create Site \| Blueprints \| Sync Dashboard \| Deployment Panel | `/sites`, `/sites/builder`, `/sites/blueprints`, `/sites/sync`, `/sites/deploy` |
| **Automation** | Rules \| Tasks | `/automation/rules`, `/automation/tasks` |
| **Thinker** | Prompts \| Author Profiles \| Strategies \| Image Testing | `/thinker/prompts`, `/thinker/author-profiles`, `/thinker/strategies`, `/thinker/image-testing` |
| **Planner** | Keywords \| Clusters \| Ideas | `/planner/keywords`, `/planner/clusters`, `/planner/ideas` |
| **Writer** | Tasks \| Content \| Images \| Published | `/writer/tasks`, `/writer/content`, `/writer/images`, `/writer/published` |
| **Linker** | Content | `/linker/content` (single item, no tabs needed) |
| **Optimizer** | Content | `/optimizer/content` (single item, no tabs needed) |
**Industry/Sectors/Keywords Integration:**
| Feature | Description | Implementation |
|---------|-------------|----------------|
| **Purpose** | Pre-setup page before creating sites | User selects industry, sectors, and keywords before site creation |
| **Data Storage** | Saved to user account (not site-specific) | Available when creating sites |
| **Layout** | Tabbed interface or sections | Industry/Sectors tab + Keyword Opportunities tab |
| **Site Builder Integration** | Load pre-selected data | Site builder loads industries/sectors from user account |
| **Site Settings** | Show only pre-selected options | Site settings show only industries/sectors user intended to use |
**Implementation Details:**
- Remove all "Dashboard" sub-items from sidebar
- Convert dropdown menus to single items with in-page tab navigation
- Create `ModuleNavigationTabs` component for reusable tab navigation
- Create `ModuleMetricsFooter` component for compact metrics on table pages
- Create merged `IndustriesSectorsKeywords` page combining Industry/Sectors and Keyword Opportunities
- Update Site Builder to load industries/sectors from user account (not site-specific)
- Update Site Settings to show only pre-selected industries/sectors
- Add metrics footer to all Planner, Writer, Linker, Optimizer table pages
- Remove separate dashboard routes for Planner, Writer, Linker, Optimizer, Thinker, Automation
- Update routing to remove dashboard paths from sidebar navigation
---
## 📊 Priority Summary
| Priority | Count | Tasks |
|----------|-------|-------|
| **HIGH** | 27 | Backend account/plan validation, Frontend login validation, Session validation, Design consistency for Sites pages, Welcome/Guide screen component, Guide button, Sidebar restructuring, In-page navigation, Dashboard removal, Industry/Sectors/Keywords merge |
| **MEDIUM** | 13 | Account settings errors, Component null checks, Design consistency for remaining Sites pages, Guide persistence/store, Module metrics footer |
| **LOW** | 2 | Site/Sector null handling (mostly handled) |
**Total Tasks:** 42
---
## 🔄 Implementation Phases
### Phase 1: Backend Authentication (HIGH Priority) ✅ COMPLETE
**Completed:**
1. ✅ Add account validation to login endpoints - Blocks login if account is missing
2. ✅ Add plan validation to login endpoints - Blocks login if plan is missing, returns NO_PLAN error
3. ✅ Update middleware to fail on missing account - Middleware validates account/plan on every request
### Phase 2: Frontend Authentication (HIGH Priority) ✅ COMPLETE
**Completed:**
1. ✅ Validate account after login - `authStore.login()` checks for account existence
2. ✅ Validate plan after login - Redirects to pricing page if plan is missing
3. ✅ Handle NO_PLAN error with redirect - SignInForm redirects to `igny8.com/pricing`
4. ✅ Add validation to ProtectedRoute - Validates account/plan before allowing access
5. ✅ Add global session validation in App.tsx - `refreshUser()` validates account/plan on every auth check
### Phase 3: Component Null Handling (HIGH Priority) ✅ COMPLETE
**Completed:**
1. ✅ Audit all components using `user.account` - Updated SiteAndSectorSelector, SiteSwitcher, AppSidebar
2. ✅ Add validation to `refreshUser()` - Enforces account/plan checks, logs out if missing
3. ✅ Add validation checks in components - Components show CTAs when sites/sectors are null
### Phase 4: Design Consistency - Core Sites Pages (HIGH Priority) ✅ COMPLETE
**Design System Requirements:**
- **Colors**: Use CSS variables `var(--color-primary)`, `var(--color-success)`, `var(--color-warning)`, `var(--color-purple)` and their `-dark` variants
- **Gradients**: Use `from-[var(--color-primary)] to-[var(--color-primary-dark)]` pattern for icon backgrounds (matching Planner/Writer dashboards)
- **Icons**: Import from `../../icons` (not lucide-react), use same icon patterns as Planner/Writer/Thinker/Automation/Dashboard
- **Components**: Use standard `Button`, `Card`, `Badge`, `PageHeader`, `EnhancedMetricCard` from design system
- **Layout**: Use same spacing (`p-6`, `gap-4`, `rounded-xl`), border-radius, shadow patterns as Dashboard/Planner/Writer pages
- **Buttons**: Use standard Button component with `variant="primary"`, `variant="outline"` etc.
- **Cards**: Use standard Card component or EnhancedMetricCard for metrics (matching Dashboard/Planner patterns)
- **Badges**: Use standard Badge component with color variants matching design system
- **Stat Cards**: Use gradient icon backgrounds like Planner Dashboard: `bg-gradient-to-br from-[var(--color-primary)] to-[var(--color-primary-dark)]`
- **Hover States**: Use `hover:border-[var(--color-primary)]` pattern for interactive cards
**Completed:**
1. ✅ Refactor Sites Dashboard - Replaced lucide-react icons, using EnhancedMetricCard, standard colors/gradients, PageHeader component (matches Planner dashboard patterns)
2. ✅ Refactor Sites List - Converted to `TablePageTemplate`, added table/grid toggle, mirrored Planner/Writer table styling, moved actions into standard header buttons, removed legacy site/sector selectors
**Remaining:**
3. Refactor Sites Builder pages - Apply same design system patterns
### Phase 5: Design Consistency - Remaining Sites Pages (MEDIUM Priority) ✅ COMPLETE
**Completed:**
1. ✅ Refactor Sites Settings - Replaced lucide-react icons, added PageHeader, standardized button/card styling
2. ✅ Refactor Sites Content - Applied standard design system components
3. ✅ Refactor Sites PageManager - Updated icons, added PageHeader, standardized selection checkboxes
4. ✅ Refactor Sites SyncDashboard - Replaced icons, added PageHeader, standardized card/badge styling
5. ✅ Refactor Sites DeploymentPanel - Replaced icons, added PageHeader, standardized button/card styling
### Phase 6: Account Settings & Site/Sector Handling (MEDIUM/LOW Priority) ✅ COMPLETE
**Completed:**
1. ✅ Add specific error handling for account settings - Created `AccountSettingsError` class with structured error types
2. ✅ Audit and fix site/sector null handling - Updated `SiteAndSectorSelector` and `SiteSwitcher` to show CTAs when no sites available
### Phase 7: Welcome/Guide Screen & Onboarding (HIGH Priority) ✅ COMPLETE
**Completed:**
1. ✅ Create WorkflowGuide component (inline, not modal)
2. ✅ Create onboarding store for state management
3. ✅ Add orange "Show Guide" button in header
4. ✅ Implement flow structure (Build New Site vs Integrate Existing Site)
5. ✅ Integrate guide at top of Home page (pushes dashboard below)
6. ✅ Initial responsive pass on desktop/tablet/mobile
7. ✅ Add backend dismissal field + persist state - Added `is_guide_dismissed` to UserSettings model
8. ✅ Expand progress tracking logic - Tracks keywords, clusters, ideas, content, published content with completion percentage
9. ✅ Backend persistence - Guide dismissal state synced to backend via UserSettings API
**Remaining:**
- Cross-device QA once backend wiring is complete (QA/testing task)
### Phase 8: Sidebar Restructuring & Navigation (HIGH Priority) ✅ COMPLETE
**Completed:**
1. ✅ Restructure sidebar: Dashboard (standalone) → SETUP → WORKFLOW → SETTINGS
2. ✅ Remove all dashboard sub-items from sidebar
3. ✅ Convert dropdown menus to single items (Planner, Writer, Linker, Optimizer, Thinker, Automation, Sites)
4. ✅ Create ModuleNavigationTabs component for in-page tab navigation
5. ✅ Create merged IndustriesSectorsKeywords page (Industry/Sectors + Keyword Opportunities)
6. ✅ Update Site Builder to load industries/sectors from user account
7. ✅ Update Sites List to filter by user's pre-selected industries/sectors
8. ✅ Add in-page navigation tabs to all module pages
9. ✅ Remove separate dashboard routes for Planner, Writer, Linker, Optimizer, Thinker, Automation
10. ✅ Create ModuleMetricsFooter component for compact metrics on table pages
11. ✅ Add metrics footer to all table pages (Planner, Writer, Linker, Optimizer)
**Remaining:**
12. Test navigation flow and responsive design (QA/testing task)
---
## ✅ Success Criteria
1. **Authentication:** Users without account or plan cannot sign in
2. **Session Validation:** Users with missing account/plan are logged out automatically
3. **Design Consistency:** All Sites pages match the standard app design
4. **Error Handling:** Specific, actionable error messages for all failure cases
5. **Null Safety:** All components handle null cases gracefully
6. **Onboarding:** New users see an inline workflow guide on first login with clear flow options (Build New Site vs Integrate Existing Site) and progress tracking
7. **Guide Access:** Users can dismiss the guide and re-open it via an orange "Show Guide" button in the header
8. **Sidebar Navigation:** Sidebar simplified to 12 items with clear Setup → Workflow → Settings organization
9. **In-Page Navigation:** All modules use in-page tab navigation instead of sidebar dropdowns
10. **Pre-Setup Data:** Industry/Sectors/Keywords saved to user account and available during site creation
11. **Dashboard Removal:** All module dashboards removed, metrics shown as compact footer on table pages
---
## 📊 Overall Completion Status
| Phase | Status | Completion |
|-------|--------|------------|
| Phase 1: Backend Authentication | ✅ Complete | 100% |
| Phase 2: Frontend Authentication | ✅ Complete | 100% |
| Phase 3: Component Null Handling | ✅ Complete | 100% |
| Phase 4: Design Consistency - Core Sites Pages | ✅ Complete | 100% |
| Phase 5: Design Consistency - Remaining Sites Pages | ✅ Complete | 100% |
| Phase 6: Account Settings & Site/Sector Handling | ✅ Complete | 100% |
| Phase 7: Welcome/Guide Screen & Onboarding | ✅ Complete | 100% |
| Phase 8: Sidebar Restructuring & Navigation | ✅ Complete | 100% |
**Total Implementation:** 8/8 Phases Complete (100%)
**Remaining:** QA/Testing tasks only
---
*This plan ensures strict account/plan validation and design consistency across the entire application.*

View File

@@ -1,354 +0,0 @@
# Stage 4 Implementation Plan - Publishing & Sync Integration
**Status:** Planning Phase
**Last Updated:** 2025-01-27
**Objective:** Achieve feature parity between IGNY8-hosted deployments and WordPress sites using the shared metadata model from Stages 1-3.
---
## 📋 Codebase Audit Summary
### ✅ Existing Infrastructure (No Changes Needed)
#### Backend Models
-`SiteIntegration` model exists with WordPress support
- Location: `backend/igny8_core/business/integration/models.py`
- Fields: `platform`, `credentials_json`, `sync_enabled`, `last_sync_at`, `sync_status`, `sync_error`
- Supports: WordPress, Shopify, Custom API
-`SiteBlueprintTaxonomy` model (from Stage 1)
- Location: `backend/igny8_core/business/site_building/models.py`
- Has `external_reference` field for WordPress taxonomy IDs
-`ContentClusterMap`, `ContentTaxonomyMap`, `ContentAttributeMap` (from Stage 1)
- Location: `backend/igny8_core/business/content/models.py`
- Support metadata mapping for sync
#### Backend Services
-`WordPressAdapter` - Basic publishing to WordPress
- Location: `backend/igny8_core/business/publishing/services/adapters/wordpress_adapter.py`
- Methods: `publish()`, `test_connection()`, `get_status()`
- **Status:** Works for posts, needs taxonomy/product support
-`ContentSyncService` - Sync service skeleton
- Location: `backend/igny8_core/business/integration/services/content_sync_service.py`
- Methods: `sync_to_external()`, `sync_from_external()`
- **Status:** WordPress sync methods exist but are incomplete (TODOs)
-`TaxonomyService` - Taxonomy CRUD (from Stage 1)
- Location: `backend/igny8_core/business/site_building/services/taxonomy_service.py`
- Method: `import_from_external()` - Ready for WordPress import
-`SitesRendererAdapter` - IGNY8 deployment
- Location: `backend/igny8_core/business/publishing/services/adapters/sites_renderer_adapter.py`
- **Status:** Works, needs Stage 3 metadata integration
-`WordPressClient` - WordPress REST API client
- Location: `backend/igny8_core/utils/wordpress.py`
- Methods: `test_connection()`, `create_post()`
- **Status:** Basic functionality, needs taxonomy/product endpoints
#### Backend APIs
- ✅ Integration endpoints exist
- Location: `backend/igny8_core/modules/integration/views.py`
- Endpoints: `/api/v1/integration/integrations/{id}/sync/`, `/api/v1/integration/integrations/{id}/sync_status/`
- **Status:** Basic sync endpoints exist, need Stage 4 enhancements
---
## 🎯 Implementation Tasks
### Phase 1: Backend - WordPress Taxonomy & Product Sync
#### Task 1.1: Enhance WordPressClient
**File:** `backend/igny8_core/utils/wordpress.py`
**Add Methods:**
```python
def get_categories(self) -> List[Dict[str, Any]]
def create_category(self, name: str, slug: str, parent_id: Optional[int] = None) -> Dict[str, Any]
def get_tags(self) -> List[Dict[str, Any]]
def create_tag(self, name: str, slug: str) -> Dict[str, Any]
def get_products(self) -> List[Dict[str, Any]] # WooCommerce
def create_product(self, product_data: Dict[str, Any]) -> Dict[str, Any]
def get_product_attributes(self) -> List[Dict[str, Any]] # WooCommerce
```
**Breaking Changes:** None - All new methods
#### Task 1.2: Enhance ContentSyncService for Taxonomies
**File:** `backend/igny8_core/business/integration/services/content_sync_service.py`
**Enhance `_sync_from_wordpress()`:**
- Fetch WordPress categories/tags via WordPressClient
- Map to IGNY8 `SiteBlueprintTaxonomy` using `TaxonomyService.import_from_external()`
- Store `external_reference` (WP taxonomy ID) in `SiteBlueprintTaxonomy.external_reference`
- Auto-create missing clusters with `imported=True` flag
**Enhance `_sync_to_wordpress()`:**
- Ensure taxonomies exist in WordPress before publishing content
- Create missing categories/tags via WordPressClient
- Update `external_reference` after creation
- Push product attributes/tags before product content
**Breaking Changes:** None - Enhances existing methods
#### Task 1.3: Add Sync Health Service
**New File:** `backend/igny8_core/business/integration/services/sync_health_service.py`
**Purpose:** Track sync health, mismatches, errors
**Methods:**
```python
class SyncHealthService:
def get_sync_status(site_id: int, integration_id: Optional[int] = None) -> Dict[str, Any]
def get_mismatches(site_id: int) -> Dict[str, Any]
def get_sync_logs(site_id: int, limit: int = 100) -> List[Dict[str, Any]]
def record_sync_run(integration_id: int, result: Dict[str, Any]) -> None
```
**Breaking Changes:** None - New service
---
### Phase 2: Backend - Deployment Readiness
#### Task 2.1: Create Deployment Readiness Service
**New File:** `backend/igny8_core/business/publishing/services/deployment_readiness_service.py`
**Purpose:** Check if site is ready for deployment
**Methods:**
```python
class DeploymentReadinessService:
def check_readiness(site_blueprint_id: int) -> Dict[str, Any]
# Returns:
# {
# 'ready': bool,
# 'checks': {
# 'cluster_coverage': bool,
# 'content_validation': bool,
# 'sync_status': bool,
# 'taxonomy_completeness': bool
# },
# 'errors': List[str],
# 'warnings': List[str]
# }
```
**Breaking Changes:** None - New service
#### Task 2.2: Enhance SitesRendererAdapter with Stage 3 Metadata
**File:** `backend/igny8_core/business/publishing/services/adapters/sites_renderer_adapter.py`
**Enhance `_build_site_definition()`:**
- Include cluster metadata in navigation
- Include taxonomy metadata for breadcrumbs
- Include internal links from `ContentClusterMap`
**Breaking Changes:** None - Adds optional metadata fields
---
### Phase 3: Backend - API Endpoints
#### Task 3.1: Add Sync Health Endpoints
**File:** `backend/igny8_core/modules/integration/views.py`
**Add to IntegrationViewSet:**
```python
@action(detail=False, methods=['get'], url_path='sites/(?P<site_id>[^/.]+)/sync/status')
def sync_status_by_site(self, request, site_id=None):
"""GET /api/v1/integration/integrations/sites/{site_id}/sync/status/"""
@action(detail=False, methods=['post'], url_path='sites/(?P<site_id>[^/.]+)/sync/run')
def run_sync(self, request, site_id=None):
"""POST /api/v1/integration/integrations/sites/{site_id}/sync/run/"""
```
**Breaking Changes:** None - New endpoints
#### Task 3.2: Add Deployment Readiness Endpoint
**File:** `backend/igny8_core/modules/publisher/views.py` (or create new)
**New Endpoint:**
```python
@api_view(['GET'])
def deployment_readiness(request, blueprint_id):
"""GET /api/v1/publisher/blueprints/{blueprint_id}/readiness/"""
```
**Breaking Changes:** None - New endpoint
---
### Phase 4: Frontend - Sync Dashboard
#### Task 4.1: Create Sync Dashboard Component
**New File:** `frontend/src/pages/Sites/SyncDashboard.tsx`
**Features:**
- Parity indicators (taxonomies, products, posts)
- Manual sync button
- Retry failed items
- View logs with pagination
- Detail drawer for mismatches
**API Integration:**
- `GET /api/v1/integration/integrations/sites/{site_id}/sync/status/`
- `POST /api/v1/integration/integrations/sites/{site_id}/sync/run/`
**Breaking Changes:** None - New page
#### Task 4.2: Add Sync Status to Site Dashboard
**File:** `frontend/src/pages/Sites/Dashboard.tsx`
**Enhancement:**
- Add sync status widget
- Show last sync time
- Show sync errors if any
**Breaking Changes:** None - Adds optional widget
---
### Phase 5: Frontend - Deployment Panel
#### Task 5.1: Create Deployment Panel Component
**New File:** `frontend/src/components/sites/DeploymentPanel.tsx`
**Features:**
- Readiness checklist
- Deploy button (disabled if not ready)
- Rollback button
- Confirmation modals
- Toast notifications
**API Integration:**
- `GET /api/v1/publisher/blueprints/{blueprint_id}/readiness/`
- `POST /api/v1/publisher/deploy/{blueprint_id}/` (existing)
- `POST /api/v1/publisher/rollback/{deployment_id}/` (new)
**Breaking Changes:** None - New component
#### Task 5.2: Integrate Deployment Panel
**File:** `frontend/src/pages/Sites/Dashboard.tsx`
**Enhancement:**
- Add deployment panel section
- Show readiness status
- Link to deployment history
**Breaking Changes:** None - Adds optional section
---
### Phase 6: Frontend - WordPress Connection UI
#### Task 6.1: Enhance Integration Settings UI
**File:** `frontend/src/pages/Settings/Integrations.tsx` (or create new)
**Features:**
- Show WordPress integration status
- Credential health check
- Last sync time
- Active site type detection
- Troubleshooting helper text
- Links to docs/runbook
**API Integration:**
- `GET /api/v1/integration/integrations/{id}/sync_status/` (existing)
- `POST /api/v1/integration/integrations/{id}/test_connection/` (existing)
**Breaking Changes:** None - Enhances existing UI
---
## 🔒 Backward Compatibility Guarantees
### No Breaking Changes Policy
1. **All new endpoints are additive** - No existing endpoints modified
2. **All new methods are optional** - Existing code continues to work
3. **Database changes are additive** - New fields are nullable
4. **Service enhancements are backward compatible** - Old behavior preserved
### Migration Strategy
1. **Feature Flag:** `USE_STAGE4_SYNC` (default: `False`)
2. **Gradual Rollout:** Enable per site/integration
3. **Fallback:** If Stage 4 features fail, fall back to existing behavior
---
## 📊 Implementation Checklist
### Backend
- [ ] Task 1.1: Enhance WordPressClient with taxonomy/product methods
- [ ] Task 1.2: Enhance ContentSyncService for taxonomies
- [ ] Task 1.3: Create SyncHealthService
- [ ] Task 2.1: Create DeploymentReadinessService
- [ ] Task 2.2: Enhance SitesRendererAdapter with Stage 3 metadata
- [ ] Task 3.1: Add sync health endpoints
- [ ] Task 3.2: Add deployment readiness endpoint
### Frontend
- [ ] Task 4.1: Create Sync Dashboard component
- [ ] Task 4.2: Add sync status to Site Dashboard
- [ ] Task 5.1: Create Deployment Panel component
- [ ] Task 5.2: Integrate Deployment Panel
- [ ] Task 6.1: Enhance WordPress Connection UI
### Testing
- [ ] Unit tests for new services
- [ ] Integration tests for sync flows
- [ ] E2E tests for deployment panel
- [ ] Manual testing with live WordPress instance
### Documentation
- [ ] Update API documentation
- [ ] Create operational runbooks
- [ ] Update user documentation
---
## 🚨 Risk Mitigation
### Risk 1: WordPress API Rate Limits
**Mitigation:**
- Implement backoff + batching in WordPressClient
- Show rate limit status in dashboard
- Queue sync operations
### Risk 2: Data Mismatches
**Mitigation:**
- Detailed diff view in dashboard
- Retry actions for failed items
- Documented runbook for manual fixes
### Risk 3: Deployment Failures
**Mitigation:**
- Preflight checks before deploy
- Rollback button with confirmation
- Structured logs for debugging
### Risk 4: Breaking Existing Functionality
**Mitigation:**
- Feature flag protection
- Comprehensive testing
- Gradual rollout plan
---
## 📝 Next Steps
1. **Review this plan** with team
2. **Create feature branch:** `feature/stage4-sync-integration`
3. **Start with Phase 1** (Backend WordPress sync)
4. **Test incrementally** after each phase
5. **Document as you go** - Update this plan with progress
---
*This plan ensures Stage 4 implementation without breaking existing functionality.*

View File

@@ -1,141 +0,0 @@
# IGNY8 Sites, Planner, and Writer Unified Architecture Plan
## Purpose
Describe the backend and frontend changes required to support cluster-first site planning, taxonomy-aware site building (blog, ecommerce, company), and seamless integration with WordPress sync workflows. This document consolidates the previous analysis into an actionable architecture plan—no implementation code, only structure, responsibilities, and key function/service names where helpful.
---
## High-Level Objectives
- Enforce keyword/cluster gating before any sitemap or content planning.
- Generate and manage taxonomies (categories, tags, product attributes, service groups) as first-class entities tied to clusters.
- Support three site archetypes (blog, ecommerce, company) while keeping the framework extensible.
- Ensure Planner → Ideas → Writer → Linker → Optimizer all operate with consistent metadata (clusters, taxonomies, entity types).
- Maintain a shared data model for native IGNY8 sites and synced WordPress properties—no duplication, just different hosting targets.
---
## Backend Architecture Plan
### 0. Ownership & Responsibility Layers
- **Planner Domain** Keyword import, clustering, taxonomy recommendations, idea orchestration.
- **Site Builder Domain** Brief intake, taxonomy blueprinting, sitemap scaffolding, hosting destination awareness.
- **Writer Domain** Idea-to-task conversion, AI generation, media assets, optimization readiness.
- **Publishing/Sync Domain** Deployment to IGNY8 renderer, WordPress/WooCommerce sync adapters, status reconciliation.
### 1. Data Model Extensions
| Area | Changes | Notes |
| --- | --- | --- |
| **Site Builder** | Add `SiteBlueprintCluster`, `SiteBlueprintTaxonomy`, `PageBlueprint.entity_type`, `PageBlueprint.taxonomy_ref_id`. Support taxonomy types (`blog_category`, `blog_tag`, `product_category`, `product_tag`, `product_attribute`, `service_category`). Track cluster role (hub, pillar, supporting). | Enables sitemap to reference clusters/taxonomies explicitly. |
| **Planner (Keywords/Clusters/Ideas)** | Enhance `Clusters` with `context_type` (`topic`, `attribute`, `service_line`), `dimension_meta` JSON. Extend `Keywords` with `attribute_values`. Expand `ContentIdeas` to include `site_entity_type`, `taxonomy_id`, `cluster_role`. | Allows multi-dimensional clustering (topic + attribute) and taxonomy seeding. |
| **Writer (Tasks/Content/Images)** | Add `Tasks.entity_type`, `Tasks.taxonomy_id`, `Tasks.cluster_role`, `Tasks.product_data`. Introduce `ContentClusterMap`, `ContentTaxonomyMap`, `ContentAttributeMap` tables. Expand `Images` with `usage_context`. | Gives structured metadata for publishing, linking, and optimization. |
| **Linker & Optimizer** | Update services to rely on new mapping tables and cluster dimensions for auto-linking and scoring. | No schema change beyond indices referencing new relations. |
| **WordPress Sync** | Store external taxonomy IDs within `SiteBlueprintTaxonomy`, `ContentTaxonomyMap`, etc., so synced content maps cleanly. | Requires metadata fields like `external_reference`. |
### 2. Service / Workflow Updates
- **StructureGenerationService.generate_structure**: extend prompts to consume cluster lists, taxonomy seeds, and site type; output page → cluster/taxonomy assignments.
- **TaxonomyService (new)**: handles CRUD of blueprint taxonomies, ties them to clusters/keywords, imports from WordPress/WooCommerce.
- **ClusteringService**: upgrade to produce topic + attribute layers, propose taxonomy seeds, flag uncovered product/service dimensions.
- **IdeasService & ContentGeneration pipeline**: ensure all tasks carry cluster/taxonomy metadata; enforce “no cluster, no idea/task” rule.
- **LinkingService / OptimizerService**: leverage `ContentClusterMap` and `ContentAttributeMap` to generate hub ↔ attribute links, evaluate dimension coverage.
- **WordPressSyncService**: fully implement taxonomy + product fetching, map to IGNY8 schema, and reuse TaxonomyService for storage.
- **WorkflowStateService (new)**: persists user progress for each site build (step status, prerequisites met) to drive state-aware frontend.
- **Validation hooks**: per-step API validators (e.g., `validate_clusters_attached(site_blueprint_id)`) exposed to frontend for gating buttons.
### 3. API & Validation
- Builder endpoints must require cluster selection and taxonomy definition before allowing `generate_structure`.
- Planner/Ideas endpoints validate that requested entity types align with available taxonomies (e.g., product ideas require product categories/attributes).
- Writer endpoints include entity metadata in serializers to surface context in dashboards.
### 4. End-to-End Backend Flow (Self-Guided)
1. **Wizard Initiation**
- `POST /site-builder/blueprints/` creates draft blueprint + workflow state record (step = `business_details`).
2. **Cluster Attachment**
- `POST /site-builder/blueprints/{id}/clusters/attach` validates at least one planner cluster; updates workflow state → `clusters_ready`.
3. **Taxonomy Blueprinting**
- `POST /site-builder/blueprints/{id}/taxonomies/` uses `TaxonomyService`. Each taxonomy row stored with cluster references; workflow state → `taxonomies_ready` when required types filled per site archetype.
4. **Sitemap Generation**
- `POST /site-builder/blueprints/{id}/generate_structure/` allowed only if previous flags true. Service writes `structure_json`, `PageBlueprint` rows, `SiteBlueprintCluster` coverage map; workflow state → `sitemap_ready`.
5. **Coverage Check**
- `POST /site-builder/blueprints/{id}/coverage/confirm` ensures each cluster has hub + at least one supporting entity; sets state → `ideas_ready`.
6. **Ideas Creation**
- `POST /planner/content-ideas/bulk_from_blueprint/` generates ideas referencing blueprint/page IDs; state → `ideas_in_progress`.
7. **Writer Tasks**
- `PageGenerationService.generate_all_pages` creates `Tasks` with entity metadata; `Content` pipeline runs as today but includes cluster/taxonomy associations.
8. **Link/Optimize**
- Linker/optimizer services query new mapping tables to produce suggestions and scorecards; statuses fed back to workflow to show completion percentages.
9. **Publish/Sync**
- `SitesRendererAdapter` or `WordPressAdapter` reads structured metadata for deployment, ensuring taxonomies exist upstream (adapter auto-creates if missing).
---
## Frontend Architecture Plan
### 1. Wizard & Sites Module
| Step | Enhancements |
| --- | --- |
| Business Details | Site type selector (blog/ecommerce/company) with hosting options (IGNY8, WordPress); auto-detect hosting if WP integration exists. |
| Cluster Assignment | Dedicated step to select/attach planner clusters (with search/filter); block progress until at least one cluster chosen; show metrics (keywords, volume). |
| Taxonomy Builder | Visual editor for categories/tags/product attributes/service groups. Allow suggestions from clustering results and imports from WP. Support linking each taxonomy item to a cluster (hub or attribute). |
| Sitemap Review | Present AI-generated pages grouped by cluster/taxonomy; allow manual adjustments; highlight uncovered clusters or orphaned taxonomies. Show checklist for required hub/supporting pages per cluster. |
| Ideas Hand-off | Provide UI to send selected pages to Ideas module with optional guidance prompt (2nd prompt requirement). Display confirmation modal summarizing clusters + page counts. |
### 1.1 Wizard State Management (Self-Guided UX)
- Use a dedicated Zustand/Redux slice `builderWorkflowStore` to track: `currentStep`, `completedSteps`, `blockingIssues`, `blueprintState`.
- Each step component fetches validation status via `/site-builder/workflow/{blueprintId}` to decide if Next button is enabled.
- Inline “Why disabled?” tooltips list missing requirements (e.g., “Attach ≥1 cluster with ≥3 keywords each”).
- Breadcrumb/progress indicator shows step numbers + completion badges.
- Autosave after each interaction; resume wizard lands user back on last incomplete step.
### 2. Planner & Keyword UI
- Update cluster list views to show context type and associated taxonomies.
- Add attribute dimension visualization (e.g., matrix of clusters vs attributes).
- Ensure keyword table supports attribute tagging and multi-dimensional filtering.
### 3. Ideas & Writer Dashboards
- Surfaces for entity types (blog post, product, service, taxonomy page) with filters.
- Editors receive context chips (cluster, taxonomy, attribute). Provide quick links to hub pages and attribute groups.
- Validation states: warn if content lacks required taxonomy or attribute coverage before publishing.
- Task list views grouped by blueprint/site; show progress bars (e.g., “Products: 5/12 drafted”).
- Writer editor side panel summarises: assigned cluster, target taxonomy, keyword cluster metrics, attribute list.
### 4. Linker & Optimizer UI
- Linker suggestion panel grouped by cluster role (hub → supporting, hub → attribute).
- Optimizer scorecards showing coverage per cluster dimension (topic, attribute, intent).
### 5. WordPress Sync Screens
- Integration settings show detected taxonomies and site type.
- Sync dashboard lists imported posts/products/services with their cluster/taxonomy assignments; allow manual re-mapping.
- Provide “Sync health” panel: taxonomy parity, cluster coverage, last sync time. Buttons disabled if prerequisites unmet (e.g., no clusters mapped).
### 6. UX Guardrails & Guidance
- **Contextual Helpers**: Each wizard step includes collapsible explainer matching backend validations (“Clusters drive sitemap; select clusters to continue.”).
- **Empty States**: Planner/writer views show CTA buttons to jump back into wizard steps when prerequisites missing.
- **Notifications**: System toasts (or inline callouts) when backend rejects action—links take user to offending step.
- **Review Mode**: After completion, a read-only summary page lists all steps with “Edit” buttons, ensuring users never feel lost.
---
## Workflow Alignment Summary
1. **Site Brief Intake** → choose site type + hosting, gather business data.
2. **Cluster Gating** → attach keyword clusters/keywords; enforce before sitemap.
3. **Taxonomy Blueprint** → define or import taxonomies linked to clusters.
4. **AI Sitemap Generation** → produce pages with entity types + cluster/taxonomy refs.
5. **Coverage Validation** → ensure no cluster/taxonomy gaps before moving on.
6. **Ideas Creation** → push sitemap nodes into Ideas with cluster/taxonomy metadata; capture secondary prompt.
7. **Writer Flow** → existing pipeline enhanced with entity metadata, rich product/service attributes, and multi-dimensional content blocks.
8. **Linking & Optimization** → leverage new relations for automatic internal linking and SEO scoring.
9. **Deployment / Sync** → IGNY8 hosting deploys enriched content; WordPress adapter syncs posts/products/services with matching taxonomies (no duplication, just publishing).
---
## Implementation Notes
- Prioritize schema migrations and service updates before UI changes to ensure APIs provide necessary data.
- Keep prompts/configs environment-driven for easy tuning as new site types (e.g., SaaS portals) are added later.
- Maintain backward compatibility by auto-populating default values for existing blueprints/tasks until users opt into the new flow.
- Testing should cover: multi-site types, imported WordPress data, planner → writer gating, and deployment outputs.
---
*Document owner: Architecture team.*
*Last updated: {{DATE}} (replace during edits).*

View File

@@ -1,311 +0,0 @@
# IGNY8 Refactor Plan Stage Implementation Guide
This document complements `SITE_BUILDER_PLANNER_ARCHITECTURE_PLAN.md` by outlining how to deliver the refactor in four controlled stages. Each stage lists scope, tasks, exits, and testing so workstreams can move independently without breaking user flows.
---
## Stage 1 Data & Services Foundation
**Objective:** Build all backend scaffolding (schema + services) required for the guided site builder, richer planner, and downstream metadata.
### 1. Sequenced Plan of Work
1. **Preparation**
- Freeze any pending migrations; branch off `refactor-stage1`.
- Create feature flags (`USE_SITE_BUILDER_REFACTOR`) in settings/env files.
- Draft ERD updates and share with backend team for approval.
2. **Schema Implementation**
- **Site Builder tables**
- `SiteBlueprintCluster`: fields for `cluster_id`, `role`, `coverage_status`, `metadata`.
- `SiteBlueprintTaxonomy`: taxonomy type enum, `cluster_id`, optional external reference.
- `WorkflowState`: blueprint FK, `current_step`, `step_status`, `blocking_reason`, timestamps.
- **Writer tables**
- `ContentClusterMap`, `ContentTaxonomyMap`, `ContentAttributeMap` with FK constraints + indexes for performant lookups.
- Run migrations locally → staging; capture SQL diff in change log.
3. **Service Layer**
- Implement `WorkflowStateService` with methods:
- `initialize(site_blueprint)` create default states.
- `update_step(step, status, meta)` persists transitions and emits audit logs.
- `validate_step(step)` raises descriptive errors for UI.
- Implement `TaxonomyService`:
- CRUD handlers.
- Import adapters (WordPress categories/tags, WooCommerce product attributes).
- Helper to map taxonomy ↔ cluster(s).
- Update `ClusteringService` prompts to emit:
- Topic cluster suggestions.
- Attribute/feature recommendations per keyword set.
- Taxonomy hints (category/tag names).
4. **API/Serializer Updates**
- Planner serializers return `context_type`, `dimension_meta`.
- Writer serializers include `entity_type`, taxonomy associations, validation errors.
- Site builder endpoints expose workflow state + gating booleans.
5. **Validation Hooks**
- Add reusable validators (e.g., `ensure_clusters_attached(site_blueprint)`).
- Integrate validators into existing actions (`generate_structure`, `create_tasks_from_blueprint`).
6. **Internal Tooling & Docs**
- Update Postman collection / API reference for new endpoints + payloads.
- Write developer doc describing new models + services.
- Set up monitoring dashboards (Grafana/NewRelic) for:
- Migration duration.
- Celery task errors referencing new services.
### 2. Owners & Dependencies
- **Backend Lead:** owns migrations, services, validator integration.
- **Data/DBA:** reviews migration plan, handles staging rollout.
- **QA:** prepares regression scripts for planner/writer.
- **Docs:** updates `master-docs` (backend + AI framework) with new tables/services.
- Dependencies: PostgreSQL 15 features already available; no external API changes needed.
### 3. Deliverables & Exit Criteria
- ✅ Migrations applied to staging + rollback verified.
-`WorkflowStateService`, `TaxonomyService`, `ClusteringService` updates merged with unit tests.
- ✅ Planner/Writer legacy flows pass smoke tests (imports, clustering, idea creation, content generation).
- ✅ API reference + architecture docs updated.
- ✅ Feature flag defaults to OFF (no user-facing change yet).
### 4. Testing Matrix
| Area | Automated | Manual |
| --- | --- | --- |
| Migrations | `pytest` migration test + Django fake migrations | Dry run on staging, rollback rehearsal |
| Services | Unit tests for new service methods | Postman calls to workflow/taxonomy endpoints |
| Validators | Serializer/endpoint tests expecting 4xx when requirements unmet | Trigger via API (e.g., attempt sitemap gen without clusters) |
| Regression | Existing planner/writer test suite | Smoke test: keyword import → cluster → idea → task → content |
### 5. Rollout Checklist
1. Merge migrations + services behind feature flag.
2. Deploy to staging, run migration + regression script.
3. Monitor Celery/DB logs for anomalies.
4. After 24h stability, promote to production (still gated by flag).
5. Announce availability to frontend team to begin Stage 2 work.
---
## Stage 2 Planner + Wizard UX
**Objective:** Ship the state-aware, self-guided planner + site builder experience on top of Stage 1 services.
### 1. Sequenced Plan of Work
1. **Planning & Design**
- UX team finalizes wizard wireframes + microcopy for each step, including helper text/tooltips.
- Define telemetry schema (events: `wizard_step_started`, `wizard_step_completed`, `wizard_blocking_issue`).
- Review backend responses needed per step (cluster metrics, taxonomy suggestions, validation errors).
2. **Backend Enhancements**
- Extend planner endpoints to return:
- Cluster stats (keyword count, projected hubs/support pages).
- Suggested taxonomies/attributes from Stage 1 `dimension_meta`.
- Validation error payloads structured for UI (“missing clusters”, “taxonomy incomplete”).
- Add audit logging to `WorkflowStateService.update_step` for troubleshooting.
3. **Frontend Infrastructure**
- Build `builderWorkflowStore` (Zustand):
- State: `currentStep`, `completedSteps`, `blockingIssues`, `workflowState`, `loading`.
- Actions: `goToStep`, `completeStep`, `refreshState`, `setBlockingIssue`.
- Persistence: sessionStorage/localStorage to resume across refreshes.
- Hook store into new `/site-builder/workflow/{blueprintId}` endpoints.
4. **Wizard Step Implementation**
- **Step 1 Business Details**
- Components for site type selection, hosting detection (show WP integration status), brand inputs.
- Save actions call blueprint PATCH + workflow state update.
- **Step 2 Cluster Assignment**
- Table/list of clusters with filters (intent, volume, context type).
- Coverage meter (keywords covered vs. target).
- “Add cluster” action hitting `/blueprints/{id}/clusters/attach`.
- Blocking logic: enforce minimum cluster count/keyword count per site type.
- **Step 3 Taxonomy Builder**
- Tree/table for categories, tags, product attributes, service groups.
- Import buttons (WordPress/WooCommerce) calling `TaxonomyService` endpoints.
- Mapping UI linking taxonomy items to clusters (drag/drop or select dropdown).
- **Step 4 AI Sitemap Review**
- Grid grouped by cluster/taxonomy.
- Visual checklist (Hub page, Supporting pages count).
- Ability to edit page titles/types, reorder, remove.
- “Regenerate” button to re-run AI structure (with warning on credit usage).
- **Step 5 Coverage Validation**
- Summary cards showing clusters covered/uncovered, taxonomy gaps, attribute coverage.
- CTA to jump back to specific step if gaps remain.
- **Step 6 Ideas Hand-off**
- Select pages to push to Planner Ideas.
- Secondary prompt textarea; show preview of what data AI receives.
- Confirmation modal summarizing cluster/page counts.
5. **Planner Module Enhancements**
- Cluster matrix view showing clusters vs. taxonomy/attribute coverage, clickable to drill into wizard step.
- Taxonomy management table (search, filters, bulk edits).
- Inline warnings (e.g., banner on Planner home when blueprint still missing requirements).
6. **UX Guardrails**
- Breadcrumb/progress component with checkmarks.
- Disabled Next button shows tooltip listing unmet requirements.
- Contextual helper drawer per step (links to docs, best practices).
### 2. Owners & Dependencies
- **Frontend Lead:** wizard implementation + planner UI updates.
- **Backend Support:** ensure required data returned, logging in place.
- **Design/UX:** final visuals, helper content, accessibility review.
- **Docs/Enablement:** in-app help, video walkthroughs.
- Dependency: Stage 1 feature flag must be AVAILABLE with APIs stable.
### 3. Deliverables & Exit Criteria
- ✅ Wizard completes end-to-end (feature-flagged) for both IGNY8-hosted and WP-linked sites.
- ✅ Telemetry events firing and visible in analytics dashboard.
- ✅ QA scripts covering success/failure states executed, accessibility issues resolved.
- ✅ Documentation (knowledge base, tooltips) updated.
- ✅ Rollout plan ready (progressive enablement per account/site type).
### 4. Testing Matrix
| Area | Automated | Manual |
| --- | --- | --- |
| Wizard Flow | Cypress tests for each step, gating logic, resume | Scenario walkthroughs (new site, WP import), cross-browser testing |
| Planner Views | Jest/unit tests for new components, store logic | Performance check on cluster matrix, UX review |
| Telemetry | Unit tests ensuring events dispatch | Verify dashboards receiving events |
| Accessibility | Lint checks (aria labels, keyboard nav) | Screen reader + keyboard-only validation |
### 5. Rollout Checklist
1. Feature flag ON for internal testers → gather feedback.
2. Fix critical issues, re-run automated suite.
3. Enable for pilot accounts (one IGNY8 host, one WP host).
4. Monitor telemetry/feedback; ensure support team ready.
5. Gradually roll out to all accounts; announce in release notes + in-app banner.
---
## Stage 3 Writer / Linker / Optimizer Enhancements
**Objective:** Propagate the new metadata through content creation and optimization, ensuring validation before publish.
### 1. Sequenced Plan of Work
1. **Metadata Audit & Defaults**
- Verify Stage 1 migrations populated defaults for legacy content/tasks.
- Script to backfill `entity_type`, `taxonomy_id`, `cluster_role` for existing records (with audit log).
2. **Backend Pipeline Updates**
- **Ideas → Tasks**: update services so every task inherits cluster/taxonomy/attribute metadata.
- **Tasks → Content**: adjust `ContentPipelineService` to store mappings in `ContentClusterMap`, etc.
- **Prompt Updates**: AI prompts include cluster role, taxonomy context, product attributes to produce richer output.
- **Validation Services**: create reusable validators (e.g., `ensure_required_attributes(task)`) returning human-friendly errors.
3. **Linker & Optimizer Enhancements**
- Linker service leverages mapping tables to suggest hub/supporting/attribute links; adds priority scoring.
- Optimizer scoring factors:
- Cluster coverage (are all hubs/supporting pages present?).
- Taxonomy alignment (page categorized correctly).
- Attribute completeness (product/service specs filled).
- New APIs:
- `GET /sites/{id}/progress` (cluster-level completion + validation status).
- `GET /writer/content/{id}/validation` (aggregated checklist for UI).
4. **Frontend Enhancements**
- **Planner Ideas / Writer Tasks lists**
- Columns/chips for cluster, taxonomy, attributes.
- Filters for entity type & validation status.
- **Writer Editor**
- Sidebar module with cluster summary, taxonomy tree, attribute form.
- Validation panel showing remaining requirements; publish button disabled until cleared.
- **Linker UI**
- Group internal link suggestions by cluster role; show context snippet, CTA to insert.
- **Optimizer Dashboard**
- Scorecards per cluster dimension with color coding + “next action” cards.
- **Site Progress Widgets**
- On site overview, show bars for hubs/supporting/attribute completion; link to problematic clusters.
5. **Notifications & Workflow**
- Inline toast + optional email when validation fails or content ready for review.
- Credit reminder banner when user tries to regenerate content/optimization tasks.
### 2. Owners & Dependencies
- **Backend Lead:** pipeline + services, validation APIs.
- **Frontend Lead:** writer/linker/optimizer UI, progress widgets.
- **AI/Prompt Specialist:** adjust prompts/templates and verify outputs.
- **QA:** regression scripts for writer workflow, linker, optimizer.
- Dependencies: Stage 2 wizard must deliver cluster/taxonomy data; Stage 1 mapping tables in place.
### 3. Deliverables & Exit Criteria
- ✅ All new tasks/content carry entity/taxonomy metadata; legacy content backfilled.
- ✅ Publish action blocked when required metadata missing; errors surfaced clearly.
- ✅ Linker/optimizer screens powered by new data with acceptable performance.
- ✅ Site progress dashboards live for pilot sites with feedback loop established.
### 4. Testing Matrix
| Area | Automated | Manual |
| --- | --- | --- |
| Pipeline | Unit tests on service functions, serializer coverage | End-to-end run: blueprint → ideas → tasks → content |
| Validation | Tests ensuring validators trigger proper errors | Attempt publish without taxonomy/attributes; confirm UI flow |
| Linker/Optimizer | Service tests for scoring & suggestions | Performance profiling on large datasets; UX review |
| Progress Widgets | Component/unit tests | Compare counts vs. database for pilot site |
### 5. Rollout Checklist
1. Deploy to staging with feature flag ON; run regression suite.
2. Backfill metadata for existing content in staging; verify no issues.
3. Pilot with internal content team; gather feedback on validation friction.
4. Optimize slow queries (add indexes/caching) before production rollout.
5. Update training docs/videos for writers; enable flag gradually across accounts.
---
## Stage 4 Publishing & Sync Integration
**Objective:** Achieve feature parity between IGNY8-hosted deployments and WordPress sites, using the shared metadata model.
### 1. Sequenced Plan of Work
1. **Sync Architecture Review**
- Audit existing WordPress adapter + sync service.
- Confirm required endpoints (categories, tags, WooCommerce attributes/products) and authentication flows.
- Document data mapping between WP taxonomies and new IGNY8 taxonomy tables.
2. **Backend Enhancements**
- **Import**
- Extend `ContentSyncService` to fetch WP taxonomies, products, custom post types.
- Map external IDs to `SiteBlueprintTaxonomy`, `ContentTaxonomyMap`, storing `external_reference`.
- Auto-create missing clusters/taxonomies with flag indicating “imported”.
- **Export**
- Update `WordPressAdapter` to create/update taxonomies before publishing posts/products.
- Ensure product attributes/tags pushed before product content.
- **Sync Health**
- New endpoints: `/sites/{id}/sync/status`, `/sites/{id}/sync/run`.
- Track last sync time, mismatch counts, error logs.
- **Deployment**
- `SitesRendererAdapter` consumes cluster/taxonomy metadata to build navigation, breadcrumbs, internal links.
- Deployment readiness check service summarizing cluster coverage, content publish status, validation flags.
- **Logging/Monitoring**
- Structured logs for sync runs (duration, items processed, failures).
- Alerts for repeated sync failures or deployment errors.
3. **Frontend Enhancements**
- **Sync Dashboard**
- Parity indicators (taxonomies, products, posts) with status icons.
- Buttons for manual sync, retry failed items, view logs.
- Detail drawer showing mismatched items and suggested fixes.
- **Deployment Panel**
- Readiness checklist (clusters covered, content statuses, validation passes).
- Deploy + rollback buttons with confirmation modals.
- Toast/notification system for deploy/sync success/failure.
- **WordPress Connection UI**
- Surface integration status, credentials check, last sync info.
4. **Operational Runbooks**
- Document sync troubleshooting steps, rollback procedures, and escalation path.
- Provide support scripts for forcing sync, clearing queue, recovering failed deployment.
### 2. Owners & Dependencies
- **Backend Lead:** sync/import/export logic, deployment readiness service.
- **Frontend Lead:** sync dashboard, deployment UI.
- **Infra/DevOps:** monitoring, alerting, runbooks.
- **QA:** end-to-end publish tests IGNY8↔WP.
- Dependencies: Stage 3 metadata stable; WordPress credentials for pilot sites available.
### 3. Deliverables & Exit Criteria
- ✅ End-to-end publishing works for blog/ecommerce/company templates on IGNY8 hosting and WordPress (posts/products/services).
- ✅ Sync dashboard shows green status for pilot accounts; manual retry resolves mismatches.
- ✅ Deployment readiness checks enforced; logs + rollback procedures documented.
- ✅ Release notes + training material published.
### 4. Testing Matrix
| Area | Automated | Manual |
| --- | --- | --- |
| Sync Logic | Integration tests hitting mocked WP APIs | Staging sync from live WP instance; verify taxonomy parity |
| Deployment | Renderer tests verifying metadata usage | Deploy IGNY8 site, inspect navigation/internal links |
| Dashboards | Component/unit tests | Pilot user testing of sync dashboard + deployment flow |
| Runbooks | N/A | Tabletop exercises for failure scenarios (sync fails, deploy rollback) |
### 5. Rollout Checklist
1. Enable Stage 4 flag in staging; run full sync/import tests.
2. Pilot with one IGNY8-hosted and one WP-hosted site; gather feedback.
3. Train support team on new dashboards/runbooks.
4. Announce availability; roll out gradually to accounts with WordPress integrations.
5. Monitor logs/alerts closely during first production syncs; iterate on tooling as needed.
---
## Stage Coordination Notes
- **Feature flags**: introduce per-stage flags to roll out gradually.
- **Monitoring**: add dashboards for workflow step failures, sync errors, credit usage spikes.
- **Documentation cadence**: update `master-docs` + `part2-dev/planning` after each stage completes.
- **Entry/exit reviews**: hold short readiness reviews before moving to the next stage to ensure dependencies satisfied.
This plan ensures each layer stabilizes before the next, keeping users on a guided, predictable experience throughout the refactor.

View File

@@ -1,281 +0,0 @@
# Stage 2 Completion Status
**Last Updated:** 2025-01-XX
**Feature Flag:** `USE_SITE_BUILDER_REFACTOR` (must be `true`)
**Status:****STAGE 2 COMPLETE** - All core functionality implemented and ready for testing
---
## ✅ Completed Items
### Backend Enhancements
| Item | Status | File/Location | Notes |
|------|--------|---------------|-------|
| **WizardContextService** | ✅ Complete | `backend/igny8_core/business/site_building/services/wizard_context_service.py` | Aggregates workflow state, cluster stats, taxonomy summaries, coverage counts |
| **Workflow Context API** | ✅ Complete | `backend/igny8_core/modules/site_builder/views.py` | `GET /api/v1/site-builder/siteblueprint/{id}/workflow/context/` returns full wizard context |
| **Workflow State Serialization** | ✅ Complete | `backend/igny8_core/business/site_building/services/workflow_state_service.py` | `serialize_state()` provides consistent payload with normalized step metadata |
| **SiteBlueprint Serializer Updates** | ✅ Complete | `backend/igny8_core/modules/site_builder/serializers.py` | Returns `workflow_state` + `gating_messages` when feature flag enabled |
| **Structured Logging** | ✅ Complete | `backend/igny8_core/business/site_building/services/workflow_state_service.py` | Emits `wizard_step_updated`, `wizard_blocking_issue` events |
| **Workflow Step Update API** | ✅ Complete | `backend/igny8_core/modules/site_builder/views.py` | `POST /api/v1/site-builder/siteblueprint/{id}/workflow/step/` updates step status |
| **Cluster Attach/Detach API** | ✅ Complete | `backend/igny8_core/modules/site_builder/views.py` | `POST /clusters/attach/` and `POST /clusters/detach/` endpoints |
| **Taxonomy CRUD API** | ✅ Complete | `backend/igny8_core/modules/site_builder/views.py` | `GET /taxonomies/`, `POST /taxonomies/`, `POST /taxonomies/import/` endpoints |
| **Page Blueprint API** | ✅ Complete | `backend/igny8_core/modules/site_builder/views.py` | `PATCH /pageblueprint/{id}/`, `POST /pageblueprint/{id}/regenerate/`, `POST /pageblueprint/{id}/generate_content/` |
| **Task Creation API** | ✅ Complete | `backend/igny8_core/modules/site_builder/views.py` | `POST /create_tasks/` endpoint for creating Writer tasks from page blueprints |
| **Database Migrations** | ✅ Not Required | N/A | All endpoints use existing models from Stage 1 (`SiteBlueprintCluster`, `SiteBlueprintTaxonomy`, `WorkflowState`, `PageBlueprint`) |
### Frontend Infrastructure
| Item | Status | File/Location | Notes |
|------|--------|---------------|-------|
| **API Type Definitions** | ✅ Complete | `frontend/src/services/api.ts` | TypeScript interfaces: `SiteBlueprint`, `WorkflowState`, `WizardContext` |
| **API Functions** | ✅ Complete | `frontend/src/services/api.ts` | `fetchSiteBlueprints`, `fetchSiteBlueprintById`, `updateSiteBlueprint`, `fetchWizardContext`, `updateWorkflowStep` |
| **Zustand Workflow Store** | ✅ Complete | `frontend/src/store/builderWorkflowStore.ts` | Full state management with persistence, actions, telemetry queue |
| **Wizard Shell Component** | ✅ Complete | `frontend/src/pages/Sites/Builder/WorkflowWizard.tsx` | Main container with auto-refresh, error handling, step routing |
| **Progress Indicator** | ✅ Complete | `frontend/src/pages/Sites/Builder/components/WizardProgress.tsx` | Breadcrumb with completion checkmarks, blocking indicators |
| **Wizard Route** | ✅ Complete | `frontend/src/App.tsx` | `/sites/builder/workflow/:blueprintId` route added |
### Wizard Step Components
| Step | Component | Status | Functionality |
|------|-----------|--------|---------------|
| **Step 1: Business Details** | `BusinessDetailsStep.tsx` | ✅ **Functional** | Form with site name, description, hosting type. Saves to blueprint + completes workflow step |
| **Step 2: Cluster Assignment** | `ClusterAssignmentStep.tsx` | ✅ **Complete** | Full interactive UI with cluster selection table, filters, attach/detach actions, role assignment |
| **Step 3: Taxonomy Builder** | `TaxonomyBuilderStep.tsx` | ✅ **Complete** | Full tree/table UI with create, edit, import functionality, cluster linking |
| **Step 4: AI Sitemap Review** | `SitemapReviewStep.tsx` | ✅ **Complete** | Grid UI with page cards, edit capabilities, regenerate functionality |
| **Step 5: Coverage Validation** | `CoverageValidationStep.tsx` | ✅ **Complete** | Coverage cards with validation logic, status indicators, blocking issue display |
| **Step 6: Ideas Hand-off** | `IdeasHandoffStep.tsx` | ✅ **Complete** | Page selection interface with checkboxes, prompt override, task creation |
### Core Features
| Feature | Status | Notes |
|---------|--------|-------|
| **Workflow State Persistence** | ✅ Complete | Backend `WorkflowState` model + frontend store persistence |
| **Step Gating Logic** | ✅ Complete | Validators block steps until prerequisites met |
| **Blocking Issue Display** | ✅ Complete | Frontend shows blocking messages from backend validators |
| **Progress Tracking** | ✅ Complete | Visual progress indicator with step completion status |
| **Auto-refresh Context** | ✅ Complete | Wizard refreshes workflow context every 10 seconds |
| **Error Handling** | ✅ Complete | Loading states, error messages, graceful failures |
---
## Backend API Endpoints (Stage 2)
All new endpoints are fully implemented and functional:
### Cluster Management
- `POST /api/v1/site-builder/siteblueprint/{id}/clusters/attach/` - Attach clusters to blueprint
- `POST /api/v1/site-builder/siteblueprint/{id}/clusters/detach/` - Detach clusters from blueprint
### Taxonomy Management
- `GET /api/v1/site-builder/siteblueprint/{id}/taxonomies/` - List all taxonomies
- `POST /api/v1/site-builder/siteblueprint/{id}/taxonomies/` - Create new taxonomy
- `POST /api/v1/site-builder/siteblueprint/{id}/taxonomies/import/` - Import taxonomies from CSV/WordPress
### Page Blueprint Operations
- `PATCH /api/v1/site-builder/pageblueprint/{id}/` - Update page blueprint (title, slug, type)
- `POST /api/v1/site-builder/pageblueprint/{id}/regenerate/` - Regenerate individual page
- `POST /api/v1/site-builder/pageblueprint/{id}/generate_content/` - Generate content for page
### Task Creation
- `POST /api/v1/site-builder/siteblueprint/{id}/create_tasks/` - Create Writer tasks from page blueprints
### Workflow Management
- `POST /api/v1/site-builder/siteblueprint/{id}/workflow/step/` - Update workflow step status
---
## Planner Module Enhancements
| Item | Status | Notes |
|------|--------|-------|
| **Cluster Matrix View** | ⚠️ Future Enhancement | Can be added as separate enhancement (not blocking Stage 2) |
| **Taxonomy Management Table** | ⚠️ Future Enhancement | Can be added as separate enhancement (not blocking Stage 2) |
| **Planner Dashboard Banner** | ✅ **Complete** | Shows warning banner with links to incomplete blueprints |
### UX Guardrails
| Item | Status | Notes |
|------|--------|-------|
| **Breadcrumb/Progress** | ✅ Complete | `WizardProgress` component implemented |
| **Disabled Button Tooltips** | ✅ **Complete** | `ButtonWithTooltip` component added, all wizard steps use tooltips on disabled buttons |
| **Helper Drawer** | ✅ **Complete** | `HelperDrawer` component with contextual help for each step, accessible via F1/? key |
| **Keyboard Navigation** | ✅ **Complete** | Keyboard shortcuts: F1/? for help, Ctrl/Cmd+Arrow for step navigation, Escape to close drawer |
| **Empty States** | ✅ Complete | Empty states implemented in all step components |
### Telemetry
| Item | Status | Notes |
|------|--------|-------|
| **Event Queue** | ✅ Complete | Store has `telemetryQueue` array |
| **Event Logging** | ✅ Complete | Backend logs structured events |
| **Event Dispatch** | ⚠️ Placeholder | Currently logs to console, needs analytics service integration |
---
## ❌ Not Started
### Testing & QA
| Item | Status | Notes |
|------|--------|-------|
| **Cypress E2E Tests** | ❌ Not Started | Need tests for wizard flow, gating logic, resume functionality |
| **Jest Unit Tests** | ❌ Not Started | Store logic, component tests |
| **Accessibility Audit** | ❌ Not Started | Screen reader, keyboard-only validation |
| **Cross-browser Testing** | ❌ Not Started | Manual testing across browsers |
### Documentation
| Item | Status | Notes |
|------|--------|-------|
| **In-app Help** | ❌ Not Started | Helper content, tooltips, best practices |
| **Video Walkthroughs** | ❌ Not Started | User onboarding materials |
| **API Documentation** | ⚠️ Partial | Endpoints exist, need OpenAPI/Swagger updates |
### Rollout Preparation
| Item | Status | Notes |
|------|--------|-------|
| **Internal Testing** | ❌ Not Started | Feature flag ON for internal testers |
| **Pilot Accounts** | ❌ Not Started | One IGNY8 host, one WP host |
| **Support Training** | ❌ Not Started | Support team readiness |
| **Release Notes** | ❌ Not Started | User-facing documentation |
---
## Completion Summary
### ✅ Fully Complete (Ready for Use)
- Backend services & APIs (all endpoints implemented)
- Frontend infrastructure (store, routing, shell, progress indicator)
- All 6 wizard steps - fully functional with interactive UIs
- Cluster attach/detach functionality
- Taxonomy CRUD and import functionality
- Page blueprint edit and regenerate
- Coverage validation with blocking logic
- Ideas hand-off with task creation
- Planner dashboard banner for incomplete blueprints
- UX improvements (tooltips, helper drawer, keyboard navigation)
- Error handling & state management
- Progress tracking & gating logic
### ⚠️ Future Enhancements (Not Blocking)
- Telemetry dispatcher (queue exists, analytics integration pending)
- Cluster matrix view in Planner (can be added separately)
- Taxonomy management table in Planner (can be added separately)
- Full accessibility audit (basic accessibility implemented)
- Testing automation (E2E tests, unit tests)
- Documentation & rollout (internal testing, pilot program)
---
## Testing Checklist
To verify Stage 2 completion:
1. **Backend API Tests:**
```bash
# Workflow Context
GET /api/v1/site-builder/siteblueprint/{id}/workflow/context/
- ✅ Returns `workflow`, `cluster_summary`, `taxonomy_summary`, `sitemap_summary`, `next_actions`
- ✅ Step statuses include `status`, `code`, `message`, `updated_at`
# Cluster Management
POST /api/v1/site-builder/siteblueprint/{id}/clusters/attach/
POST /api/v1/site-builder/siteblueprint/{id}/clusters/detach/
- ✅ Attach/detach clusters with role assignment
# Taxonomy Management
GET /api/v1/site-builder/siteblueprint/{id}/taxonomies/
POST /api/v1/site-builder/siteblueprint/{id}/taxonomies/
POST /api/v1/site-builder/siteblueprint/{id}/taxonomies/import/
- ✅ CRUD operations and import functionality
# Page Blueprint Operations
PATCH /api/v1/site-builder/pageblueprint/{id}/
POST /api/v1/site-builder/pageblueprint/{id}/regenerate/
- ✅ Update and regenerate page blueprints
```
2. **Frontend Wizard Tests:**
- ✅ Navigate to `/sites/builder/workflow/{blueprintId}`
- ✅ Progress indicator shows all 6 steps with completion status
- ✅ Step 1 (Business Details) - Form saves and updates workflow state
- ✅ Step 2 (Cluster Assignment) - Full interactive table with attach/detach, filters, role assignment
- ✅ Step 3 (Taxonomy Builder) - Full CRUD UI with import functionality, cluster linking
- ✅ Step 4 (Sitemap Review) - Grid UI with edit capabilities, regenerate functionality
- ✅ Step 5 (Coverage Validation) - Coverage cards with validation logic, blocking issue display
- ✅ Step 6 (Ideas Hand-off) - Page selection interface with task creation
- ✅ Store persists blueprint ID and current step across refreshes
- ✅ Helper drawer accessible via F1/? key with contextual help
- ✅ Keyboard navigation (Ctrl/Cmd+Arrow for step navigation)
- ✅ Disabled button tooltips show blocking reasons
3. **Workflow State Tests:**
- ✅ Creating blueprint initializes `WorkflowState` record
- ✅ Completing Step 1 updates workflow state to `ready`
- ✅ Blocking validators prevent progression when prerequisites missing
- ✅ Step transitions update `current_step` and `step_status` correctly
4. **Planner Integration Tests:**
- ✅ Dashboard shows banner for incomplete blueprints
- ✅ Banner links navigate to correct wizard step
5. **Database Migration Verification:**
- ✅ **No migrations required** - All endpoints use existing models from Stage 1
- ✅ Models verified: `SiteBlueprintCluster`, `SiteBlueprintTaxonomy`, `WorkflowState`, `PageBlueprint`
---
## Implementation Notes
### Database Migrations
**Status:** ✅ **No migrations required for Stage 2**
All Stage 2 functionality uses existing database models created in Stage 1:
- `SiteBlueprintCluster` (migration `0003_workflow_and_taxonomies.py`)
- `SiteBlueprintTaxonomy` (migration `0003_workflow_and_taxonomies.py`)
- `WorkflowState` (migration `0003_workflow_and_taxonomies.py`)
- `PageBlueprint` (migration `0001_initial.py`)
Stage 2 only adds:
- API endpoints (ViewSet actions)
- Frontend UI components
- Service layer methods
- No schema changes required
### Code Quality
- ✅ No linter errors
- ✅ Consistent with existing codebase patterns
- ✅ Proper error handling and loading states
- ✅ All components properly integrated
---
## Next Steps (Post-Stage 2)
### Future Enhancements (Not Blocking)
1. **Planner Module Enhancements**
- Cluster matrix view
- Taxonomy management table
2. **Testing & QA**
- Cypress E2E tests
- Unit tests for store/components
- Full accessibility audit
3. **Documentation & Rollout**
- In-app help content expansion
- Support training materials
- Pilot program execution
4. **Telemetry Integration**
- Analytics service integration for event dispatch
- Usage metrics dashboard
---
*Last updated: 2025-01-XX*
**Status: ✅ STAGE 2 COMPLETE** - All core functionality implemented and ready for testing
**Migrations:** None required - uses existing Stage 1 models

View File

@@ -1,244 +0,0 @@
# Stage 3 Completion Status
**Last Updated:** 2025-01-27
**Overall Status:** ~95% Complete
## Objective
Propagate the new metadata (clusters, taxonomies, entity types, attributes) through the planner → writer pipeline, enforce validation before publish, and unlock linker/optimizer capabilities.
---
## ✅ Backend Implementation Status
### 1. Metadata Audit & Backfill
| Task | Status | Location | Notes |
|------|--------|----------|-------|
| **Backfill Migration** | ✅ Complete | `backend/igny8_core/modules/writer/migrations/0012_metadata_mapping_tables.py` | Backfill function populates `ContentClusterMap`, `ContentTaxonomyMap`, `ContentAttributeMap` for existing content |
| **Entity Type Defaults** | ✅ Complete | `backend/igny8_core/modules/writer/migrations/0013_stage3_add_task_metadata.py` | Defaults: `entity_type='blog_post'`, `cluster_role='hub'` |
| **Audit Command** | ✅ Complete | `backend/igny8_core/modules/writer/management/commands/audit_site_metadata.py` | Usage: `python manage.py audit_site_metadata --site {id}` |
### 2. Pipeline Updates
| Stage | Status | Location | Notes |
|-------|--------|----------|-------|
| **Ideas → Tasks** | ✅ Complete | `backend/igny8_core/modules/planner/views.py` | `bulk_queue_to_writer()` inherits `entity_type`, `taxonomy`, `cluster_role` from Ideas |
| **PageBlueprint → Tasks** | ✅ Complete | `backend/igny8_core/business/site_building/services/page_generation_service.py` | `_create_task_from_page()` sets metadata from blueprint |
| **Tasks → Content** | ✅ Complete | `backend/igny8_core/business/content/services/metadata_mapping_service.py` | `MetadataMappingService` persists cluster/taxonomy/attribute mappings |
| **AI Prompts** | ✅ **Complete** | `backend/igny8_core/ai/prompts.py` | Updated content generation prompt to include cluster role, taxonomy context, product attributes |
### 3. Validation Services
| Component | Status | Location | Notes |
|-----------|--------|----------|-------|
| **ContentValidationService** | ✅ Complete | `backend/igny8_core/business/content/services/validation_service.py` | Validates entity_type, cluster mappings, taxonomy mappings, attributes |
| **Validation API Endpoints** | ✅ Complete | `backend/igny8_core/modules/writer/views.py` | `GET /validation/` and `POST /validate/` endpoints |
| **Publish Validation** | ✅ Complete | `backend/igny8_core/business/content/services/validation_service.py` | `validate_for_publish()` returns structured errors |
### 4. Linker & Optimizer Enhancements
| Component | Status | Location | Notes |
|-----------|--------|----------|-------|
| **LinkerService** | ✅ Complete | `backend/igny8_core/business/linking/services/candidate_engine.py` | Prioritizes content from same clusters (+50 points), matches by taxonomy (+20), entity type (+15) |
| **OptimizerService** | ✅ Complete | `backend/igny8_core/business/optimization/services/analyzer.py` | Calculates metadata completeness score (0-100), includes in overall score (15% weight) |
| **DB Indexes** | ✅ Complete | `backend/igny8_core/business/content/models.py` | Indexes on `cluster`, `cluster_role`, `taxonomy`, `entity_type` |
### 5. API Additions
| Endpoint | Status | Location | Notes |
|----------|--------|----------|-------|
| **GET /api/v1/writer/content/{id}/validation/** | ✅ Complete | `backend/igny8_core/modules/writer/views.py` | Returns validation checklist with errors |
| **POST /api/v1/writer/content/{id}/validate/** | ✅ Complete | `backend/igny8_core/modules/writer/views.py` | Re-runs validators and returns actionable errors |
| **GET /api/v1/site-builder/blueprints/{id}/progress/** | ✅ Complete | `backend/igny8_core/modules/site_builder/views.py` | Returns cluster-level completion + validation flags |
---
## ✅ Frontend Implementation Status
### 1. Writer UI Enhancements
| Feature | Status | Location | Notes |
|---------|--------|----------|-------|
| **Metadata Columns** | ✅ Complete | `frontend/src/config/pages/content.config.tsx` | Added Entity Type, Cluster, Cluster Role, Taxonomy columns |
| **Entity Type Filter** | ✅ Complete | `frontend/src/config/pages/content.config.tsx` | Filter dropdown for entity types |
| **Validation Panel** | ✅ Complete | `frontend/src/pages/Sites/PostEditor.tsx` | Validation tab with errors, metadata summary, publish blockers |
| **Validation API Integration** | ✅ Complete | `frontend/src/services/api.ts` | `fetchContentValidation()` and `validateContent()` functions |
| **Publish Button Disabled** | ✅ Complete | `frontend/src/pages/Sites/PostEditor.tsx` | Publish button disabled when `validationResult.ready_to_publish` is false |
| **Sidebar Module** | ✅ Complete | `frontend/src/pages/Sites/PostEditor.tsx` | Sidebar displays metadata summary (entity_type, cluster_name, cluster_role, taxonomy_name), validation status, and quick links |
### 2. Linker UI Enhancements
| Feature | Status | Location | Notes |
|---------|--------|----------|-------|
| **Cluster Column** | ✅ Complete | `frontend/src/pages/Linker/ContentList.tsx` | Shows cluster name and role |
| **Group by Cluster Role** | ✅ Complete | `frontend/src/components/linker/LinkResults.tsx` | Link suggestions grouped by "High Priority (Cluster Match)" and "Other Suggestions" based on `cluster_match` |
| **Context Snippets** | ✅ Complete | `frontend/src/components/linker/LinkResults.tsx` | Displays `relevance_score` and `cluster_match` indicators for each link |
### 3. Optimizer UI Enhancements
| Feature | Status | Location | Notes |
|---------|--------|----------|-------|
| **Metadata Scorecard** | ✅ Complete | `frontend/src/components/optimizer/OptimizationScores.tsx` | Added metadata completeness score with indicators |
| **Cluster Dimension Scorecards** | ✅ Complete | `frontend/src/pages/Optimizer/AnalysisPreview.tsx` | Integrated `metadata_completeness_score` into optimization scores display |
| **Next Action Cards** | ✅ Complete | `frontend/src/pages/Optimizer/AnalysisPreview.tsx` | Added "Next Action" cards based on missing metadata (e.g., "Missing Cluster Mapping", "Missing Taxonomy Mapping", "Missing Attributes") |
### 4. Planner & Ideas UI Enhancements
| Feature | Status | Location | Notes |
|---------|--------|----------|-------|
| **Ideas List Metadata** | ✅ Complete | `frontend/src/config/pages/ideas.config.tsx` | Added `entity_type` and `cluster_role` columns to Ideas table |
| **Tasks List Metadata** | ✅ Complete | `frontend/src/config/pages/tasks.config.tsx` | Added `entity_type`, `cluster_role`, and `taxonomy_name` columns to Tasks table |
| **Metadata Filters** | ✅ Complete | `frontend/src/pages/Planner/Ideas.tsx`, `frontend/src/pages/Writer/Tasks.tsx` | Added `entity_type` filter to Ideas and Tasks pages |
### 5. Site Progress Widgets
| Feature | Status | Location | Notes |
|---------|--------|----------|-------|
| **Progress API Integration** | ✅ Complete | `backend/igny8_core/modules/site_builder/views.py` | Backend endpoint returns cluster-level completion |
| **Progress Widget UI** | ✅ Complete | `frontend/src/components/sites/SiteProgressWidget.tsx` | Widget displays overall status, cluster coverage progress bars, and detailed cluster list with roles, task counts, and completion status |
| **Deep Links** | ✅ Complete | `frontend/src/components/sites/SiteProgressWidget.tsx` | Links to blueprint workflow for incomplete blueprints and to individual clusters |
---
## 📊 Completion Summary
### Backend: ~100% Complete
**Completed:**
- ✅ Database migrations and backfill
- ✅ Pipeline updates (Ideas→Tasks→Content)
- ✅ Validation services and APIs
- ✅ Linker/Optimizer enhancements
- ✅ API endpoints
- ✅ Audit command
- ✅ DB indexes
- ✅ AI Prompts updated with Stage 3 metadata (cluster role, taxonomy, attributes)
**Remaining:**
- None
### Frontend: ~95% Complete
**Completed:**
- ✅ Writer Content list metadata columns
- ✅ Validation panel in PostEditor
- ✅ Publish button disabled when validation fails
- ✅ Writer Editor sidebar with metadata summary
- ✅ Linker cluster column
- ✅ Linker grouping by cluster role with context snippets
- ✅ Optimizer metadata scorecard
- ✅ Optimizer cluster dimension scorecards
- ✅ Optimizer next action cards
- ✅ Planner Ideas metadata columns and filters
- ✅ Planner Tasks metadata columns and filters
- ✅ Site progress widgets with deep links
- ✅ Validation API integration
**Remaining:**
- Minor UI polish and edge case handling
---
## 🧪 Testing Status
| Area | Automated | Manual | Status |
|------|-----------|--------|--------|
| **Pipeline** | ❌ Not Started | ✅ Tested | End-to-end: blueprint → ideas → tasks → content tested |
| **Validation** | ❌ Not Started | ✅ Tested | Validation endpoints tested via browser |
| **Linker/Optimizer** | ❌ Not Started | ⚠️ Partial | Services enhanced, but UI not fully tested |
| **Progress Widgets** | ❌ Not Started | ❌ Not Started | Backend API exists, frontend not implemented |
---
## 📋 Next Steps
### High Priority
1. **Testing** - Write unit tests for metadata persistence and E2E tests for validation flow
2. **Documentation** - Update user documentation for new metadata features
### Medium Priority
3. **UI Polish** - Refine UI/UX for metadata display and validation feedback
4. **Performance** - Optimize queries for metadata-heavy pages
### Low Priority
5. **Advanced Features** - Additional metadata visualization and reporting
6. **Integration Testing** - End-to-end testing of complete pipeline
---
## 🔧 Files Modified
### Backend
- `backend/igny8_core/business/content/models.py` - Added metadata fields to Tasks
- `backend/igny8_core/modules/writer/migrations/0013_stage3_add_task_metadata.py` - New migration
- `backend/igny8_core/modules/writer/migrations/0012_metadata_mapping_tables.py` - Updated backfill
- `backend/igny8_core/modules/planner/views.py` - Updated Ideas→Tasks pipeline
- `backend/igny8_core/business/site_building/services/page_generation_service.py` - Updated PageBlueprint→Tasks
- `backend/igny8_core/business/content/services/metadata_mapping_service.py` - New service
- `backend/igny8_core/business/content/services/validation_service.py` - New service
- `backend/igny8_core/business/linking/services/candidate_engine.py` - Enhanced with cluster matching
- `backend/igny8_core/business/optimization/services/analyzer.py` - Enhanced with metadata scoring
- `backend/igny8_core/modules/writer/views.py` - Added validation endpoints
- `backend/igny8_core/modules/site_builder/views.py` - Added progress endpoint
- `backend/igny8_core/modules/writer/management/commands/audit_site_metadata.py` - New command
- `backend/igny8_core/ai/prompts.py` - Updated content generation prompt to include cluster role, taxonomy context, product attributes
- `backend/igny8_core/ai/functions/generate_content.py` - Updated to build prompts with Stage 3 metadata context
### Frontend
- `frontend/src/services/api.ts` - Added Content metadata fields, validation APIs, SiteBlueprintProgress API
- `frontend/src/config/pages/content.config.tsx` - Added metadata columns and filters
- `frontend/src/config/pages/ideas.config.tsx` - Added entity_type and cluster_role columns
- `frontend/src/config/pages/tasks.config.tsx` - Added entity_type, cluster_role, and taxonomy_name columns
- `frontend/src/pages/Sites/PostEditor.tsx` - Added validation panel, publish button logic, and metadata sidebar
- `frontend/src/pages/Planner/Ideas.tsx` - Added entity_type filter
- `frontend/src/pages/Writer/Tasks.tsx` - Added entity_type filter
- `frontend/src/pages/Linker/ContentList.tsx` - Added cluster column
- `frontend/src/components/linker/LinkResults.tsx` - Added cluster grouping and context snippets
- `frontend/src/pages/Optimizer/AnalysisPreview.tsx` - Added metadata scorecards and next action cards
- `frontend/src/components/optimizer/OptimizationScores.tsx` - Added metadata scorecard
- `frontend/src/components/sites/SiteProgressWidget.tsx` - New component for site progress display
- `frontend/src/pages/Sites/Dashboard.tsx` - Integrated SiteProgressWidget
---
## 🎯 Stage 3 Objectives Status
| Objective | Backend | Frontend | Overall |
|-----------|---------|----------|---------|
| Metadata backfill | ✅ Complete | N/A | ✅ Complete |
| Ideas→Tasks pipeline | ✅ Complete | ✅ Complete | ✅ Complete |
| Tasks→Content pipeline | ✅ Complete | ✅ Complete | ✅ Complete |
| Validation services | ✅ Complete | ✅ Complete | ✅ Complete |
| Linker enhancements | ✅ Complete | ✅ Complete | ✅ Complete |
| Optimizer enhancements | ✅ Complete | ✅ Complete | ✅ Complete |
| API endpoints | ✅ Complete | ✅ Complete | ✅ Complete |
| Audit command | ✅ Complete | N/A | ✅ Complete |
| AI Prompts | ✅ Complete | N/A | ✅ Complete |
| Writer UI | N/A | ✅ Complete | ✅ Complete |
| Linker UI | N/A | ✅ Complete | ✅ Complete |
| Optimizer UI | N/A | ✅ Complete | ✅ Complete |
| Planner UI | N/A | ✅ Complete | ✅ Complete |
| Site Progress Widgets | ✅ Complete | ✅ Complete | ✅ Complete |
**Overall Stage 3: ~75% Complete**
---
## 🚀 Rollout Readiness
### Ready for Production
- ✅ Backend validation services
- ✅ Metadata mapping services
- ✅ API endpoints
- ✅ Database migrations and backfill
### Needs Work Before Production
- ⚠️ Testing coverage insufficient (unit tests and E2E tests needed)
- ⚠️ Documentation needs updates (user guides for new features)
- ✅ AI Prompts updated with Stage 3 metadata
- ✅ Frontend UI enhancements complete
---
*This document tracks the completion status of Stage 3 implementation. Update as features are completed.*