# IGNY8 Application Repository **Repository Name:** `igny8-app` **Purpose:** Custom application code for the IGNY8 Content AI Platform --- ## Overview This repository contains ONLY the custom business logic for IGNY8. It does not contain: - Dockerfiles (in stack repo) - package.json / requirements.txt (in stack repo) - Vite/TypeScript configs (in stack repo) - Docker compose files (in stack repo) --- ## Complete Folder Structure ``` igny8-app/ │ ├── README.md # App overview ├── CHANGELOG.md # Version history ├── .gitignore # Git ignore rules ├── .env.example # Environment template │ ├── backend/ │ └── igny8_core/ # Django application │ ├── __init__.py │ ├── settings.py # Django settings │ ├── urls.py # Root URL routing │ ├── celery.py # Celery configuration │ ├── wsgi.py # WSGI entry point │ ├── asgi.py # ASGI entry point │ ├── tasks.py # Root Celery tasks │ │ │ ├── auth/ # Authentication module │ │ ├── __init__.py │ │ ├── models.py # User, Account, Site, Sector, Plan │ │ ├── views.py # Login, register, password reset │ │ ├── serializers.py # DRF serializers │ │ ├── middleware.py # AccountContextMiddleware │ │ ├── urls.py # Auth URL routes │ │ └── migrations/ # Database migrations │ │ │ ├── api/ # API infrastructure │ │ ├── __init__.py │ │ ├── base.py # Base ViewSets (AccountModelViewSet) │ │ ├── authentication.py # JWT, API key auth │ │ ├── pagination.py # Unified pagination │ │ └── tests/ # API tests │ │ │ ├── ai/ # AI engine │ │ ├── __init__.py │ │ ├── engine.py # AIEngine orchestrator │ │ ├── registry.py # Function registry │ │ ├── model_registry.py # AI model configuration │ │ ├── progress.py # Progress tracking │ │ └── functions/ # AI function implementations │ │ ├── __init__.py │ │ ├── auto_cluster.py │ │ ├── generate_ideas.py │ │ ├── generate_content.py │ │ └── ... │ │ │ ├── modules/ # Feature modules (API layer) │ │ ├── __init__.py │ │ ├── planner/ # Keywords, Clusters, Ideas │ │ │ ├── models.py │ │ │ ├── views.py │ │ │ ├── serializers.py │ │ │ ├── urls.py │ │ │ └── migrations/ │ │ ├── writer/ # Tasks, Content, Images │ │ ├── billing/ # Credits, usage, transactions │ │ ├── integration/ # WordPress integration │ │ ├── system/ # Settings, prompts, AI config │ │ ├── linker/ # Internal linking │ │ ├── optimizer/ # Content optimization │ │ └── publisher/ # Publishing pipeline │ │ │ ├── business/ # Business logic (services) │ │ ├── __init__.py │ │ ├── automation/ # 7-stage automation pipeline │ │ ├── billing/ # Credit service │ │ ├── content/ # Content generation │ │ ├── integration/ # Sync services │ │ ├── linking/ # Link processing │ │ ├── notifications/ # Notification system │ │ ├── optimization/ # Content optimization │ │ ├── planning/ # Clustering, ideas │ │ └── publishing/ # Publishing orchestration │ │ │ ├── middleware/ # Custom middleware │ │ ├── __init__.py │ │ ├── request_id.py # X-Request-ID header │ │ └── resource_tracker.py # Resource tracking │ │ │ ├── tasks/ # Celery background tasks │ │ ├── __init__.py │ │ └── *.py │ │ │ ├── admin/ # Django admin customization │ ├── common/ # Shared utilities │ ├── management/ # Django management commands │ │ └── commands/ │ ├── utils/ # Helper functions │ ├── urls/ # URL routing modules │ ├── static/ # App static files │ └── templates/ # Django templates │ ├── frontend/ │ └── src/ # React application │ ├── main.tsx # Entry point │ ├── App.tsx # Root component, routing │ ├── index.css # Global styles, Tailwind │ ├── vite-env.d.ts # Vite type definitions │ ├── svg.d.ts # SVG type definitions │ │ │ ├── api/ # API client modules │ │ ├── linker.api.ts │ │ ├── optimizer.api.ts │ │ └── ... │ │ │ ├── services/ # Core services │ │ ├── api.ts # Main API service │ │ └── notifications.api.ts # Notification API │ │ │ ├── store/ # Zustand state stores │ │ ├── authStore.ts # Authentication state │ │ ├── siteStore.ts # Active site │ │ ├── sectorStore.ts # Active sector │ │ ├── billingStore.ts # Billing state │ │ ├── moduleStore.ts # Module enable/disable │ │ ├── notificationStore.ts # Notifications │ │ └── ... │ │ │ ├── pages/ # Route pages │ │ ├── Dashboard/ │ │ ├── Planner/ │ │ ├── Writer/ │ │ ├── Automation/ │ │ ├── Linker/ │ │ ├── Optimizer/ │ │ ├── Settings/ │ │ ├── Billing/ │ │ └── Auth/ │ │ │ ├── components/ # Reusable components │ │ ├── common/ # Shared UI components │ │ ├── dashboard/ # Dashboard widgets │ │ ├── header/ # Header components │ │ └── shared/ # Cross-feature components │ │ │ ├── layout/ # Layout components │ │ ├── AppLayout.tsx │ │ ├── AppHeader.tsx │ │ └── AppSidebar.tsx │ │ │ ├── hooks/ # Custom React hooks │ ├── context/ # React contexts │ ├── config/ # App configuration │ ├── icons/ # Icon components │ ├── styles/ # CSS modules/styles │ ├── utils/ # Utility functions │ ├── types/ # TypeScript types │ ├── templates/ # Content templates │ ├── modules/ # Feature modules │ ├── marketing/ # Marketing site │ │ ├── index.tsx │ │ ├── MarketingApp.tsx │ │ ├── config/ │ │ ├── components/ │ │ ├── layout/ │ │ ├── pages/ │ │ ├── images/ │ │ └── styles/ │ │ │ └── __tests__/ # Test files │ ├── public/ # Public static assets │ ├── favicon.ico │ ├── logo.svg │ └── images/ │ └── docs/ # Documentation ├── 00-SYSTEM/ │ └── ARCHITECTURE.md ├── 10-MODULES/ ├── 20-API/ ├── 30-FRONTEND/ ├── 40-WORKFLOWS/ ├── 50-DEPLOYMENT/ │ ├── TWO-REPO-ARCHITECTURE.md │ ├── INFRASTRUCTURE-STACK.md │ ├── IGNY8-APP-STRUCTURE.md # This file │ ├── DOCKER-DEPLOYMENT.md │ └── ENVIRONMENT-SETUP.md ├── 90-REFERENCE/ └── plans/ ``` --- ## Deployment to New Server ### Prerequisites - Stack already installed (see INFRASTRUCTURE-STACK.md) - Server has `/data/stack/igny8-stack/` ready - Docker network `igny8_net` exists ### Step-by-Step Deployment ``` 1. Copy app code to server Option A: Git clone cd /data/app git clone https://github.com/yourorg/igny8-app.git igny8 Option B: Rsync from existing server rsync -avz --exclude='.git' \ --exclude='node_modules' \ --exclude='__pycache__' \ --exclude='*.pyc' \ --exclude='staticfiles' \ --exclude='dist' \ old-server:/data/app/igny8/ /data/app/igny8/ 2. Create symlinks to stack cd /data/stack/igny8-stack ./scripts/link-app.sh igny8 3. Configure environment cd /data/app/igny8 cp .env.example .env nano .env # Set your secrets 4. Install frontend dependencies docker exec igny8_frontend npm install 5. Run database migrations docker exec igny8_backend python manage.py migrate 6. Create superuser (first time only) docker exec -it igny8_backend python manage.py createsuperuser 7. Collect static files docker exec igny8_backend python manage.py collectstatic --noinput 8. Start all services docker compose -f docker-compose.app.yml up -d 9. Verify curl https://api.igny8.com/api/v1/system/status/ ``` --- ## What Gets Copied vs Symlinked ### Copied (Your Code) | Path | Content | |------|---------| | `backend/igny8_core/` | All Django app code | | `frontend/src/` | All React code | | `public/` | Static assets | | `docs/` | Documentation | | `.env` | Environment config | ### Symlinked (From Stack) | App Path | Stack Path | |----------|------------| | `backend/Dockerfile` | `stack/backend/Dockerfile` | | `backend/requirements.txt` | `stack/backend/requirements.txt` | | `backend/manage.py` | `stack/backend/manage.py` | | `frontend/Dockerfile.dev` | `stack/frontend/Dockerfile.dev` | | `frontend/package.json` | `stack/frontend/package.json` | | `frontend/vite.config.ts` | `stack/frontend/vite.config.ts` | | `frontend/tsconfig*.json` | `stack/frontend/tsconfig*.json` | | `docker-compose.app.yml` | `stack/docker/docker-compose.app.yml` | --- ## Updating App on Existing Server ### Code Update (Most Common) ``` cd /data/app/igny8 git pull # Get latest code # If migrations changed: docker exec igny8_backend python manage.py migrate # If frontend deps changed: docker exec igny8_frontend npm install # Restart to apply: docker compose restart ``` ### Full Rebuild (After Major Changes) ``` cd /data/app/igny8 docker compose down docker compose build --no-cache docker compose up -d ``` --- ## Backup Before Migration ### What to Backup | Item | Command/Method | |------|----------------| | Database | `pg_dump igny8_db > backup.sql` | | App code | `git push` or `rsync` | | Uploads | Copy `/data/app/igny8/backend/media/` | | Environment | Copy `.env` file | ### Full Backup Script ``` # On old server DATE=$(date +%Y%m%d) mkdir -p /data/backups/$DATE # Database docker exec igny8_postgres pg_dump -U igny8 igny8_db > /data/backups/$DATE/db.sql # App code (excluding generated files) tar -czf /data/backups/$DATE/app.tar.gz \ --exclude='node_modules' \ --exclude='__pycache__' \ --exclude='staticfiles' \ --exclude='dist' \ --exclude='.git' \ /data/app/igny8/ # Environment cp /data/app/igny8/.env /data/backups/$DATE/ echo "Backup complete: /data/backups/$DATE/" ``` --- ## Related Documentation - [TWO-REPO-ARCHITECTURE.md](TWO-REPO-ARCHITECTURE.md) - Why this structure - [INFRASTRUCTURE-STACK.md](INFRASTRUCTURE-STACK.md) - Stack repo details - [DOCKER-DEPLOYMENT.md](DOCKER-DEPLOYMENT.md) - Container details - [ARCHITECTURE.md](../00-SYSTEM/ARCHITECTURE.md) - System architecture