Add Linker and Optimizer modules with API integration and frontend components
- Added Linker and Optimizer apps to `INSTALLED_APPS` in `settings.py`. - Configured API endpoints for Linker and Optimizer in `urls.py`. - Implemented `OptimizeContentFunction` for content optimization in the AI module. - Created prompts for content optimization and site structure generation. - Updated `OptimizerService` to utilize the new AI function for content optimization. - Developed frontend components including dashboards and content lists for Linker and Optimizer. - Integrated new routes and sidebar navigation for Linker and Optimizer in the frontend. - Enhanced content management with source and sync status filters in the Writer module. - Comprehensive test coverage added for new features and components.
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
**Detailed Configuration Plan for Site Builder & Linker/Optimizer**
|
||||
|
||||
**Created**: 2025-01-XX
|
||||
**Status**: Phase 3 Complete ✅ | Phase 4 Backend Complete ✅ | Phase 4 Frontend Pending
|
||||
**Last Updated**: 2025-01-XX
|
||||
**Status**: Phase 3 Complete ✅ | Phase 4 Complete ✅
|
||||
|
||||
---
|
||||
|
||||
@@ -254,7 +255,7 @@
|
||||
- **Issue**: Incomplete mock state in `WizardPage.test.tsx`
|
||||
- **Fix**: Added complete `style` object with default values
|
||||
|
||||
### ✅ Phase 4: Linker & Optimizer - Backend Complete
|
||||
### ✅ Phase 4: Linker & Optimizer - COMPLETE
|
||||
|
||||
#### Backend Implementation
|
||||
|
||||
@@ -287,7 +288,73 @@
|
||||
- ✅ `process_writer_content()` - Full pipeline for Writer content
|
||||
- ✅ `process_synced_content()` - Optimization-only for synced content
|
||||
|
||||
**Note**: Phase 4 frontend UI (Linker Dashboard, Optimizer Dashboard) is **not yet implemented**.
|
||||
#### Frontend Implementation
|
||||
|
||||
**API Clients** (`frontend/src/api/`):
|
||||
- ✅ `linker.api.ts` - Linker API functions (`process`, `batchProcess`)
|
||||
- ✅ `optimizer.api.ts` - Optimizer API functions (`optimize`, `batchOptimize`, `analyze`)
|
||||
|
||||
**Shared Components** (`frontend/src/components/content/`):
|
||||
- ✅ `SourceBadge.tsx` - Displays content source (igny8, wordpress, shopify, custom)
|
||||
- ✅ `SyncStatusBadge.tsx` - Displays sync status (native, imported, synced)
|
||||
- ✅ `ContentFilter.tsx` - Filters content by source and sync status
|
||||
- ✅ `index.ts` - Barrel exports
|
||||
|
||||
**Linker Components** (`frontend/src/components/linker/`):
|
||||
- ✅ `LinkResults.tsx` - Displays linking results with links added count
|
||||
|
||||
**Optimizer Components** (`frontend/src/components/optimizer/`):
|
||||
- ✅ `OptimizationScores.tsx` - Displays optimization scores (SEO, readability, engagement, overall)
|
||||
- ✅ `ScoreComparison.tsx` - Compares before/after optimization scores
|
||||
|
||||
**Linker Pages** (`frontend/src/pages/Linker/`):
|
||||
- ✅ `Dashboard.tsx` - Linker dashboard with stats and quick actions
|
||||
- ✅ `ContentList.tsx` - Content list with link processing actions
|
||||
|
||||
**Optimizer Pages** (`frontend/src/pages/Optimizer/`):
|
||||
- ✅ `Dashboard.tsx` - Optimizer dashboard with stats and quick actions
|
||||
- ✅ `ContentSelector.tsx` - Content selector with batch optimization and filters
|
||||
- ✅ `AnalysisPreview.tsx` - Analysis preview page for content scores
|
||||
|
||||
**Routing & Navigation**:
|
||||
- ✅ Added Linker routes to `App.tsx` (`/linker`, `/linker/content`)
|
||||
- ✅ Added Optimizer routes to `App.tsx` (`/optimizer`, `/optimizer/content`, `/optimizer/analyze/:id`)
|
||||
- ✅ Updated `routes.config.ts` with Linker and Optimizer menu items
|
||||
- ✅ Added Linker and Optimizer to sidebar navigation menu (`AppSidebar.tsx`)
|
||||
|
||||
**Writer Integration**:
|
||||
- ✅ Added source and sync status columns to Writer Content table
|
||||
- ✅ Added source and sync status filters to Writer Content list
|
||||
- ✅ Added "Optimize" action to Writer content rows
|
||||
- ✅ Added "Send to Optimizer" action in Writer
|
||||
- ✅ Updated `content.config.tsx` with source and sync status columns and filters
|
||||
|
||||
**AI Function Created**:
|
||||
- ✅ `OptimizeContentFunction` (`ai/functions/optimize_content.py`)
|
||||
- Operation type: `optimize_content`
|
||||
- Credit cost: 1 credit per 200 words (from constants)
|
||||
- Optimizes content for SEO, readability, engagement
|
||||
- All phases implemented: INIT, PREP, AI_CALL, PARSE, SAVE, DONE
|
||||
- ✅ Added to AI registry (`ai/registry.py`)
|
||||
- ✅ Added prompt to `ai/prompts.py` (`optimize_content`)
|
||||
- ✅ Integrated into `OptimizerService._optimize_content()`
|
||||
|
||||
**API Layer Created** (`modules/linker/` and `modules/optimizer/`):
|
||||
- ✅ `LinkerViewSet` with actions:
|
||||
- `process/` (POST) - Process content for linking
|
||||
- `batch_process/` (POST) - Process multiple content items
|
||||
- ✅ `OptimizerViewSet` with actions:
|
||||
- `optimize/` (POST) - Optimize content (auto-detects entry point)
|
||||
- `batch_optimize/` (POST) - Batch optimize multiple content items
|
||||
- `analyze/` (POST) - Analyze content without optimizing
|
||||
- ✅ Serializers:
|
||||
- `LinkContentSerializer`, `BatchLinkContentSerializer`
|
||||
- `OptimizeContentSerializer`, `BatchOptimizeContentSerializer`, `AnalyzeContentSerializer`
|
||||
- ✅ URLs registered at `/api/v1/linker/` and `/api/v1/optimizer/`
|
||||
- ✅ Added to `INSTALLED_APPS` in `settings.py`
|
||||
- ✅ Throttle rates configured: `linker: 30/min`, `optimizer: 10/min`
|
||||
|
||||
**Note**: Phase 4 frontend UI is **now complete** ✅
|
||||
|
||||
### 📋 Files Created/Modified
|
||||
|
||||
@@ -325,16 +392,39 @@
|
||||
- `backend/igny8_core/business/site_building/tests/base.py`
|
||||
- `backend/igny8_core/business/site_building/tests/test_services.py`
|
||||
- `backend/igny8_core/ai/tests/test_generate_site_structure_function.py`
|
||||
- `backend/igny8_core/business/linking/tests/__init__.py`
|
||||
- `backend/igny8_core/business/linking/tests/test_linker_service.py`
|
||||
- `backend/igny8_core/business/linking/tests/test_candidate_engine.py`
|
||||
- `backend/igny8_core/business/linking/tests/test_injection_engine.py`
|
||||
- `backend/igny8_core/business/optimization/tests/__init__.py`
|
||||
- `backend/igny8_core/business/optimization/tests/test_optimizer_service.py`
|
||||
- `backend/igny8_core/business/optimization/tests/test_analyzer.py`
|
||||
- `backend/igny8_core/business/content/tests/__init__.py`
|
||||
- `backend/igny8_core/business/content/tests/test_content_pipeline_service.py`
|
||||
- `backend/igny8_core/business/billing/tests/__init__.py`
|
||||
- `backend/igny8_core/business/billing/tests/test_phase4_credits.py`
|
||||
- `backend/igny8_core/modules/linker/tests/__init__.py`
|
||||
- `backend/igny8_core/modules/linker/tests/test_views.py`
|
||||
- `backend/igny8_core/modules/optimizer/tests/__init__.py`
|
||||
- `backend/igny8_core/modules/optimizer/tests/test_views.py`
|
||||
- `backend/igny8_core/ai/functions/tests/__init__.py`
|
||||
- `backend/igny8_core/ai/functions/tests/test_optimize_content.py`
|
||||
|
||||
#### Backend Files Modified
|
||||
|
||||
- `backend/igny8_core/settings.py` - Added Site Builder apps to `INSTALLED_APPS`
|
||||
- `backend/igny8_core/urls.py` - Added Site Builder URL routing
|
||||
- `backend/igny8_core/ai/registry.py` - Registered `GenerateSiteStructureFunction`
|
||||
- `backend/igny8_core/ai/prompts.py` - Added `site_structure_generation` prompt
|
||||
- `backend/igny8_core/settings.py` - Added Site Builder, Linker, Optimizer apps to `INSTALLED_APPS`; Added throttle rates
|
||||
- `backend/igny8_core/urls.py` - Added Site Builder, Linker, Optimizer URL routing
|
||||
- `backend/igny8_core/ai/registry.py` - Registered `GenerateSiteStructureFunction` and `OptimizeContentFunction`
|
||||
- `backend/igny8_core/ai/prompts.py` - Added `site_structure_generation` and `optimize_content` prompts
|
||||
- `backend/igny8_core/ai/engine.py` - Integrated site structure generation
|
||||
- `backend/igny8_core/business/content/models.py` - Added Phase 4 fields
|
||||
- `backend/igny8_core/business/optimization/services/optimizer_service.py` - Updated `_optimize_content()` to use AI function
|
||||
- `backend/igny8_core/modules/writer/serializers.py` - Fixed `Content.DoesNotExist` handling
|
||||
- `frontend/src/App.tsx` - Added Linker and Optimizer routes
|
||||
- `frontend/src/config/routes.config.ts` - Added Linker and Optimizer menu items
|
||||
- `frontend/src/layout/AppSidebar.tsx` - Added Linker and Optimizer to sidebar navigation
|
||||
- `frontend/src/config/pages/content.config.tsx` - Added source and sync status columns and filters
|
||||
- `frontend/src/pages/Writer/Content.tsx` - Added optimize action, source/sync filters
|
||||
|
||||
#### Frontend Files Created
|
||||
|
||||
@@ -375,6 +465,13 @@
|
||||
- `site-builder/src/state/__tests__/siteDefinitionStore.test.ts`
|
||||
- `site-builder/src/pages/wizard/__tests__/WizardPage.test.tsx`
|
||||
- `site-builder/src/pages/preview/__tests__/PreviewCanvas.test.tsx`
|
||||
- `frontend/src/components/content/__tests__/SourceBadge.test.tsx`
|
||||
- `frontend/src/components/content/__tests__/SyncStatusBadge.test.tsx`
|
||||
- `frontend/src/components/content/__tests__/ContentFilter.test.tsx`
|
||||
- `frontend/src/pages/Linker/__tests__/Dashboard.test.tsx`
|
||||
- `frontend/src/pages/Linker/__tests__/ContentList.test.tsx`
|
||||
- `frontend/src/pages/Optimizer/__tests__/Dashboard.test.tsx`
|
||||
- `frontend/src/pages/Optimizer/__tests__/ContentSelector.test.tsx`
|
||||
|
||||
**Shared Component Library**:
|
||||
- `frontend/src/components/shared/blocks/HeroBlock.tsx`
|
||||
@@ -392,6 +489,22 @@
|
||||
- `frontend/src/components/shared/index.ts`
|
||||
- `frontend/src/components/shared/README.md`
|
||||
|
||||
**Phase 4 Frontend Components**:
|
||||
- `frontend/src/api/linker.api.ts`
|
||||
- `frontend/src/api/optimizer.api.ts`
|
||||
- `frontend/src/components/content/SourceBadge.tsx`
|
||||
- `frontend/src/components/content/SyncStatusBadge.tsx`
|
||||
- `frontend/src/components/content/ContentFilter.tsx`
|
||||
- `frontend/src/components/content/index.ts`
|
||||
- `frontend/src/components/linker/LinkResults.tsx`
|
||||
- `frontend/src/components/optimizer/OptimizationScores.tsx`
|
||||
- `frontend/src/components/optimizer/ScoreComparison.tsx`
|
||||
- `frontend/src/pages/Linker/Dashboard.tsx`
|
||||
- `frontend/src/pages/Linker/ContentList.tsx`
|
||||
- `frontend/src/pages/Optimizer/Dashboard.tsx`
|
||||
- `frontend/src/pages/Optimizer/ContentSelector.tsx`
|
||||
- `frontend/src/pages/Optimizer/AnalysisPreview.tsx`
|
||||
|
||||
#### Infrastructure Files Modified
|
||||
|
||||
- `docker-compose.app.yml` - Added `igny8_site_builder` service
|
||||
@@ -412,41 +525,53 @@
|
||||
- [ ] Add page editor for manual block editing
|
||||
- [ ] Add template selection in wizard
|
||||
|
||||
#### Phase 4 - Frontend UI
|
||||
- [ ] Create Linker Dashboard (`frontend/src/pages/Linker/Dashboard.tsx`)
|
||||
- [ ] Create Linker Content List (`frontend/src/pages/Linker/ContentList.tsx`)
|
||||
- [ ] Create Optimizer Dashboard (`frontend/src/pages/Optimizer/Dashboard.tsx`)
|
||||
- [ ] Create Optimizer Content Selector (`frontend/src/pages/Optimizer/ContentSelector.tsx`)
|
||||
- [ ] Create shared components:
|
||||
- [ ] `SourceBadge.tsx` - Display content source
|
||||
- [ ] `SyncStatusBadge.tsx` - Display sync status
|
||||
- [ ] `ContentFilter.tsx` - Filter by source/sync_status
|
||||
- [ ] Update Writer content list to show source badges
|
||||
- [ ] Add "Send to Optimizer" button in Writer
|
||||
#### Phase 4 - COMPLETE ✅
|
||||
|
||||
#### Phase 4 - AI Function
|
||||
- [ ] Create `OptimizeContentFunction` (`ai/functions/optimize_content.py`)
|
||||
- [ ] Add optimization prompts to `ai/prompts.py`
|
||||
- [ ] Register function in `ai/registry.py`
|
||||
- [ ] Integrate into `ai/engine.py`
|
||||
**All Phase 4 implementation tasks completed in this session:**
|
||||
|
||||
#### Phase 4 - API Layer
|
||||
- [ ] Create `modules/linker/` module with ViewSet
|
||||
- [ ] Create `modules/optimizer/` module with ViewSet
|
||||
- [ ] Register URLs for Linker and Optimizer APIs
|
||||
**Backend**:
|
||||
- ✅ AI Function (`OptimizeContentFunction`) created and integrated
|
||||
- ✅ Linker API module (`modules/linker/`) with ViewSet, serializers, URLs
|
||||
- ✅ Optimizer API module (`modules/optimizer/`) with ViewSet, serializers, URLs
|
||||
- ✅ Settings and URL routing configured
|
||||
- ✅ 10 backend test files created (70+ test cases)
|
||||
|
||||
**Frontend**:
|
||||
- ✅ API clients (`linker.api.ts`, `optimizer.api.ts`)
|
||||
- ✅ Shared components (SourceBadge, SyncStatusBadge, ContentFilter, LinkResults, OptimizationScores, ScoreComparison)
|
||||
- ✅ Linker pages (Dashboard, ContentList)
|
||||
- ✅ Optimizer pages (Dashboard, ContentSelector, AnalysisPreview)
|
||||
- ✅ Writer integration (source badges, filters, optimize actions)
|
||||
- ✅ Routing and navigation (routes, sidebar menu)
|
||||
- ✅ 7 frontend test files created (30+ test cases)
|
||||
|
||||
**Summary**: Phase 4 is 100% complete with all backend services, AI functions, API endpoints, frontend UI, and comprehensive test coverage.
|
||||
|
||||
### 📊 Implementation Statistics
|
||||
|
||||
- **Backend Files Created**: 25+
|
||||
- **Frontend Files Created**: 30+
|
||||
- **Backend Tests**: 3 test files, 10+ test cases
|
||||
- **Frontend Tests**: 4 test files, 15+ test cases
|
||||
- **Lines of Code**: ~5,000+ (backend + frontend)
|
||||
- **Backend Files Created**: 40+
|
||||
- **Frontend Files Created**: 45+
|
||||
- **Backend Tests**: 13 test files, 70+ test cases
|
||||
- **Frontend Tests**: 11 test files, 30+ test cases
|
||||
- **Lines of Code**: ~8,000+ (backend + frontend)
|
||||
- **Docker Containers**: 1 new container (`igny8_site_builder`)
|
||||
- **API Endpoints**: 10+ new endpoints
|
||||
- **API Endpoints**: 15+ new endpoints
|
||||
- **Database Tables**: 2 new tables (`SiteBlueprint`, `PageBlueprint`)
|
||||
- **Migrations**: 2 migrations created and applied
|
||||
|
||||
#### Phase 4 Statistics (This Session)
|
||||
- **Backend Files Created**: 15+
|
||||
- AI Function: 1 file
|
||||
- API Modules: 6 files (linker + optimizer)
|
||||
- Test Files: 10 files
|
||||
- **Frontend Files Created**: 20+
|
||||
- API Clients: 2 files
|
||||
- Components: 6 files
|
||||
- Pages: 5 files
|
||||
- Test Files: 7 files
|
||||
- **Backend Test Cases**: 70+ individual test methods
|
||||
- **Frontend Test Cases**: 30+ individual test methods
|
||||
|
||||
---
|
||||
|
||||
## OVERVIEW
|
||||
@@ -968,46 +1093,50 @@ frontend/src/components/
|
||||
- [x] Integrate with `CreditService`
|
||||
|
||||
4. **Create AI Function**
|
||||
- [ ] Create `OptimizeContentFunction`
|
||||
- [ ] Add optimization prompts
|
||||
- [ ] Test AI function
|
||||
- [x] Create `OptimizeContentFunction`
|
||||
- [x] Add optimization prompts
|
||||
- [x] Test AI function
|
||||
|
||||
5. **Create Pipeline Service**
|
||||
- [x] Create `ContentPipelineService`
|
||||
- [x] Integrate Linker and Optimizer
|
||||
|
||||
6. **Create API Layer**
|
||||
- [ ] Create `modules/linker/` folder
|
||||
- [ ] Create `LinkerViewSet`
|
||||
- [ ] Create `modules/optimizer/` folder
|
||||
- [ ] Create `OptimizerViewSet`
|
||||
- [ ] Create serializers
|
||||
- [ ] Register URLs
|
||||
- [x] Create `modules/linker/` folder
|
||||
- [x] Create `LinkerViewSet`
|
||||
- [x] Create `modules/optimizer/` folder
|
||||
- [x] Create `OptimizerViewSet`
|
||||
- [x] Create serializers
|
||||
- [x] Register URLs
|
||||
|
||||
#### Frontend Tasks (Priority Order)
|
||||
|
||||
1. **Create Linker UI**
|
||||
- [ ] Linker Dashboard
|
||||
- [ ] Content List
|
||||
- [ ] Link Results display
|
||||
- [x] Linker Dashboard
|
||||
- [x] Content List
|
||||
- [x] Link Results display
|
||||
|
||||
2. **Create Optimizer UI**
|
||||
- [ ] Optimizer Dashboard
|
||||
- [ ] Content Selector (with source filters)
|
||||
- [ ] Optimization Results
|
||||
- [ ] Score Comparison
|
||||
- [x] Optimizer Dashboard
|
||||
- [x] Content Selector (with source filters)
|
||||
- [x] Optimization Results
|
||||
- [x] Score Comparison
|
||||
- [x] Analysis Preview
|
||||
|
||||
3. **Create Shared Components**
|
||||
- [ ] SourceBadge component
|
||||
- [ ] SyncStatusBadge component
|
||||
- [ ] ContentFilter component
|
||||
- [ ] SourceFilter component
|
||||
- [x] SourceBadge component
|
||||
- [x] SyncStatusBadge component
|
||||
- [x] ContentFilter component
|
||||
- [x] LinkResults component
|
||||
- [x] OptimizationScores component
|
||||
- [x] ScoreComparison component
|
||||
|
||||
4. **Update Content List**
|
||||
- [ ] Add source badges
|
||||
- [ ] Add sync status badges
|
||||
- [ ] Add filters (by source, sync_status)
|
||||
- [ ] Add "Send to Optimizer" button
|
||||
- [x] Add source badges
|
||||
- [x] Add sync status badges
|
||||
- [x] Add filters (by source, sync_status)
|
||||
- [x] Add "Optimize" action button
|
||||
- [x] Add "Send to Optimizer" action
|
||||
|
||||
---
|
||||
|
||||
@@ -1202,20 +1331,31 @@ site-builder/src/ # Phase 3 NEW
|
||||
- Test file browser
|
||||
- Test component library
|
||||
|
||||
### Phase 4 Testing
|
||||
### Phase 4 Testing ✅ COMPLETE
|
||||
|
||||
1. **Backend Tests**
|
||||
- Test Content model extensions
|
||||
- Test LinkerService (find candidates, inject links)
|
||||
- Test OptimizerService (all entry points)
|
||||
- Test ContentPipelineService
|
||||
- Test credit deduction
|
||||
1. **Backend Tests** ✅
|
||||
- ✅ Test Content model extensions (via service tests)
|
||||
- ✅ Test LinkerService (`test_linker_service.py` - 8 test cases)
|
||||
- ✅ Test CandidateEngine (`test_candidate_engine.py` - 6 test cases)
|
||||
- ✅ Test InjectionEngine (`test_injection_engine.py` - 6 test cases)
|
||||
- ✅ Test OptimizerService (`test_optimizer_service.py` - 10 test cases)
|
||||
- ✅ Test ContentAnalyzer (`test_analyzer.py` - 8 test cases)
|
||||
- ✅ Test ContentPipelineService (`test_content_pipeline_service.py` - 10 test cases)
|
||||
- ✅ Test credit deduction (`test_phase4_credits.py` - 8 test cases)
|
||||
- ✅ Test Linker API endpoints (`test_views.py` - 9 test cases)
|
||||
- ✅ Test Optimizer API endpoints (`test_views.py` - 10 test cases)
|
||||
- ✅ Test OptimizeContentFunction (`test_optimize_content.py` - 10 test cases)
|
||||
- **Total**: 10 test files, 85+ test cases
|
||||
|
||||
2. **Frontend Tests**
|
||||
- Test Linker UI
|
||||
- Test Optimizer UI
|
||||
- Test source filtering
|
||||
- Test content selection
|
||||
2. **Frontend Tests** ✅
|
||||
- ✅ Test SourceBadge component (`SourceBadge.test.tsx`)
|
||||
- ✅ Test SyncStatusBadge component (`SyncStatusBadge.test.tsx`)
|
||||
- ✅ Test ContentFilter component (`ContentFilter.test.tsx`)
|
||||
- ✅ Test Linker Dashboard (`Dashboard.test.tsx`)
|
||||
- ✅ Test Linker ContentList (`ContentList.test.tsx`)
|
||||
- ✅ Test Optimizer Dashboard (`Dashboard.test.tsx`)
|
||||
- ✅ Test Optimizer ContentSelector (`ContentSelector.test.tsx`)
|
||||
- **Total**: 7 test files, 30+ test cases
|
||||
|
||||
### Integration Tests
|
||||
|
||||
@@ -1263,6 +1403,14 @@ site-builder/src/ # Phase 3 NEW
|
||||
- ✅ Content source tracking works
|
||||
- ✅ Pipeline orchestrates correctly
|
||||
- ✅ UI shows content sources and filters
|
||||
- ✅ API endpoints functional and tested
|
||||
- ✅ AI function integrated and working
|
||||
- ✅ Credit deduction working at all stages
|
||||
- ✅ Frontend UI complete with all dashboards and selectors
|
||||
- ✅ Writer integration complete with badges and filters
|
||||
- ✅ Navigation and routing complete
|
||||
- ✅ Backend tests complete (10 test files)
|
||||
- ✅ Frontend tests complete (7 test files)
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user