5.1 KiB
5.1 KiB
Content Lifecycle
Purpose
Trace content from keyword intake through clustering, idea generation, task creation, AI writing, image generation, and publishing/sync, mapping to backend services and frontend pages.
Code Locations (exact paths)
- Planner models:
backend/igny8_core/business/planning/models.py(Keywords,Clusters,ContentIdeas) - Writer models:
backend/igny8_core/business/content/models.py(Tasks,Content,Images,ContentTaxonomy) - ViewSets:
backend/igny8_core/modules/planner/views.py;backend/igny8_core/modules/writer/views.py - Automation orchestration:
backend/igny8_core/business/automation/services/automation_service.py; Celery tasksbusiness/automation/tasks.py - WordPress sync/publish:
backend/igny8_core/business/integration/services/integration_service.py,modules/integration/views.py - Frontend pages:
frontend/src/pages/Planner/*,frontend/src/pages/Writer/*,frontend/src/pages/Automation/AutomationPage.tsx,frontend/src/pages/Sites/*
High-Level Responsibilities
- Collect and cluster keywords, generate ideas, create tasks, generate content and images, then publish/sync.
- Support manual steps via Planner/Writer pages and automated runs via Automation pipeline.
- Maintain site/sector scoping and credit enforcement throughout AI operations.
Detailed Behavior
- Keywords → Clusters:
KeywordViewSet(upload/create) andClusterViewSet(manual or AI auto_cluster). Models inheritSiteSectorBaseModelfor scoping. - Clusters → ContentIdeas:
ContentIdeasViewSetwith AI generation endpoint; ideas track status. - Ideas/Tasks:
Tasksmodel holds brief/keywords/structure/status; created manually or by automation stage. - Tasks → Content: Writer endpoints generate content (AI) and update
Contentrecords; statuses managed in writer views. - Content → Images:
ImagesViewSethandles image generation and storage; images linked to tasks/content. - Publishing: Integration service sends content to WordPress via
/api/v1/integrationendpoints; WP plugin responds with IDs and syncs status back. - Automation:
automation_service.run_automationexecutes 7 stages with delays/retries/credit estimates; run status tracked inAutomationRun.
Data Structures / Models Involved (no code)
- Planner:
Keywords,Clusters,ContentIdeas. - Writer:
Tasks,Content,Images,ContentTaxonomy. - Automation:
AutomationConfig,AutomationRun. - Integration:
SiteIntegration.
Execution Flow
- Manual path: upload keywords → cluster (auto/manual) → generate ideas → create tasks → generate content → generate images → publish to WP → WP syncs status back.
- Automated path: Automation pipeline stages perform the same transitions in sequence, logging progress and deducting credits.
- Each stage uses DRF viewsets; automation uses Celery tasks (
run_automation_task,resume_automation_task) and logger for trace files.
Cross-Module Interactions
- Automation consumes planner/writer endpoints and triggers integration publish.
- Integration relies on site’s WP API key (
Site.wp_api_key) andSiteIntegrationconfig for credentials/URLs. - Billing deducts credits for AI operations through
CreditService.
State Transitions (if applicable)
- Keywords: status (active/inactive/used) per model.
- Clusters: status (active/archived).
- ContentIdeas: status (draft/approved/in_progress/completed).
- Tasks: status simplified (queued/completed) in Stage 1; content status (draft/published) and image status stored on related models.
- AutomationRun: status across run lifecycle (created/running/paused/completed/failed).
Error Handling
- Viewsets rely on unified DRF error responses; automation logger records failures per stage; Celery retries configured where applicable.
- WordPress sync errors surfaced via integration service responses.
Tenancy Rules
- All planner/writer/automation/integration models inherit account/site/sector via base models; viewsets filter by
request.accountand query params.
Billing Rules (if applicable)
- AI clustering/idea/content/image generation deduct credits via
CreditServicecost map; automation blocks run if estimated credits insufficient.
Background Tasks / Schedulers (if applicable)
- Automation scheduler:
check_scheduled_automationsenqueues runs;run_automation_task/resume_automation_taskexecute pipeline in Celery. - AI tasks run async via Celery wrappers (
ai/tasks.py).
Key Design Considerations
- Single source of truth for tenancy via base models; prevents cross-tenant data exposure.
- Automation mirrors manual flow; manual pages remain usable when automation is paused or disabled.
- WordPress publish/sync uses API key auth to avoid storing user credentials beyond site integration config.
How Developers Should Work With This Module
- When adding new content stages, update both manual endpoints and automation stages.
- Ensure every new action that calls AI is wired through
CreditServiceand respects site/sector filters. - For new publishing targets, extend
SiteIntegrationand integration service while keeping site/account scoping.