18 KiB
IGNY8 System Complete Overview
Executive Summary
IGNY8 is a comprehensive AI-powered content generation and management platform built on Django (backend) and React (frontend). The system enables automated content creation workflows from keyword research through publication, with WordPress integration for seamless content distribution.
System Architecture
Core Technology Stack
Backend:
- Django 4.2+ with Django REST Framework
- PostgreSQL database
- Celery for async task processing
- Redis for caching and message broker
- JWT authentication
Frontend:
- React 18+ with TypeScript
- Vite build system
- Zustand for state management
- TailwindCSS for styling
- React Router for navigation
AI Integration:
- OpenAI GPT-4 for content generation
- Runware for image generation
- Custom AI orchestration layer
Multi-Tenant Architecture
Account Hierarchy
Account (Organization)
└── Site (Website/Project)
└── Sector (Content Category)
└── Content/Keywords/Tasks
Key Models:
Account: Top-level organizationSite: Individual website/projectSector: Content category within siteUser: User with role-based permissions
Data Isolation
All business models inherit from:
AccountBaseModel: Account-level isolationSiteSectorBaseModel: Site/Sector-level isolation
Authentication & Authorization
JWT Authentication Flow
- User logs in via
/api/v1/auth/login/ - Backend validates credentials and returns JWT tokens
- Frontend stores tokens in localStorage
AccountContextMiddlewareextracts account from token- All requests include JWT in Authorization header
Permission System
Roles (Hierarchical):
- Owner: Full access
- Admin: Manage users and settings
- Editor: Create and edit content
- Viewer: Read-only access
Implementation:
IsAuthenticatedAndActive: Base permissionIsViewerOrAbove: Minimum viewer roleIsEditorOrAbove: Minimum editor role
API Architecture
Unified API Standard v1.0
All API responses follow this format:
{
"success": true,
"data": { /* response data */ },
"message": "Operation completed successfully",
"request_id": "uuid-v4",
"timestamp": "2024-01-01T00:00:00Z"
}
Error Response:
{
"success": false,
"error": "Error message",
"error_code": "ERROR_CODE",
"request_id": "uuid-v4",
"timestamp": "2024-01-01T00:00:00Z"
}
Base ViewSets
- Automatic account filtering
- Used for account-level resources
- Automatic site/sector filtering
- Used for content-related resources
- Supports site/sector switching
Core Modules
1. Planner Module
Purpose: Keyword research and content planning
Key Components:
Keyword: Individual keywords with metricsCluster: Grouped keywords by topicTask: Content creation tasks
AI Functions:
auto_cluster(): Automatic keyword clusteringgenerate_ideas(): Content idea generation
API Endpoints:
GET/POST /api/v1/planner/keywords/GET/POST /api/v1/planner/clusters/GET/POST /api/v1/planner/tasks/POST /api/v1/planner/keywords/bulk-import/POST /api/v1/planner/clusters/{id}/auto-cluster/
2. Writer Module
Purpose: AI-powered content generation
Key Components:
Content: Generated content with metadataContentVersion: Version historyImagePrompt: AI image generation promptsGeneratedImage: Generated images
AI Functions:
generate_content(): Article generationgenerate_image_prompts(): Image prompt creationgenerate_images(): Image generation via Runware
API Endpoints:
GET/POST /api/v1/writer/content/POST /api/v1/writer/content/{id}/generate/POST /api/v1/writer/content/{id}/regenerate/GET/POST /api/v1/writer/image-prompts/POST /api/v1/writer/images/generate/
3. Integration Module
Purpose: WordPress bidirectional sync
Key Components:
Integration: WordPress site connectionSyncLog: Sync operation history
WordPress Plugin:
- REST API endpoints for content sync
- Webhook notifications for changes
- Authentication via API keys
API Endpoints:
GET/POST /api/v1/integration/integrations/POST /api/v1/integration/integrations/{id}/test-connection/POST /api/v1/integration/integrations/{id}/sync/POST /api/v1/integration/integrations/{id}/publish/
Sync Flow:
- User creates Integration with WordPress URL and credentials
- System validates connection
- Content can be pushed to WordPress
- WordPress plugin sends webhooks on changes
- System pulls updates and maintains sync
4. Automation Module
Purpose: Automated workflow execution
Key Components:
AutomationRule: Workflow definitionsScheduledTask: Scheduled executions
Services:
AutomationService: Main orchestratorRuleEngine: Condition evaluationActionExecutor: Action execution
Rule Structure:
{
"name": "Auto Content Pipeline",
"trigger": "schedule",
"schedule": "0 0 * * *",
"conditions": [
{
"field": "task.status",
"operator": "equals",
"value": "pending"
}
],
"actions": [
{
"type": "generate_content",
"params": {
"task_ids": ["task-id"]
}
},
{
"type": "generate_images",
"params": {
"content_id": "content-id"
}
}
]
}
API Endpoints:
GET/POST /api/v1/automation/rules/POST /api/v1/automation/rules/{id}/execute/GET /api/v1/automation/scheduled-tasks/
AI Framework
Architecture
- Central orchestrator for all AI operations
- Manages function registry and execution
- Handles progress tracking and error handling
- Low-level API client for OpenAI/Runware
- Request/response handling
- Rate limiting and retry logic
- Lazy loading of AI functions
- Function metadata and validation
- Dependency injection
AI Function Structure
Each AI function follows this pattern:
@ai_function(
name="function_name",
description="Function description",
cost_credits=10
)
def my_ai_function(account, **kwargs):
"""
AI function implementation
Args:
account: Account instance
**kwargs: Function-specific parameters
Returns:
dict: Result with success status
"""
# Implementation
pass
Progress Tracking
Celery Integration:
- Each AI operation runs as Celery task
- Progress updates via task state
- Real-time updates to frontend
Progress Phases:
- Initializing: Setup and validation
- Processing: Main AI operation
- AI Analysis: Post-processing
- Saving: Database persistence
- Completed: Final state
Cost Management
Credit System:
CreditService: Credit management- Pre-execution credit checks
- Post-execution credit deduction
- Usage tracking and reporting
Credit Costs:
- Content generation: 1 credit per 500 words
- Image prompts: 0.5 credits per prompt
- Image generation: 1-4 credits (provider-dependent)
- Keyword clustering: 10 credits per operation
Frontend Architecture
State Management (Zustand)
Global Stores:
authStore: Authentication statesiteStore: Site/sector selectioncontentStore: Content management
Store Pattern:
interface Store {
// State
data: any[];
loading: boolean;
error: string | null;
// Actions
fetchData: () => Promise<void>;
createItem: (item: any) => Promise<void>;
updateItem: (id: string, item: any) => Promise<void>;
deleteItem: (id: string) => Promise<void>;
}
API Client
- Axios-based HTTP client
- Automatic JWT token injection
- Request/response interceptors
- Error handling and retry logic
Component Structure
Layout Components:
DefaultLayout: Main app layoutHeader: Top navigationSidebar: Side navigation
Common Components:
ProgressModal: AI operation progressConfirmDialog: Confirmation dialogsFormModal: Generic form modals
Routing
Protected Routes:
<ProtectedRoute>
<Route path="/planner" element={<PlannerPage />} />
<Route path="/writer" element={<WriterPage />} />
<Route path="/integration" element={<IntegrationPage />} />
<Route path="/automation" element={<AutomationPage />} />
</ProtectedRoute>
Database Schema
Core Tables
Authentication:
igny8_accounts: Organizationsigny8_sites: Websites/projectsigny8_sectors: Content categoriesigny8_users: User accounts
Planning:
igny8_keywords: Keyword dataigny8_clusters: Keyword clustersigny8_tasks: Content tasks
Content:
igny8_content: Generated contentigny8_content_versions: Version historyigny8_image_prompts: Image promptsigny8_generated_images: Generated images
Integration:
igny8_integrations: WordPress connectionsigny8_sync_logs: Sync history
Automation:
igny8_automation_rules: Workflow rulesigny8_scheduled_tasks: Scheduled executions
Billing:
igny8_credit_transactions: Credit usageigny8_subscriptions: Subscription plans
Deployment
Docker Configuration
Services:
backend: Django applicationfrontend: React applicationpostgres: PostgreSQL databaseredis: Redis cache/brokercelery: Celery workercelery-beat: Celery scheduler
services:
backend:
build: ./backend
ports:
- "8000:8000"
environment:
- DATABASE_URL=postgresql://...
- REDIS_URL=redis://...
frontend:
build: ./frontend
ports:
- "3000:3000"
postgres:
image: postgres:15
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
celery:
build: ./backend
command: celery -A igny8_core worker -l info
celery-beat:
build: ./backend
command: celery -A igny8_core beat -l info
Environment Variables
Backend (.env):
DEBUG=False
SECRET_KEY=your-secret-key
DATABASE_URL=postgresql://user:pass@host:5432/db
REDIS_URL=redis://host:6379/0
OPENAI_API_KEY=sk-...
RUNWARE_API_KEY=...
Frontend (.env):
VITE_API_URL=http://localhost:8000/api/v1
VITE_WS_URL=ws://localhost:8000/ws
Security Considerations
Authentication Security
-
JWT Tokens:
- Access token: 1 hour expiry
- Refresh token: 7 days expiry
- Secure HTTP-only cookies (optional)
-
Password Security:
- Django's PBKDF2 hashing
- Minimum 8 characters
- Complexity requirements
-
API Security:
- Rate limiting per endpoint
- CORS configuration
- CSRF protection
Data Security
-
Multi-Tenant Isolation:
- Automatic account filtering
- Row-level security
- No cross-account data access
-
Permission Checks:
- Role-based access control
- Object-level permissions
- Audit logging
-
Sensitive Data:
- API keys encrypted at rest
- WordPress credentials secured
- PII data protection
Performance Optimization
Backend Optimization
-
Database:
- Indexed foreign keys
- Composite indexes for common queries
- Query optimization with select_related/prefetch_related
-
Caching:
- Redis for session storage
- API response caching
- Database query caching
-
Async Processing:
- Celery for long-running tasks
- Background job processing
- Task prioritization
Frontend Optimization
-
Code Splitting:
- Route-based splitting
- Lazy loading components
- Dynamic imports
-
State Management:
- Zustand for minimal re-renders
- Selective subscriptions
- Memoization
-
Asset Optimization:
- Image lazy loading
- SVG optimization
- Bundle size monitoring
Monitoring & Logging
Backend Logging
Log Levels:
- DEBUG: Development debugging
- INFO: General information
- WARNING: Warning messages
- ERROR: Error conditions
- CRITICAL: Critical failures
Log Destinations:
- Console output
- File rotation
- External logging service (optional)
Frontend Monitoring
Error Tracking:
- React Error Boundaries
- API error logging
- User action tracking
Performance Monitoring:
- Page load times
- API response times
- Component render times
Testing Strategy
Backend Testing
Unit Tests:
- Model validation
- Service logic
- Utility functions
Integration Tests:
- API endpoints
- Database operations
- External API calls
Test Coverage:
- Minimum 80% coverage
- Critical paths 100% coverage
Frontend Testing
Component Tests:
- React Testing Library
- Component rendering
- User interactions
Integration Tests:
- API integration
- State management
- Routing
Development Workflow
Local Development
- Backend Setup:
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
- Frontend Setup:
cd frontend
npm install
npm run dev
- Celery Worker:
cd backend
celery -A igny8_core worker -l info
Git Workflow
- Create feature branch from
develop - Implement changes with tests
- Create pull request
- Code review and approval
- Merge to
develop - Deploy to staging
- Merge to
mainfor production
API Documentation
Interactive Documentation
Swagger UI:
- URL:
/api/schema/swagger-ui/ - Interactive API testing
- Request/response examples
ReDoc:
- URL:
/api/schema/redoc/ - Clean documentation view
- Searchable endpoints
API Versioning
Current version: v1.0
All endpoints prefixed with /api/v1/
Future versions will use /api/v2/, etc.
Troubleshooting
Common Issues
1. Database Connection Errors:
- Check DATABASE_URL in .env
- Verify PostgreSQL is running
- Check network connectivity
2. Celery Task Failures:
- Check Redis connection
- Verify Celery worker is running
- Check task logs
3. Authentication Issues:
- Verify JWT token validity
- Check token expiration
- Validate user permissions
4. WordPress Sync Failures:
- Test WordPress connection
- Verify API credentials
- Check WordPress plugin version
Future Enhancements
Planned Features
-
Advanced Automation:
- Conditional workflows
- Multi-step pipelines
- Error recovery
-
Enhanced AI:
- Multiple AI providers
- Custom model fine-tuning
- Advanced prompt engineering
-
Collaboration:
- Team workspaces
- Content approval workflows
- Comment system
-
Analytics:
- Content performance tracking
- SEO metrics
- Usage analytics
-
Integrations:
- Additional CMS platforms
- Social media publishing
- Email marketing tools
Support & Resources
Documentation
- System Architecture:
docs/00-SYSTEM-ARCHITECTURE-MASTER-REFERENCE.md - REST API:
docs/01-IGNY8-REST-API-COMPLETE-REFERENCE.md - WordPress Integration:
docs/03-WORDPRESS-PLUGIN-API-INTEGRATION-GUIDE.md - Automation:
docs/automation-designer-mode-specification.md
Contact
- Technical Support: support@igny8.com
- Documentation: docs.igny8.com
- GitHub: github.com/igny8/igny8-app
Document Version: 1.0
Last Updated: 2024-11-30
Maintained By: IGNY8 Development Team