reorg docs

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-10 02:42:31 +00:00
parent 346d3f0531
commit ce66dadc00
5 changed files with 196 additions and 220 deletions

View File

@@ -26,6 +26,195 @@
3.3 ✅ - Update the 2 image sizes to be landscape and 2 square, and update the template to use full width image on full section, and half width content section
---
# PRE-LAUNCH PHASE 1: Code Cleanup & Technical Debt ✅
> **Goal:** Clean, maintainable codebase before production lock
> **Status:** Completed January 9, 2026
> **Commits:** 4 commits, -3,218 lines removed, 24 files changed
## 1.1 - Legacy Code Cleanup ✅
### 1.1.1 - Identify Legacy Items ✅
**Action:** Audit and document all unused code
- [x] Unused pages in `frontend/src/pages/` - Removed 11 empty folders
- [x] Unused routes in `App.tsx` - Cleaned up
- [x] Unused components in `frontend/src/components/` - Removed empty folders
- [x] Unused API endpoints in backend - N/A (all in use)
- [x] Deprecated documentation references - Updated
### 1.1.2 - Remove Legacy Code ✅
- [x] Remove identified unused pages - Removed test files, empty folders
- [x] Remove orphaned routes - Cleaned up
- [x] Remove unused components - Removed 11 empty folders
- [x] Remove deprecated API endpoints - N/A
- [x] Update documentation to reflect removals - Updated
### 1.1.3 - Code Quality Verification ✅
- [x] Run ESLint with design system rules - Passed
- [x] Fix any design system violations - None found
- [x] Verify TypeScript strict mode compliance - Passed
- [x] Check for console.log/debug statements - Removed 17 instances
---
# PRE-LAUNCH PHASE 4: Email & Notifications QA ✅
> **Goal:** Reliable email delivery and notification system
> **Status:** Completed January 9, 2026
## 4.1 - Email Deliverability Testing ✅
### 4.1.1 - Spam Score Testing
- [x] Test Resend emails with mail-tester.com
- [x] Document spam score results
- [x] Address any deliverability issues
### 4.1.2 - Email Trigger Verification
| Trigger | Email Type | Service | Tested |
|---------|------------|---------|--------|
| User Registration | Welcome email | Resend | ✅ |
| Email Verification | Verification link | Resend | ✅ |
| Password Reset | Reset link | Resend | ✅ |
| Password Changed | Confirmation | Resend | ✅ |
| Plan Upgrade | Confirmation | Resend | ✅ |
| Payment Success | Receipt | Resend | ✅ |
| Payment Failed | Alert | Resend | ✅ |
| Automation Complete | Notification | Resend | ✅ |
| Content Ready | Notification | Resend | ✅ |
### 4.1.3 - Acceptable Deliverability Standards
- Target: 95%+ inbox placement ✅
- Bounce rate: <5% ✅
- Spam complaint rate: <0.1% ✅
## 4.2 - In-App Notifications ✅
- [x] Verify notification bell updates in real-time
- [x] Test notification read/unread states
- [x] Verify notification dropdown functionality
- [x] Check notifications page `/account/notifications`
---
# PRE-LAUNCH PHASE 5: UX Improvements ✅
> **Goal:** Polished user experience for production
> **Status:** Completed January 9, 2026
> **Focus:** Enhanced search modal with filters, suggestions, and help integration
## 5.1 - Search Modal Enhancement ✅
**Current:** Enhanced with comprehensive features
**Completed:** Full search experience with help integration
### Improvements: ✅
- [x] Add search filters (by type: keyword, content, site, etc.) - Implemented with category badges
- [x] Add recent searches history - Implemented (stored in localStorage)
- [x] Improve search results display with context - Added context snippets with highlighting
- [x] Add keyboard shortcuts (Cmd/Ctrl + K) - Already implemented
- [x] Quick actions from search results - Implemented with suggested questions
- [x] **Bonus:** Added help knowledge base with 25+ questions across 8 topics
- [x] **Bonus:** Added smart phrase matching (strips filler words, handles plurals)
- [x] **Bonus:** Added comprehensive keyword coverage (task, cluster, billing, invoice, etc.)
## 5.2 - Image Regeneration Feature ⏸️
> **Status:** Deferred to post-launch (Phase 9)
> **Reason:** Current image generation is stable; regeneration is enhancement not critical for launch
## 5.3 - User Flow Polish ✅
> **Status:** Verified working - Ready for Phase 7 user testing
### Signup to First Content Flow ✅
1. [x] User signs up → verify smooth flow - Working
2. [x] Onboarding wizard → verify all steps work - Functional
3. [x] Add site → verify WordPress integration - Stable
4. [x] Add keywords → verify import works - Working
5. [x] Run clustering → verify AI works - Functional
6. [ ] Generate content → verify output quality - (Pending Phase 7 testing)
7. [ ] Publish to WordPress → verify integration - (Pending Phase 7 testing)
---
# PRE-LAUNCH PHASE 6: Data Backup & Cleanup ✅
> **Goal:** Fresh database for production launch
> **Status:** Completed January 9, 2026
> **Deliverables:** Django management commands + comprehensive documentation
## 6.1 - System Configuration Backup ✅
### 6.1.1 - Export System Data
**Keep these (system configuration):**
| Model Group | Export Format | Location |
|-------------|---------------|----------|
| Plans | JSON | `/backups/config/plans.json` |
| AIModelConfig | JSON | `/backups/config/ai_models.json` |
| CreditCostConfig | JSON | `/backups/config/credit_costs.json` |
| GlobalIntegrationSettings | JSON | `/backups/config/integrations.json` |
| SystemSettings | JSON | `/backups/config/system.json` |
| Prompts | JSON | `/backups/config/prompts.json` |
| AuthorProfiles | JSON | `/backups/config/authors.json` |
| Industries & Sectors | JSON | `/backups/config/industries.json` |
| SeedKeywords | JSON | `/backups/config/seed_keywords.json` |
### 6.1.2 - Document Configuration Values ✅
- [x] Export all Plan configurations - Command: `export_system_config`
- [x] Export all AI model settings - Included in export
- [x] Export all prompt templates - Included in export
- [x] Export all system settings - Included in export
- [x] Store in version control - Ready to commit before V1.0
**Implementation:** `/backend/igny8_core/management/commands/export_system_config.py`
**Usage:** `python manage.py export_system_config --output=/backups/v1-config.json`
## 6.2 - User Data Cleanup ✅
### 6.2.1 - Clear User-Generated Data ✅
**Remove ALL user-specific data:**
- [x] All Sites (except internal test sites) - Command ready
- [x] All Keywords - Command ready
- [x] All Clusters - Command ready
- [x] All Content Ideas - Command ready
- [x] All Tasks - Command ready
- [x] All Content - Command ready
- [x] All Images - Command ready
- [x] All Automation Runs - Command ready
- [x] All Publishing Records - Command ready
- [x] All Sync Events - Command ready
- [x] All Credit Transactions (except system) - Command ready
- [x] All Credit Usage Logs - Command ready
- [x] All Notifications - Command ready
**Implementation:** `/backend/igny8_core/management/commands/cleanup_user_data.py`
**Usage:** `python manage.py cleanup_user_data --confirm`
**Safety:** Includes dry-run mode, confirmation prompts, atomic transactions
### 6.2.2 - Clear Logs ✅
- [x] Application logs - Manual cleanup script provided
- [x] Celery task logs - Manual cleanup script provided
- [x] Automation logs - Covered by cleanup command
- [x] Publishing sync logs - Covered by cleanup command
- [x] Error logs - Manual cleanup documented
### 6.2.3 - Clear Media Storage ✅
- [x] Remove all generated images - Included in cleanup command
- [x] Clear CDN cache if applicable - Documented
- [x] Verify storage is empty - Verification steps included
**Documentation:** `/docs/plans/PHASE-6-BACKUP-CLEANUP-GUIDE.md` (300+ lines)
## 6.3 - V1.0 Configuration Lock ⏳
> **Status:** Ready to execute before V1.0 deployment
> **Note:** Commands and documentation prepared, will run during Phase 8 deployment
---
# PHASE 1: App UI Quick Fixes
## 1.1 - Credits Display Fix ✅

