38 KiB
IGNY8 Backend Implementation Reference
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.
Table of Contents
- Backend Overview
- Tech Stack
- Project Structure
- Models
- ViewSets
- Serializers
- Celery Tasks
- API Endpoints
- Base Classes
- Middleware
- Utilities
- Modules
Backend Overview
The IGNY8 backend is a Django 5.2+ application using Django REST Framework (DRF) for API endpoints. The backend follows a modular architecture with clear separation of concerns, automatic account isolation, and support for asynchronous task processing via Celery.
Key Features
- Multi-Tenancy: Complete account isolation with automatic filtering
- RESTful API: DRF ViewSets with consistent response format
- Celery Integration: Asynchronous task processing for long-running operations
- Account/Site/Sector Hierarchy: Hierarchical data organization
- AI Integration: Unified AI framework for all AI operations
- Progress Tracking: Real-time progress updates for Celery tasks
Tech Stack
Core Technologies
- Django 5.2+: Web framework
- Django REST Framework: API framework
- PostgreSQL: Database
- Celery: Asynchronous task queue
- Redis: Celery broker and caching
Key Libraries
- django-filter: Advanced filtering
- djangorestframework-simplejwt: JWT authentication
- requests: HTTP client for external APIs
- python-dotenv: Environment variable management
Project Structure
backend/igny8_core/
├── auth/ # Multi-tenancy and authentication
│ ├── models.py # Account, User, Plan, Site, Sector, Industry models
│ ├── views.py # Account, User, Site, Sector ViewSets
│ ├── serializers.py # Account, User, Plan serializers
│ └── urls.py # Auth module URLs
├── modules/ # Feature modules
│ ├── planner/ # Keywords, Clusters, Ideas
│ │ ├── views.py # KeywordViewSet, ClusterViewSet, ContentIdeasViewSet
│ │ ├── serializers.py # Model serializers
│ │ └── urls.py # Planner module URLs
│ ├── writer/ # Tasks, Content, Images
│ │ ├── views.py # TasksViewSet, ContentViewSet, ImagesViewSet
│ │ ├── serializers.py # Model serializers
│ │ └── 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
│ │ ├── models.py # AIPrompt, IntegrationSettings, AuthorProfile, Strategy
│ │ ├── views.py # AIPromptViewSet, AuthorProfileViewSet
│ │ ├── settings_views.py # SystemSettingsViewSet, AccountSettingsViewSet
│ │ ├── integration_views.py # IntegrationSettingsViewSet, task_progress
│ │ ├── utils.py # Default prompts, prompt loading
│ │ └── urls.py # System module URLs
│ └── billing/ # Credits, Transactions, Usage
│ ├── views.py # CreditTransactionViewSet, CreditBalanceViewSet, CreditUsageViewSet
│ ├── 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
│ ├── base.py # AccountModelViewSet, SiteSectorModelViewSet
│ └── pagination.py # CustomPageNumberPagination
├── utils/ # Shared utilities
│ ├── ai_processor.py # Unified AI interface (legacy, see AI functions)
│ └── content_normalizer.py # Content processing utilities
├── middleware/ # Custom middleware
│ ├── account.py # AccountContextMiddleware (sets request.account)
│ └── resource_tracker.py # ResourceTrackerMiddleware (API metrics)
├── ai/ # AI framework
│ ├── base.py # BaseAIFunction
│ ├── engine.py # AIEngine
│ ├── tasks.py # run_ai_task
│ ├── registry.py # Function registry
│ ├── prompts.py # PromptRegistry
│ ├── ai_core.py # AICore
│ ├── settings.py # Model configuration
│ ├── validators.py # Validation functions
│ ├── tracker.py # Progress tracking
│ └── functions/ # AI function implementations
│ ├── auto_cluster.py
│ ├── generate_ideas.py
│ ├── generate_content.py
│ ├── generate_image_prompts.py
│ └── generate_images.py
├── settings.py # Django settings
├── urls.py # Root URL configuration
└── celery.py # Celery configuration
Models
Base Models
AccountBaseModel
File: auth/models.py
Purpose: Base model for all account-isolated models.
Fields:
account: ForeignKey to Accountcreated_at: DateTimeField (auto_now_add)updated_at: DateTimeField (auto_now)
Usage: All models that need account isolation inherit from this.
SiteSectorBaseModel
File: auth/models.py
Purpose: Base model for models that belong to Site and Sector.
Fields:
- Inherits from
AccountBaseModel site: ForeignKey to Sitesector: ForeignKey to Sector
Methods:
save(): Automatically setsaccountfromsite.accountand validates sector belongs to site
Usage: Models like Keywords, Clusters, ContentIdeas, Tasks inherit from this.
Auth Models
Account
Table: igny8_accounts
Fields:
name: CharFieldslug: SlugField (unique)owner: ForeignKey to Userplan: ForeignKey to Plancredits: IntegerField (default: 0)status: CharField (choices: active, suspended, trial, cancelled)
Methods:
is_system_account(): Returns True if account is a system account
User
Table: igny8_users
Inherits: AbstractUser
Fields:
email: EmailField (unique)account: ForeignKey to Accountrole: CharField (choices: developer, owner, admin, editor, viewer, system_bot)
Methods:
has_role(role): Checks if user has roleis_owner_or_admin(): Checks if user is owner or adminis_developer(): Checks if user is developeris_admin_or_developer(): Checks if user is admin or developeris_system_account_user(): Checks if user belongs to system accountget_accessible_sites(): Returns queryset of accessible sites
Plan
Table: igny8_plans
Fields: Extensive fields for limits (users, sites, keywords, clusters, content ideas, AI requests, word count, images, credits)
Methods:
clean(): Validates plan limitsget_effective_credits_per_month(): Returns included_credits or credits_per_month
Site
Table: igny8_sites
Inherits: AccountBaseModel
Fields:
name: CharFieldslug: SlugField (unique per account)domain: URLField (optional)industry: ForeignKey to Industry (optional)is_active: BooleanFieldstatus: CharFieldwp_url: URLField (optional)wp_username: CharField (optional)wp_app_password: CharField (optional)
Methods:
get_active_sectors_count(): Returns count of active sectorscan_add_sector(): Returns True if site can add another sector (max 5)
Sector
Table: igny8_sectors
Inherits: AccountBaseModel
Fields:
site: ForeignKey to Siteindustry_sector: ForeignKey to IndustrySector (optional)name: CharFieldslug: SlugField (unique per site)is_active: BooleanFieldstatus: CharField
Validation: Maximum 5 active sectors per site
Planner Models
Keywords
Table: igny8_keywords
Inherits: SiteSectorBaseModel
Fields:
keyword: CharFieldvolume: IntegerField (optional)difficulty: IntegerField (optional)intent: CharField (optional)status: CharFieldcluster: ManyToManyField to Clusters
Clusters
Table: igny8_clusters
Inherits: SiteSectorBaseModel
Fields:
name: CharFielddescription: TextField (optional)keywords_count: IntegerField (calculated)volume: IntegerField (calculated)status: CharFieldkeywords: ManyToManyField to Keywords
ContentIdeas
Table: igny8_content_ideas
Inherits: SiteSectorBaseModel
Fields:
idea_title: CharFielddescription: TextFieldcontent_type: CharFieldcontent_structure: CharFieldtarget_keywords: TextFieldkeyword_cluster: ForeignKey to Clustersestimated_word_count: IntegerFieldstatus: CharField
Writer Models
Tasks
Table: igny8_tasks
Inherits: SiteSectorBaseModel
Fields:
title: CharFielddescription: TextFieldcluster: ForeignKey to Clusters (optional)idea: ForeignKey to ContentIdeas (optional)content_type: CharFieldcontent_structure: CharFieldstatus: CharField
Content
Table: igny8_content
Inherits: SiteSectorBaseModel
Fields:
task: OneToOneField to Taskshtml_content: TextFieldword_count: IntegerFieldstatus: CharFieldwp_post_id: IntegerField (optional)meta_title: CharField (optional)meta_description: TextField (optional)primary_keyword: CharField (optional)secondary_keywords: TextField (optional)
Images
Table: igny8_images
Inherits: SiteSectorBaseModel
Fields:
task: ForeignKey to Tasks (optional)content: ForeignKey to Content (optional)image_type: CharField (choices: featured, in_article, desktop, mobile)prompt: TextFieldimage_url: CharFieldstatus: CharField
System Models
AIPrompt
Table: igny8_ai_prompts
Inherits: AccountBaseModel
Fields:
prompt_type: CharFieldprompt_value: TextFieldfunction_name: CharField (optional)
IntegrationSettings
Table: igny8_integration_settings
Inherits: AccountBaseModel
Fields:
integration_type: CharField (choices: openai, runware, image_generation)config: JSONField
AuthorProfile
Table: igny8_author_profiles
Inherits: AccountBaseModel
Fields:
name: CharFielddescription: TextFieldtone: CharFieldlanguage: CharField
Strategy
Table: igny8_strategies
Inherits: AccountBaseModel
Fields:
name: CharFielddescription: TextFieldsector: ForeignKey to Sector (optional)prompt_types: JSONFieldsection_logic: JSONFieldis_active: BooleanField
Billing Models
CreditTransaction
Table: igny8_credit_transactions
Inherits: AccountBaseModel
Fields:
transaction_type: CharField (choices: purchase, usage, refund, adjustment)amount: IntegerFieldbalance_after: IntegerFielddescription: TextField (optional)
CreditUsageLog
Table: igny8_credit_usage_logs
Inherits: AccountBaseModel
Fields:
operation_type: CharFieldcredits_used: IntegerFieldcost_usd: DecimalFielddetails: JSONField (optional)
ViewSets
Base ViewSets
AccountModelViewSet
File: api/base.py
Purpose: Base ViewSet with automatic account filtering.
Methods:
get_queryset(): Filters queryset byrequest.account(with admin/developer override)perform_create(): Sets account on created objectsget_serializer_context(): Adds account to serializer context
Access Control:
- Admin/Developer users: Bypass account filtering
- System account users: Bypass account filtering
- Regular users: Only see data from their account
SiteSectorModelViewSet
File: api/base.py
Purpose: Base ViewSet with site/sector filtering and access control.
Inherits: AccountModelViewSet
Methods:
get_queryset(): Filters by account, accessible sites, and optional site_id/sector_idperform_create(): Validates site access and sector-site relationshipget_serializer_context(): Adds accessible sites and sectors to context
Access Control:
- Developers: All active sites
- System account users: All active sites
- Owners/Admins: All sites in their account
- Editors/Viewers: Only sites granted via
SiteUserAccess
Planner ViewSets
KeywordViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List keywords with filteringcreate(): Create keywordretrieve(): Get keyword detailsupdate(): Update keyworddestroy(): Delete keywordauto_cluster(): Auto-cluster keywords using AIbulk_delete(): Bulk delete keywordsbulk_update_status(): Bulk update keyword statusexport_csv(): Export keywords to CSVimport_csv(): Import keywords from CSV
Filtering:
- Search:
keywordfield - Filters:
status,cluster_id,intent - Custom:
difficulty_min,difficulty_max,volume_min,volume_max - Ordering:
created_at,volume,difficulty
ClusterViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List clusterscreate(): Create clusterretrieve(): Get cluster detailsupdate(): Update clusterdestroy(): Delete clusterauto_generate_ideas(): Auto-generate content ideas for clusters
ContentIdeasViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List content ideascreate(): Create content idearetrieve(): Get content idea detailsupdate(): Update content ideadestroy(): Delete content idea
Writer ViewSets
TasksViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List taskscreate(): Create taskretrieve(): Get task detailsupdate(): Update taskdestroy(): Delete taskauto_generate_content(): Auto-generate content for tasksgenerate_images(): Generate images for image recordsbulk_delete(): Bulk delete tasksbulk_update(): Bulk update task status
Filtering:
- Search:
title,keywords - Filters:
status,cluster_id,content_type,content_structure - Ordering:
title,created_at,word_count,status
ContentViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List contentcreate(): Create contentretrieve(): Get content detailsupdate(): Update contentdestroy(): Delete contentpublish_to_wordpress(): Publish content to WordPress
ImagesViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List imagescreate(): Create imageretrieve(): Get image detailsupdate(): Update imagedestroy(): Delete imagegenerate_images(): Generate images using AI
Linker ViewSets
LinkerViewSet
Inherits: viewsets.ViewSet
Actions:
process(): Process a single content item for internal linkingbatch_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 itemsanalyze(): Analyze content without optimization
Purpose: Content optimization and scoring
Publisher ViewSets
PublishingRecordViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List publishing recordscreate(): Create publishing recordretrieve(): Get publishing record detailsupdate(): Update publishing recorddestroy(): Delete publishing record
DeploymentRecordViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List deployment recordscreate(): Create deployment recordretrieve(): Get deployment record detailsupdate(): Update deployment recorddestroy(): Delete deployment record
PublisherViewSet
Inherits: viewsets.ViewSet
Actions:
publish(): Publish content to destinationdeploy(): Deploy site blueprintcheck_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 blueprintscreate(): Create site blueprintretrieve(): Get site blueprint detailsupdate(): Update site blueprintdestroy(): Delete site blueprintgenerate_structure(): Generate site structure using AIgenerate_all_pages(): Generate all pages for blueprintcreate_tasks(): Create Writer tasks for pagesprogress(): Get cluster-level completion statusattach_clusters(): Attach planner clusters to blueprintdetach_clusters(): Detach clusters from blueprintlist_taxonomies(): List taxonomies for blueprintcreate_taxonomy(): Create taxonomy for blueprintimport_taxonomies(): Import taxonomies from external sourcebulk_delete(): Bulk delete blueprints
PageBlueprintViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List page blueprintscreate(): Create page blueprintretrieve(): Get page blueprint detailsupdate(): Update page blueprintdestroy(): Delete page blueprintgenerate_content(): Generate content for pageregenerate(): Regenerate page content
SiteAssetView
Inherits: APIView
Actions:
GET: List files for sitePOST: Upload fileDELETE: 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 rulescreate(): Create automation ruleretrieve(): Get automation rule detailsupdate(): Update automation ruledestroy(): Delete automation ruleexecute(): Manually execute automation rule
ScheduledTaskViewSet
Inherits: AccountModelViewSet
Actions:
list(): List scheduled taskscreate(): Create scheduled taskretrieve(): Get scheduled task detailsupdate(): Update scheduled taskdestroy(): Delete scheduled task
Integration ViewSets
IntegrationViewSet
Inherits: SiteSectorModelViewSet
Actions:
list(): List site integrationscreate(): Create site integrationretrieve(): Get integration detailsupdate(): Update integrationdestroy(): Delete integrationtest_connection(): Test connection to integrated platformsync(): Sync content with integrated platformsync_health(): Check sync health status
System ViewSets
IntegrationSettingsViewSet
Inherits: viewsets.ViewSet
Actions:
list(): List integrationsretrieve(): Get integration settingsupdate(): Save integration settingssave_post(): Save integration settings (POST)test_connection(): Test API connectiontest_openai(): Test OpenAI connectiontest_runware(): Test Runware connectiongenerate_image(): Test image generationtask_progress(): Get Celery task progress
AIPromptViewSet
Inherits: AccountModelViewSet
Actions:
list(): List promptscreate(): Create promptretrieve(): Get prompt detailsupdate(): Update promptdestroy(): Delete promptreset_to_default(): Reset prompt to default value
AuthorProfileViewSet
Inherits: AccountModelViewSet
Actions:
list(): List author profilescreate(): Create author profileretrieve(): Get author profile detailsupdate(): Update author profiledestroy(): Delete author profile
Serializers
Planner Serializers
KeywordSerializer
Fields: All Keyword model fields
Validation: Validates keyword uniqueness, cluster belongs to same sector
ClusterSerializer
Fields: All Cluster model fields
Read-Only Fields: keywords_count, volume (calculated)
ContentIdeasSerializer
Fields: All ContentIdeas model fields
Writer Serializers
TasksSerializer
Fields: All Tasks model fields
ContentSerializer
Fields: All Content model fields
ImagesSerializer
Fields: All Images model fields
System Serializers
AIPromptSerializer
Fields: All AIPrompt model fields
IntegrationSettingsSerializer
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
AI Task Entry Point
run_ai_task
File: ai/tasks.py
Purpose: Unified Celery task entrypoint for all AI functions
Parameters:
function_name: Function name (e.g., 'auto_cluster')payload: Function-specific payloadaccount_id: Account ID
Flow:
- Gets account from account_id
- Gets function instance from registry
- Creates AIEngine
- Executes function via AIEngine
Planner Tasks
auto_cluster_keywords_task
File: modules/planner/tasks.py (legacy, now uses run_ai_task)
Purpose: Auto-cluster keywords using AI
Parameters:
keyword_ids: List of keyword IDsaccount_id: Account IDsite_id: Site IDsector_id: Sector ID
Progress Tracking: Updates progress with request_steps and response_steps
auto_generate_ideas_task
File: modules/planner/tasks.py (legacy, now uses run_ai_task)
Purpose: Auto-generate content ideas for clusters
Parameters:
cluster_ids: List of cluster IDsaccount_id: Account ID
Progress Tracking: Updates progress for each cluster
Writer Tasks
auto_generate_content_task
File: modules/writer/tasks.py (legacy, now uses run_ai_task)
Purpose: Auto-generate content for tasks
Parameters:
task_ids: List of task IDsaccount_id: Account ID
Progress Tracking: Updates progress for each task
process_image_generation_queue
File: modules/writer/views.py (via ai/tasks.py)
Purpose: Generate images for image records
Parameters:
image_ids: List of image IDsaccount_id: Account IDcontent_id: Content ID (optional)
Progress Tracking: Updates progress for each image sequentially
API Endpoints
Base URL
/api/v1/
Planner Endpoints
GET /api/v1/planner/keywords/- List keywordsPOST /api/v1/planner/keywords/- Create keywordGET /api/v1/planner/keywords/{id}/- Get keywordPUT /api/v1/planner/keywords/{id}/- Update keywordDELETE /api/v1/planner/keywords/{id}/- Delete keywordPOST /api/v1/planner/keywords/auto_cluster/- Auto-cluster keywordsPOST /api/v1/planner/keywords/bulk_delete/- Bulk delete keywordsPOST /api/v1/planner/keywords/bulk_update_status/- Bulk update statusGET /api/v1/planner/keywords/export_csv/- Export keywordsPOST /api/v1/planner/keywords/import_csv/- Import keywordsGET /api/v1/planner/clusters/- List clustersPOST /api/v1/planner/clusters/auto_generate_ideas/- Auto-generate ideasGET /api/v1/planner/ideas/- List content ideas
Writer Endpoints
GET /api/v1/writer/tasks/- List tasksPOST /api/v1/writer/tasks/- Create taskGET /api/v1/writer/tasks/{id}/- Get task detailsPOST /api/v1/writer/tasks/auto_generate_content/- Auto-generate contentGET /api/v1/writer/content/- List contentGET /api/v1/writer/content/{id}/- Get content detailsPOST /api/v1/writer/images/generate_images/- Generate images
Linker Endpoints
POST /api/v1/linker/process/- Process content for internal linkingPOST /api/v1/linker/batch_process/- Batch process content for linking
Optimizer Endpoints
POST /api/v1/optimizer/optimize/- Optimize contentPOST /api/v1/optimizer/batch_optimize/- Batch optimize contentPOST /api/v1/optimizer/analyze/- Analyze content
Publisher Endpoints
GET /api/v1/publisher/publishing-records/- List publishing recordsPOST /api/v1/publisher/publishing-records/- Create publishing recordGET /api/v1/publisher/deployments/- List deployment recordsPOST /api/v1/publisher/deployments/- Create deployment recordPOST /api/v1/publisher/publish/- Publish contentPOST /api/v1/publisher/deploy/- Deploy site blueprintGET /api/v1/publisher/sites/{site_id}/definition/- Get site definition (public)
Site Builder Endpoints
GET /api/v1/site-builder/blueprints/- List site blueprintsPOST /api/v1/site-builder/blueprints/- Create site blueprintGET /api/v1/site-builder/blueprints/{id}/- Get blueprint detailsPOST /api/v1/site-builder/blueprints/{id}/generate_structure/- Generate structurePOST /api/v1/site-builder/blueprints/{id}/generate_all_pages/- Generate all pagesPOST /api/v1/site-builder/blueprints/{id}/create_tasks/- Create tasks for pagesGET /api/v1/site-builder/blueprints/{id}/progress/- Get progressPOST /api/v1/site-builder/blueprints/{id}/clusters/attach/- Attach clustersPOST /api/v1/site-builder/blueprints/{id}/clusters/detach/- Detach clustersGET /api/v1/site-builder/blueprints/{id}/taxonomies/- List taxonomiesPOST /api/v1/site-builder/blueprints/{id}/taxonomies/- Create taxonomyPOST /api/v1/site-builder/blueprints/{id}/taxonomies/import/- Import taxonomiesPOST /api/v1/site-builder/blueprints/bulk_delete/- Bulk delete blueprintsGET /api/v1/site-builder/pages/- List page blueprintsPOST /api/v1/site-builder/pages/- Create page blueprintGET /api/v1/site-builder/pages/{id}/- Get page detailsPOST /api/v1/site-builder/pages/{id}/generate_content/- Generate contentPOST /api/v1/site-builder/pages/{id}/regenerate/- Regenerate pageGET /api/v1/site-builder/assets/- List assetsPOST /api/v1/site-builder/assets/- Upload assetDELETE /api/v1/site-builder/assets/- Delete assetGET /api/v1/site-builder/metadata/- Get metadata
Automation Endpoints
GET /api/v1/automation/rules/- List automation rulesPOST /api/v1/automation/rules/- Create automation ruleGET /api/v1/automation/rules/{id}/- Get rule detailsPOST /api/v1/automation/rules/{id}/execute/- Execute ruleGET /api/v1/automation/scheduled-tasks/- List scheduled tasksPOST /api/v1/automation/scheduled-tasks/- Create scheduled task
Integration Endpoints
GET /api/v1/integration/integrations/- List site integrationsPOST /api/v1/integration/integrations/- Create integrationGET /api/v1/integration/integrations/{id}/- Get integration detailsPOST /api/v1/integration/integrations/{id}/test_connection/- Test connectionPOST /api/v1/integration/integrations/{id}/sync/- Sync contentGET /api/v1/integration/integrations/{id}/sync_health/- Get sync health
System Endpoints
GET /api/v1/system/settings/integrations/{pk}/- Get integration settingsPUT /api/v1/system/settings/integrations/{pk}/- Save integration settingsPOST /api/v1/system/settings/integrations/{pk}/test_openai/- Test OpenAIPOST /api/v1/system/settings/integrations/{pk}/test_runware/- Test RunwarePOST /api/v1/system/settings/integrations/{pk}/generate_image/- Test image generationGET /api/v1/system/settings/task_progress/{task_id}/- Get task progress
Base Classes
AccountModelViewSet
File: api/base.py
Purpose: Base ViewSet with automatic account filtering
Features:
- Automatic account filtering
- Admin/Developer override
- Account context in serializers
SiteSectorModelViewSet
File: api/base.py
Purpose: Base ViewSet with site/sector filtering
Features:
- Account filtering (inherited)
- Site access control
- Sector validation
- Accessible sites/sectors in serializer context
Middleware
AccountContextMiddleware
File: middleware/account.py
Purpose: Sets request.account from JWT token
Functionality:
- Extracts account ID from JWT token
- Loads Account object
- Sets
request.account
ResourceTrackerMiddleware
File: middleware/resource_tracker.py
Purpose: Tracks API request metrics
Functionality:
- Tracks CPU, memory, I/O usage
- Stores metrics in cache
- Provides metrics endpoint
Utilities
Content Normalizer
File: utils/content_normalizer.py
Purpose: Content processing utilities
Functions:
normalize_content(): Converts plain text to HTML_extract_body_content(): Extracts body content from HTML
Modules
Planner Module
Purpose: Keyword management and content planning
Models: Keywords, Clusters, ContentIdeas
ViewSets: KeywordViewSet, ClusterViewSet, ContentIdeasViewSet
Tasks: Auto-cluster keywords, Auto-generate ideas
Writer Module
Purpose: Content generation and management
Models (in business/content/):
Tasks: Content generation tasksContent: Generated content piecesImages: Generated imagesContentClusterMap: Content-to-cluster mappingContentTaxonomyMap: Content taxonomy mappingContentAttributeMap: Content attribute mapping
ViewSets:
TasksViewSet: CRUD + auto-generate content, bulk operationsContentViewSet: CRUD + publish to WordPressImagesViewSet: CRUD + generate images
URLs: /api/v1/writer/
Linker Module
Purpose: Internal linking operations
ViewSets:
LinkerViewSet: Process content for internal linking
Actions:
process(): Process single content itembatch_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 contentanalyze(): Analyze content without optimization
URLs: /api/v1/optimizer/
Publisher Module
Purpose: Publishing records and site deployment
Models (in business/publishing/):
PublishingRecord: Records of content publishingDeploymentRecord: Records of site deployments
ViewSets:
PublishingRecordViewSet: CRUD for publishing recordsDeploymentRecordViewSet: CRUD for deployment recordsPublisherViewSet: Publishing and deployment actionsSiteDefinitionView: Public endpoint for Sites Renderer
Actions:
publish(): Publish content to destinationdeploy(): Deploy site blueprintcheck_readiness(): Check deployment readiness
URLs: /api/v1/publisher/
Site Builder Module
Purpose: Site blueprint management
Models (in business/site_building/):
SiteBlueprint: Site structure definitionsPageBlueprint: Page structure definitionsSiteBlueprintCluster: Cluster-to-blueprint mappingSiteBlueprintTaxonomy: Taxonomy definitionsSiteBuilderOption: Site builder configuration options
ViewSets:
SiteBlueprintViewSet: CRUD + structure generation, cluster managementPageBlueprintViewSet: CRUD + content generationSiteAssetView: Asset managementSiteBuilderMetadataView: Metadata retrieval
Actions:
generate_structure(): Generate site structure using AIgenerate_all_pages(): Generate all pages for blueprintcreate_tasks(): Create Writer tasks for pagesprogress(): Get cluster-level completion statusattach_clusters(): Attach planner clustersdetach_clusters(): Detach clustersgenerate_content(): Generate content for pageregenerate(): 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 definitionsScheduledTask: Scheduled task definitions
ViewSets:
AutomationRuleViewSet: CRUD + execute ruleScheduledTaskViewSet: 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 platformsync(): Sync content with integrated platformsync_health(): Check sync health status
URLs: /api/v1/integration/
System Module
Purpose: System configuration and AI settings
Models:
AIPrompt: AI prompt templatesIntegrationSettings: Account-level integration settingsAuthorProfile: Author profile definitionsStrategy: Content strategy definitions
ViewSets:
AIPromptViewSet: CRUD + reset to defaultIntegrationSettingsViewSet: Integration settings managementAuthorProfileViewSet: CRUD for author profilesSystemSettingsViewSet: System settings managementAccountSettingsViewSet: Account settings management
URLs: /api/v1/system/
Billing Module
Purpose: Credit management and usage tracking
Models (in business/billing/):
CreditTransaction: Credit transaction recordsCreditUsageLog: Credit usage logging
ViewSets:
CreditTransactionViewSet: CRUD for transactionsCreditBalanceViewSet: Credit balance retrievalCreditUsageViewSet: Credit usage tracking
Services:
CreditService: Credit operations (check, deduct, add, calculate)
URLs: /api/v1/billing/
Summary
The IGNY8 backend provides:
- Multi-Tenancy: Complete account isolation with automatic filtering
- RESTful API: DRF ViewSets with consistent response format
- Celery Integration: Asynchronous task processing
- Hierarchical Organization: Account > Site > Sector > Content structure
- AI Framework: Unified AI framework for all AI operations
- Progress Tracking: Real-time progress updates for Celery tasks
- Module-Based Design: Clear separation of concerns across 10 modules
- Base Classes: Reusable ViewSets for common patterns
- Middleware: Account context and resource tracking
- Utilities: Content processing and AI integration
- Internal Linking: AI-powered internal linking suggestions
- Content Optimization: Content optimization and scoring
- Publishing System: Multi-destination publishing with deployment tracking
- Site Builder: Site blueprint and structure management (API-based)
- Automation: Rule-based automation and scheduled tasks
- Integration: External platform integrations and synchronization
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.