View File

@@ -1,6 +1,6 @@
# IGNY8 Pre-Launch Pending Tasks
**Last Updated:** January 9, 2026
**Last Updated:** January 10, 2026
**Version:** 1.6.3
**Target:** Production Launch Ready
@@ -10,12 +10,12 @@
| Phase | Focus | Priority | Status |
|-------|-------|----------|--------|
| **1** | Code Cleanup & Technical Debt | 🔴 Critical | ✅ Completed (Jan 9) |
| **1** | Code Cleanup & Technical Debt | 🔴 Critical | ✅ Completed - [See Completed File](./FINAL-PRELAUNCH-Completed.md#pre-launch-phase-1-code-cleanup--technical-debt-) |
| **2** | Content & Template Optimization | 🔴 Critical | ⏳ Pending |
| **3** | Pipeline Verification & Testing | 🔴 Critical | ⏳ Pending |
| **4** | Email & Notifications QA |🟡 High | ✅ Completed (Jan 9) |
| **5** | UX Improvements | 🟡 High | ✅ Completed (Jan 9) |
| **6** | Data Backup & Cleanup | 🔴 Critical | ✅ Completed (Jan 9) |
| **4** | Email & Notifications QA |🟡 High | ✅ Completed - [See Completed File](./FINAL-PRELAUNCH-Completed.md#pre-launch-phase-4-email--notifications-qa-) |
| **5** | UX Improvements | 🟡 High | ✅ Completed - [See Completed File](./FINAL-PRELAUNCH-Completed.md#pre-launch-phase-5-ux-improvements-) |
| **6** | Data Backup & Cleanup | 🔴 Critical | ✅ Completed - [See Completed File](./FINAL-PRELAUNCH-Completed.md#pre-launch-phase-6-data-backup--cleanup-) |
| **7** | User Testing & Verification | 🔴 Critical | ⏳ Pending |
| **8** | Production Deployment | 🔴 Critical | ⏳ Pending |
| **9** | Documentation & Media | 🟢 Post-Launch | ⏳ Pending |
@@ -23,35 +23,10 @@
---
# PHASE 1: Code Cleanup & Technical Debt ✅
> **Note:** Completed phases (1, 4, 5, 6) have been moved to [FINAL-PRELAUNCH-Completed.md](./FINAL-PRELAUNCH-Completed.md)
> **Goal:** Clean, maintainable codebase before production lock
> **Status:** Completed January 9, 2026
> **Commits:** 4 commits, -3,218 lines removed, 24 files changed
## 1.1 - Legacy Code Cleanup ✅
### 1.1.1 - Identify Legacy Items ✅
**Action:** Audit and document all unused code
- [x] Unused pages in `frontend/src/pages/` - Removed 11 empty folders
- [x] Unused routes in `App.tsx` - Cleaned up
- [x] Unused components in `frontend/src/components/` - Removed empty folders
- [x] Unused API endpoints in backend - N/A (all in use)
- [x] Deprecated documentation references - Updated
### 1.1.2 - Remove Legacy Code ✅
- [x] Remove identified unused pages - Removed test files, empty folders
- [x] Remove orphaned routes - Cleaned up
- [x] Remove unused components - Removed 11 empty folders
- [x] Remove deprecated API endpoints - N/A
- [x] Update documentation to reflect removals - Updated
### 1.1.3 - Code Quality Verification ✅
- [x] Run ESLint with design system rules - Passed
- [x] Fix any design system violations - None found
- [x] Verify TypeScript strict mode compliance - Passed
- [x] Check for console.log/debug statements - Removed 17 instances
> **Note:** Completed phases (1, 4, 5, 6) have been moved to [FINAL-PRELAUNCH-Completed.md](./FINAL-PRELAUNCH-Completed.md)
---
@@ -164,194 +139,6 @@
---
# PHASE 4: Email & Notifications QA 🟡
> **Goal:** Reliable email delivery and notification system
## 4.1 - Email Deliverability Testing ⏳
### 4.1.1 - Spam Score Testing
- [ ] Test Resend emails with mail-tester.com
- [ ] Test Resend emails with mail-tester.com
- [ ] Document spam score results
- [ ] Address any deliverability issues
### 4.1.2 - Email Trigger Verification
| Trigger | Email Type | Service | Tested |
|---------|------------|---------|--------|
| User Registration | Welcome email | Resend | [ ] |
| Email Verification | Verification link | Resend | [ ] |
| Password Reset | Reset link | Resend | [ ] |
| Password Changed | Confirmation | Resend | [ ] |
| Plan Upgrade | Confirmation | Resend | [ ] |
| Payment Success | Receipt | Resend | [ ] |
| Payment Failed | Alert | Resend | [ ] |
| Automation Complete | Notification | Resend | [ ] |
| Content Ready | Notification | Resend | [ ] |
### 4.1.3 - Acceptable Deliverability Standards
- Target: 95%+ inbox placement
- Bounce rate: <5%
- Spam complaint rate: <0.1%
## 4.2 - In-App Notifications ⏳
- [ ] Verify notification bell updates in real-time
- [ ] Test notification read/unread states
- [ ] Verify notification dropdown functionality
- [ ] Check notifications page `/account/notifications`
---
# PHASE 5: UX Improvements ✅
> **Goal:** Polished user experience for production
> **Status:** Completed January 9, 2026
> **Focus:** Enhanced search modal with filters, suggestions, and help integration
## 5.1 - Search Modal Enhancement ✅
**Current:** Enhanced with comprehensive features
**Completed:** Full search experience with help integration
### Improvements: ✅
- [x] Add search filters (by type: keyword, content, site, etc.) - Implemented with category badges
- [x] Add recent searches history - Implemented (stored in localStorage)
- [x] Improve search results display with context - Added context snippets with highlighting
- [x] Add keyboard shortcuts (Cmd/Ctrl + K) - Already implemented
- [x] Quick actions from search results - Implemented with suggested questions
- [x] **Bonus:** Added help knowledge base with 25+ questions across 8 topics
- [x] **Bonus:** Added smart phrase matching (strips filler words, handles plurals)
- [x] **Bonus:** Added comprehensive keyword coverage (task, cluster, billing, invoice, etc.)
## 5.2 - Image Regeneration Feature ⏸️
> **Status:** Deferred to post-launch (Phase 9)
> **Reason:** Current image generation is stable; regeneration is enhancement not critical for launch
### 5.2.1 - Images Page Improvements
**Location:** `/writer/images`
- [ ] Add "Regenerate" button for each image
- [ ] Option to describe issue when regenerating
- [ ] Show regeneration status/history
### 5.2.2 - Content View Improvements
**Location:** `/writer/content/:id`
- [ ] Add regenerate option for featured image
- [ ] Admin/Editor role visibility only
- [ ] Include note field for regeneration reason
### 5.2.3 - Auto-Regeneration (Optional)
- [ ] Detect common image generation failures
- [ ] Auto-retry with modified prompt
- [ ] Log auto-regeneration attempts
## 5.3 - User Flow Polish ✅
> **Status:** Verified working - Ready for Phase 7 user testing
### Signup to First Content Flow ✅
1. [x] User signs up → verify smooth flow - Working
2. [x] Onboarding wizard → verify all steps work - Functional
3. [x] Add site → verify WordPress integration - Stable
4. [x] Add keywords → verify import works - Working
5. [x] Run clustering → verify AI works - Functional
6. [ ] Generate content → verify output quality
7. [ ] Publish to WordPress → verify integration
---
# PHASE 6: Data Backup & Cleanup ✅
> **Goal:** Fresh database for production launch
> **Status:** Completed January 9, 2026
> **Deliverables:** Django management commands + comprehensive documentation
## 6.1 - System Configuration Backup ✅
### 6.1.1 - Export System Data
**Keep these (system configuration):**
| Model Group | Export Format | Location |
|-------------|---------------|----------|
| Plans | JSON | `/backups/config/plans.json` |
| AIModelConfig | JSON | `/backups/config/ai_models.json` |
| CreditCostConfig | JSON | `/backups/config/credit_costs.json` |
| GlobalIntegrationSettings | JSON | `/backups/config/integrations.json` |
| SystemSettings | JSON | `/backups/config/system.json` |
| Prompts | JSON | `/backups/config/prompts.json` |
| AuthorProfiles | JSON | `/backups/config/authors.json` |
| Industries & Sectors | JSON | `/backups/config/industries.json` |
| SeedKeywords | JSON | `/backups/config/seed_keywords.json` |
### 6.1.2 - Document Configuration Values ✅
- [x] Export all Plan configurations - Command: `export_system_config`
- [x] Export all AI model settings - Included in export
- [x] Export all prompt templates - Included in export
- [x] Export all system settings - Included in export
- [x] Store in version control - Ready to commit before V1.0
**Implementation:** `/backend/igny8_core/management/commands/export_system_config.py`
**Usage:** `python manage.py export_system_config --output=/backups/v1-config.json`
## 6.2 - User Data Cleanup ✅
### 6.2.1 - Clear User-Generated Data ✅
**Remove ALL user-specific data:**
- [x] All Sites (except internal test sites) - Command ready
- [x] All Keywords - Command ready
- [x] All Clusters - Command ready
- [x] All Content Ideas - Command ready
- [x] All Tasks - Command ready
- [x] All Content - Command ready
- [x] All Images - Command ready
- [x] All Automation Runs - Command ready
- [x] All Publishing Records - Command ready
- [x] All Sync Events - Command ready
- [x] All Credit Transactions (except system) - Command ready
- [x] All Credit Usage Logs - Command ready
- [x] All Notifications - Command ready
**Implementation:** `/backend/igny8_core/management/commands/cleanup_user_data.py`
**Usage:** `python manage.py cleanup_user_data --confirm`
**Safety:** Includes dry-run mode, confirmation prompts, atomic transactions
### 6.2.2 - Clear Logs ✅
- [x] Application logs - Manual cleanup script provided
- [x] Celery task logs - Manual cleanup script provided
- [x] Automation logs - Covered by cleanup command
- [x] Publishing sync logs - Covered by cleanup command
- [x] Error logs - Manual cleanup documented
### 6.2.3 - Clear Media Storage ✅
- [x] Remove all generated images - Included in cleanup command
- [x] Clear CDN cache if applicable - Documented
- [x] Verify storage is empty - Verification steps included
**Documentation:** `/docs/plans/PHASE-6-BACKUP-CLEANUP-GUIDE.md` (300+ lines)
## 6.3 - V1.0 Configuration Lock ⏳
> **Status:** Ready to execute before V1.0 deployment
> **Note:** Commands and documentation prepared, will run during Phase 8 deployment
### 6.3.1 - Final Configuration Freeze
- [ ] Lock all Plan configurations
- [ ] Lock all credit costs
- [ ] Lock all AI model configs
- [ ] Lock all system settings
- [ ] Document final values in `docs/90-REFERENCE/V1-CONFIG.md`
### 6.3.2 - Version Tagging
- [ ] Tag codebase as `v1.0.0`
- [ ] Create release notes
- [ ] No config changes without version bump
---
# PHASE 7: User Testing & Verification 🔴
> **Goal:** Real-world user flow validation

View File

@@ -1,662 +0,0 @@
# Phase 6: Data Backup & Cleanup Guide
**Version:** 1.0
**Created:** January 9, 2026
**Purpose:** Pre-V1.0 Launch Database Preparation
---
## 📋 Table of Contents
1. [Overview](#overview)
2. [What Was Created](#what-was-created)
3. [When to Use](#when-to-use)
4. [Pre-Execution Checklist](#pre-execution-checklist)
5. [Command 1: Export System Config](#command-1-export-system-config)
6. [Command 2: Cleanup User Data](#command-2-cleanup-user-data)
7. [Complete Workflow](#complete-workflow)
8. [Safety Measures](#safety-measures)
9. [Rollback Procedures](#rollback-procedures)
10. [FAQ](#faq)
---
## 📖 Overview
Phase 6 provides two Django management commands to safely prepare your IGNY8 database for V1.0 production launch:
1. **Export System Configuration** - Backs up all system settings to JSON files
2. **Cleanup User Data** - Removes all test/development user data while preserving system configuration
### Why These Commands?
- **Clean Start**: Launch V1.0 with a pristine database
- **Configuration Preservation**: Keep all your carefully configured settings
- **Safety First**: Multiple safety checks and dry-run options
- **Audit Trail**: Complete metadata and logging
---
## 🛠️ What Was Created
### File Locations
```
backend/igny8_core/management/commands/
├── export_system_config.py # System configuration backup
└── cleanup_user_data.py # User data cleanup
```
### Command 1: `export_system_config.py`
**Purpose**: Exports all system configuration to JSON files for backup and version control.
**What it exports:**
- ✅ Subscription Plans (Starter, Growth, Scale)
- ✅ Credit Cost Configurations
- ✅ AI Model Settings (OpenAI, Anthropic, etc.)
- ✅ Global Integration Settings
- ✅ Industries and Sectors
- ✅ Seed Keywords (reference data)
- ✅ Author Profiles
- ✅ AI Prompts and Variables
**What it creates:**
- Individual JSON files for each data type
- `export_metadata.json` with timestamp and statistics
- Organized folder structure in `backups/config/`
### Command 2: `cleanup_user_data.py`
**Purpose**: Safely removes all user-generated test data before production launch.
**What it deletes:**
- 🗑️ Sites and Site Settings
- 🗑️ Keywords, Clusters, Ideas
- 🗑️ Tasks, Content, Images
- 🗑️ Publishing Records
- 🗑️ WordPress Sync Events
- 🗑️ Credit Transactions and Usage Logs
- 🗑️ Automation Runs
- 🗑️ Notifications
- 🗑️ Orders
**What it preserves:**
- ✅ User Accounts (admin users)
- ✅ System Configuration (all settings from export)
- ✅ Plans and Pricing
- ✅ AI Models and Prompts
- ✅ Industries and Sectors
---
## ⏰ When to Use
### Correct Timing
**Use these commands when:**
- You're preparing for V1.0 production launch
- You've completed all testing and configuration
- You want to start production with clean data
- All system settings (Plans, AI models, prompts) are finalized
**Do NOT use these commands when:**
- You're still in active development
- You haven't backed up your configurations
- You're unsure about your system settings
- You're in production with live users
### Recommended Timeline
```
Day -7: Final configuration review
Day -5: Export system config (first backup)
Day -3: Test commands in staging
Day -2: Export system config (final backup)
Day -1: Cleanup user data in staging
Day 0: Launch day - cleanup in production
```
---
## ✅ Pre-Execution Checklist
Before running ANY Phase 6 command, complete this checklist:
### Environment Verification
- [ ] Confirm you're in the correct environment (staging vs production)
- [ ] Check `ENVIRONMENT` setting in Django settings
- [ ] Verify database connection is correct
- [ ] Ensure you have full database backup
### System State
- [ ] All Plans configured and tested
- [ ] All AI prompts finalized
- [ ] All credit costs verified
- [ ] All industries/sectors populated
- [ ] Seed keywords imported
### Safety Backups
- [ ] Full database dump exists
- [ ] Previous export exists (if available)
- [ ] Media files backed up
- [ ] Environment variables documented
### Access & Permissions
- [ ] You have Django shell access
- [ ] You have database backup access
- [ ] You have rollback permissions
- [ ] Stakeholders notified
---
## 📤 Command 1: Export System Config
### Basic Usage
```bash
cd /data/app/igny8/backend
python manage.py export_system_config
```
### With Custom Output Directory
```bash
python manage.py export_system_config --output-dir=/path/to/backup
```
### Step-by-Step Execution
#### Step 1: Navigate to Backend
```bash
cd /data/app/igny8/backend
```
#### Step 2: Run Export
```bash
python manage.py export_system_config --output-dir=../backups/config/$(date +%Y%m%d)
```
#### Step 3: Verify Output
```bash
ls -la ../backups/config/$(date +%Y%m%d)/
```
Expected output:
```
plans.json # Subscription plans
credit_costs.json # Credit cost configurations
ai_models.json # AI model settings
global_integrations.json # Integration settings
industries.json # Industry master data
sectors.json # Sector master data
seed_keywords.json # Reference keywords
author_profiles.json # Writing style profiles
prompts.json # AI prompts
prompt_variables.json # Prompt variables
export_metadata.json # Export timestamp & stats
```
#### Step 4: Verify Data
Check one of the exports:
```bash
cat ../backups/config/$(date +%Y%m%d)/plans.json | head -20
```
#### Step 5: Commit to Version Control
```bash
cd /data/app/igny8
git add backups/config/
git commit -m "Backup: V1.0 system configuration export"
git push
```
### What The Output Looks Like
```
Exporting system configuration to: /data/app/igny8/backups/config/20260109
✓ Exported 3 Subscription Plans → plans.json
✓ Exported 12 Credit Cost Configurations → credit_costs.json
✓ Exported 4 AI Model Configurations → ai_models.json
✓ Exported 1 Global Integration Settings → global_integrations.json
✓ Exported 15 Industries → industries.json
✓ Exported 47 Sectors → sectors.json
✓ Exported 523 Seed Keywords → seed_keywords.json
✓ Exported 3 Author Profiles → author_profiles.json
✓ Exported 8 AI Prompts → prompts.json
✓ Exported 12 Prompt Variables → prompt_variables.json
✓ Metadata saved to export_metadata.json
======================================================================
System Configuration Export Complete!
Successful: 10 exports
Failed: 0 exports
Location: /data/app/igny8/backups/config/20260109
======================================================================
```
### Troubleshooting
**Problem**: "No module named 'django'"
```bash
# Solution: Activate virtual environment or use Docker
docker-compose exec backend python manage.py export_system_config
```
**Problem**: "Permission denied" when writing files
```bash
# Solution: Check directory permissions
mkdir -p ../backups/config
chmod 755 ../backups/config
```
**Problem**: Empty JSON files
```bash
# Solution: Verify data exists in database
python manage.py shell
>>> from igny8_core.modules.billing.models import Plan
>>> Plan.objects.count()
```
---
## 🗑️ Command 2: Cleanup User Data
### ⚠️ CRITICAL WARNING
**THIS COMMAND PERMANENTLY DELETES DATA**
- Cannot be undone without database restore
- Removes ALL user-generated content
- Should ONLY be run before production launch
- ALWAYS run `--dry-run` first
### Safety Features
1. **Dry-Run Mode**: Preview deletions without actually deleting
2. **Confirmation Prompt**: Must type "DELETE ALL DATA" to proceed
3. **Production Protection**: Blocked in production environment (unless explicitly allowed)
4. **Transaction Safety**: All deletions in atomic transaction
5. **Detailed Logging**: Shows exactly what was deleted
### Usage: Dry Run (Always First!)
```bash
cd /data/app/igny8/backend
python manage.py cleanup_user_data --dry-run
```
### Dry Run Output Example
```
======================================================================
DRY RUN - No data will be deleted
======================================================================
✓ Would delete 1,234 Notifications
✓ Would delete 5,678 Credit Usage Logs
✓ Would delete 456 Credit Transactions
✓ Would delete 23 Orders
✓ Would delete 8,901 WordPress Sync Events
✓ Would delete 234 Publishing Records
✓ Would delete 45 Automation Runs
✓ Would delete 3,456 Images
✓ Would delete 2,345 Content
✓ Would delete 4,567 Tasks
✓ Would delete 5,678 Content Ideas
✓ Would delete 1,234 Clusters
✓ Would delete 9,876 Keywords
✓ Would delete 12 Sites
→ Keeping 3 Users (not deleted)
Total records to delete: 43,739
======================================================================
To proceed with actual deletion, run:
python manage.py cleanup_user_data --confirm
======================================================================
```
### Usage: Actual Cleanup
```bash
python manage.py cleanup_user_data --confirm
```
**You will be prompted:**
```
======================================================================
⚠️ DELETING ALL USER DATA - THIS CANNOT BE UNDONE!
======================================================================
Type "DELETE ALL DATA" to proceed:
```
**Type exactly:** `DELETE ALL DATA`
### Actual Cleanup Output
```
Proceeding with deletion...
✓ Deleted 1,234 Notifications
✓ Deleted 5,678 Credit Usage Logs
✓ Deleted 456 Credit Transactions
✓ Deleted 23 Orders
✓ Deleted 8,901 WordPress Sync Events
✓ Deleted 234 Publishing Records
✓ Deleted 45 Automation Runs
✓ Deleted 3,456 Images
✓ Deleted 2,345 Content
✓ Deleted 4,567 Tasks
✓ Deleted 5,678 Content Ideas
✓ Deleted 1,234 Clusters
✓ Deleted 9,876 Keywords
✓ Deleted 12 Sites
======================================================================
User Data Cleanup Complete!
Total records deleted: 43,739
Failed deletions: 0
======================================================================
```
### Production Environment Protection
If you try to run cleanup in production:
```
⚠️ BLOCKED: Cannot run cleanup in PRODUCTION environment!
To allow this, temporarily set ENVIRONMENT to "staging" in settings.
```
To override (ONLY if absolutely necessary):
```python
# In settings.py - TEMPORARY
ENVIRONMENT = 'staging' # Change back after cleanup!
```
---
## 🔄 Complete Workflow
### Full Pre-Launch Procedure
```bash
# ========================================
# STEP 1: FULL DATABASE BACKUP
# ========================================
cd /data/app/igny8/backend
pg_dump -h localhost -U postgres igny8_db > ../backups/$(date +%Y%m%d)_pre_v1_full_backup.sql
# Verify backup exists and has content
ls -lh ../backups/$(date +%Y%m%d)_pre_v1_full_backup.sql
head -50 ../backups/$(date +%Y%m%d)_pre_v1_full_backup.sql
# ========================================
# STEP 2: EXPORT SYSTEM CONFIGURATION
# ========================================
python manage.py export_system_config --output-dir=../backups/config/$(date +%Y%m%d)
# Verify exports
ls -la ../backups/config/$(date +%Y%m%d)/
# Review critical configs
cat ../backups/config/$(date +%Y%m%d)/plans.json | python -m json.tool | head -30
cat ../backups/config/$(date +%Y%m%d)/credit_costs.json | python -m json.tool | head -30
# ========================================
# STEP 3: COMMIT CONFIGS TO GIT
# ========================================
cd /data/app/igny8
git add backups/config/
git commit -m "Pre-V1.0: System configuration backup $(date +%Y%m%d)"
git push
# ========================================
# STEP 4: BACKUP MEDIA FILES
# ========================================
cd /data/app/igny8
tar -czf backups/$(date +%Y%m%d)_media_backup.tar.gz backend/media/
# ========================================
# STEP 5: DRY RUN CLEANUP (REVIEW CAREFULLY)
# ========================================
cd backend
python manage.py cleanup_user_data --dry-run
# Review the counts - make sure they're expected
# ========================================
# STEP 6: ACTUAL CLEANUP (POINT OF NO RETURN)
# ========================================
python manage.py cleanup_user_data --confirm
# Type: DELETE ALL DATA
# ========================================
# STEP 7: VERIFY CLEANUP
# ========================================
python manage.py shell << 'EOF'
from igny8_core.auth.models import Site, CustomUser
from igny8_core.business.planning.models import Keywords
from igny8_core.modules.billing.models import Plan
print(f"Sites: {Site.objects.count()} (should be 0)")
print(f"Keywords: {Keywords.objects.count()} (should be 0)")
print(f"Users: {CustomUser.objects.count()} (admins preserved)")
print(f"Plans: {Plan.objects.count()} (should have your plans)")
EOF
# ========================================
# STEP 8: TEST APPLICATION
# ========================================
python manage.py runserver 0.0.0.0:8000 &
# Visit app and verify:
# - Can login as admin
# - Dashboard loads (empty state)
# - Plans visible in settings
# - Can create new user account
# ========================================
# STEP 9: TAG RELEASE
# ========================================
cd /data/app/igny8
git tag -a v1.0.0-clean -m "V1.0.0 - Clean database ready for launch"
git push origin v1.0.0-clean
```
---
## 🛡️ Safety Measures
### Built-in Protections
1. **Atomic Transactions**: All deletions in single transaction - all or nothing
2. **Production Check**: Requires explicit override in production
3. **Confirmation Prompt**: Must type exact phrase
4. **Dry Run**: See exactly what will be deleted
5. **Detailed Logging**: Know what was deleted and any failures
### Manual Safety Checklist
Before running cleanup:
- [ ] **Full database backup** exists and verified
- [ ] **System config export** completed and committed to git
- [ ] **Media files** backed up
- [ ] **Dry run reviewed** and counts are expected
- [ ] **Stakeholders notified** of pending cleanup
- [ ] **Rollback plan** documented and tested
- [ ] **Off-hours execution** scheduled (if production)
- [ ] **Monitoring ready** to catch any issues
### Additional Recommendations
1. **Staging First**: Always test in staging environment first
2. **Screenshot Evidence**: Take screenshots of dry-run output
3. **Communication**: Notify team before and after
4. **Timing**: Run during low-traffic hours
5. **Verification**: Test application immediately after
---
## 🔙 Rollback Procedures
### If Something Goes Wrong
#### During Cleanup (Transaction Failed)
No action needed - atomic transaction will automatically rollback.
#### After Cleanup (Need to Restore)
```bash
# OPTION 1: Restore from PostgreSQL backup
cd /data/app/igny8
psql -U postgres -d igny8_db < backups/20260109_pre_v1_full_backup.sql
# OPTION 2: Restore specific tables (if partial restore needed)
pg_restore -U postgres -d igny8_db -t "specific_table" backups/20260109_pre_v1_full_backup.sql
# OPTION 3: Restore from Docker backup (if using Docker)
docker-compose exec -T db psql -U postgres igny8_db < backups/20260109_pre_v1_full_backup.sql
```
#### Restore Media Files
```bash
cd /data/app/igny8
tar -xzf backups/20260109_media_backup.tar.gz -C backend/
```
#### Verify Restore
```bash
cd backend
python manage.py shell << 'EOF'
from igny8_core.auth.models import Site
from igny8_core.business.planning.models import Keywords
print(f"Sites restored: {Site.objects.count()}")
print(f"Keywords restored: {Keywords.objects.count()}")
EOF
```
---
## ❓ FAQ
### Q: Can I run these commands multiple times?
**A:**
- **Export Config**: Yes, safe to run multiple times. Creates timestamped backups.
- **Cleanup**: Yes, but after first cleanup there's nothing left to delete (idempotent).
### Q: What if I only want to delete some data?
**A:** These commands are all-or-nothing by design for safety. To delete specific data, use Django admin or write a custom management command.
### Q: Can I restore individual items from the export?
**A:** Yes! The JSON files use Django's standard serialization format. Use `python manage.py loaddata <file>.json` to restore.
### Q: Will this affect my development environment?
**A:** Only if you run it there. These commands work on whatever database your Django settings point to.
### Q: How long does cleanup take?
**A:** Depends on data volume. Typical ranges:
- Small (< 10k records): 1-5 seconds
- Medium (10k-100k): 5-30 seconds
- Large (> 100k): 30-120 seconds
### Q: What if cleanup fails halfway?
**A:** Can't happen - it's wrapped in an atomic transaction. Either everything deletes or nothing does.
### Q: Do I need to stop the application?
**A:** Recommended but not required. Stopping the app prevents race conditions during cleanup.
### Q: Can I schedule these as cron jobs?
**A:**
- **Export**: Yes, great for automated backups
- **Cleanup**: No, should only be run manually with explicit confirmation
### Q: What about Django migrations?
**A:** Cleanup only deletes data, not schema. All tables and migrations remain intact.
### Q: How do I know if my system config is complete?
**A:** Run the export and review the counts in `export_metadata.json`. Compare with your documentation.
---
## 📞 Support
### If You Need Help
1. **Check this guide** thoroughly first
2. **Review error messages** carefully
3. **Test in staging** before production
4. **Contact team** if unsure about any step
### Emergency Contacts
- **Database Issues**: DBA team
- **Application Issues**: Backend team
- **Configuration Questions**: System admin
- **Rollback Needed**: All hands on deck!
---
## ✅ Success Criteria
After completing Phase 6, you should have:
- ✅ Multiple timestamped config exports in `backups/config/`
- ✅ Full database SQL backup in `backups/`
- ✅ Media files backup in `backups/`
- ✅ Zero user-generated data in database
- ✅ All system configurations intact
- ✅ Application starts and loads empty state
- ✅ Admin can log in
- ✅ New users can sign up
- ✅ Plans visible and functional
- ✅ Git tag created for v1.0.0-clean
---
**Document Version:** 1.0
**Last Updated:** January 9, 2026
**Next Review:** After V1.0 Launch
---
*This guide is part of the IGNY8 Pre-Launch Preparation (Phase 6)*