wokring models and image genration model and admin apges
This commit is contained in:
@@ -0,0 +1,360 @@
|
||||
# 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
|
||||
@@ -0,0 +1,219 @@
|
||||
# Infrastructure Stack Repository
|
||||
|
||||
**Repository Name:** `igny8-stack`
|
||||
**Purpose:** Reusable tech stack for Django + React applications
|
||||
|
||||
---
|
||||
|
||||
## Complete Folder Structure
|
||||
|
||||
```
|
||||
igny8-stack/
|
||||
│
|
||||
├── README.md # Stack overview and quick start
|
||||
├── install.sh # Main installation script
|
||||
├── uninstall.sh # Cleanup script
|
||||
│
|
||||
├── config/
|
||||
│ ├── .env.example # Environment variables template
|
||||
│ │
|
||||
│ └── caddy/
|
||||
│ └── Caddyfile # Reverse proxy configuration
|
||||
│
|
||||
├── docker/
|
||||
│ ├── docker-compose.infra.yml # Shared services (Postgres, Redis, Caddy)
|
||||
│ └── docker-compose.app.yml # App services template
|
||||
│
|
||||
├── backend/
|
||||
│ ├── Dockerfile # Python 3.11 slim + dependencies
|
||||
│ ├── requirements.txt # Django, DRF, Celery, Gunicorn, etc.
|
||||
│ ├── manage.py # Django CLI entry point
|
||||
│ ├── container_startup.sh # Container entrypoint script
|
||||
│ └── create_groups.py # Initial permission groups setup
|
||||
│
|
||||
├── frontend/
|
||||
│ ├── Dockerfile.dev # Vite dev server with HMR
|
||||
│ ├── Dockerfile.prod # Production build with Caddy
|
||||
│ ├── Dockerfile.marketing.dev # Marketing site dev server
|
||||
│ ├── package.json # React, Vite, Tailwind, Zustand, etc.
|
||||
│ ├── package-lock.json # Locked dependency versions
|
||||
│ ├── vite.config.ts # Vite configuration
|
||||
│ ├── tsconfig.json # TypeScript base config
|
||||
│ ├── tsconfig.app.json # App TypeScript config
|
||||
│ ├── tsconfig.node.json # Node TypeScript config
|
||||
│ ├── postcss.config.js # PostCSS for Tailwind
|
||||
│ ├── eslint.config.js # ESLint rules
|
||||
│ ├── index.html # Main app HTML template
|
||||
│ └── marketing.html # Marketing site HTML template
|
||||
│
|
||||
└── scripts/
|
||||
├── build-images.sh # Build all Docker images
|
||||
├── migrate.sh # Run Django migrations
|
||||
├── backup-db.sh # Database backup utility
|
||||
├── restore-db.sh # Database restore utility
|
||||
└── health-check.sh # System health check
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## File Purposes
|
||||
|
||||
### Root Files
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `install.sh` | Creates directories, symlinks, builds images, sets up network |
|
||||
| `uninstall.sh` | Removes symlinks and cleans up (keeps data) |
|
||||
|
||||
### Config Folder
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `.env.example` | Template for environment variables (DB passwords, secrets, domains) |
|
||||
| `caddy/Caddyfile` | Routes domains to containers, handles SSL, WebSocket proxying |
|
||||
|
||||
### Docker Folder
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `docker-compose.infra.yml` | Postgres, Redis, Caddy, PgAdmin, FileBrowser, Portainer |
|
||||
| `docker-compose.app.yml` | Backend, Frontend, Celery Worker, Celery Beat, Flower |
|
||||
|
||||
### Backend Folder
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `Dockerfile` | Python 3.11 slim, installs requirements, runs Gunicorn |
|
||||
| `requirements.txt` | All Python dependencies (Django 5.x, DRF, Celery, etc.) |
|
||||
| `manage.py` | Django management command entry point |
|
||||
| `container_startup.sh` | Logs startup, runs migrations if needed |
|
||||
| `create_groups.py` | Creates initial Django permission groups |
|
||||
|
||||
### Frontend Folder
|
||||
|
||||
| File | Purpose |
|
||||
|------|---------|
|
||||
| `Dockerfile.dev` | Node 18, Vite dev server with hot reload |
|
||||
| `Dockerfile.prod` | Multi-stage build, Caddy serves static files |
|
||||
| `Dockerfile.marketing.dev` | Marketing site dev server (port 5174) |
|
||||
| `package.json` | All npm dependencies |
|
||||
| `vite.config.ts` | Build config, HMR settings, code splitting |
|
||||
| `tsconfig*.json` | TypeScript compiler settings |
|
||||
| `postcss.config.js` | Tailwind CSS processing |
|
||||
| `eslint.config.js` | Code linting rules |
|
||||
| `index.html` | Main app entry HTML |
|
||||
| `marketing.html` | Marketing site entry HTML |
|
||||
|
||||
### Scripts Folder
|
||||
|
||||
| Script | Purpose |
|
||||
|--------|---------|
|
||||
| `build-images.sh` | Builds all Docker images with proper tags |
|
||||
| `migrate.sh` | Runs Django migrations inside container |
|
||||
| `backup-db.sh` | Dumps PostgreSQL database to backup file |
|
||||
| `restore-db.sh` | Restores database from backup file |
|
||||
| `health-check.sh` | Checks all services are running |
|
||||
|
||||
---
|
||||
|
||||
## New Server Installation
|
||||
|
||||
### Prerequisites
|
||||
- Ubuntu 22.04+ or Debian 12+
|
||||
- Docker and Docker Compose installed
|
||||
- Git installed
|
||||
- Domain DNS pointing to server IP
|
||||
|
||||
### Step-by-Step Installation
|
||||
|
||||
```
|
||||
1. Create directories
|
||||
mkdir -p /data/stack /data/app /data/logs
|
||||
|
||||
2. Clone stack repository
|
||||
cd /data/stack
|
||||
git clone https://github.com/yourorg/igny8-stack.git
|
||||
|
||||
3. Run installation script
|
||||
cd igny8-stack
|
||||
chmod +x install.sh
|
||||
./install.sh
|
||||
|
||||
4. Verify installation
|
||||
docker images # Should show app-backend, app-frontend images
|
||||
docker network ls # Should show igny8_net
|
||||
ls -la /data/app/ # Should show prepared structure
|
||||
```
|
||||
|
||||
### What install.sh Does
|
||||
|
||||
1. Creates Docker network (`igny8_net`)
|
||||
2. Creates directory structure under `/data/app/`
|
||||
3. Builds Docker images:
|
||||
- `app-backend:latest`
|
||||
- `app-frontend-dev:latest`
|
||||
- `app-marketing-dev:latest`
|
||||
4. Starts infrastructure services (Postgres, Redis, Caddy)
|
||||
5. Creates symlinks for app folder structure
|
||||
6. Prints next steps
|
||||
|
||||
---
|
||||
|
||||
## Updating Stack on Existing Server
|
||||
|
||||
```
|
||||
1. Pull latest changes
|
||||
cd /data/stack/igny8-stack
|
||||
git pull
|
||||
|
||||
2. Rebuild images if Dockerfile changed
|
||||
./scripts/build-images.sh
|
||||
|
||||
3. Restart containers to use new images
|
||||
cd /data/app/igny8
|
||||
docker compose -f docker-compose.app.yml down
|
||||
docker compose -f docker-compose.app.yml up -d
|
||||
|
||||
4. Verify
|
||||
docker ps
|
||||
./scripts/health-check.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Customizing for Different Apps
|
||||
|
||||
The stack is designed to run any Django + React application. To use it for a different app (not igny8):
|
||||
|
||||
1. Clone stack to new server
|
||||
2. Run `install.sh`
|
||||
3. Clone your app repo to `/data/app/yourapp/`
|
||||
4. Update `.env` with your app's settings
|
||||
5. Update Caddyfile with your domains
|
||||
6. Start containers
|
||||
|
||||
The stack doesn't contain any igny8-specific logic - it's a generic Django+React runtime environment.
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Key variables to set in `.env`:
|
||||
|
||||
| Variable | Purpose | Example |
|
||||
|----------|---------|---------|
|
||||
| `DB_HOST` | PostgreSQL host | `postgres` |
|
||||
| `DB_NAME` | Database name | `igny8_db` |
|
||||
| `DB_USER` | Database user | `igny8` |
|
||||
| `DB_PASSWORD` | Database password | `secure_password` |
|
||||
| `REDIS_HOST` | Redis host | `redis` |
|
||||
| `SECRET_KEY` | Django secret key | `random_50_char_string` |
|
||||
| `DOMAIN` | Primary domain | `igny8.com` |
|
||||
| `DEBUG` | Debug mode | `False` |
|
||||
|
||||
---
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [TWO-REPO-ARCHITECTURE.md](TWO-REPO-ARCHITECTURE.md) - Why two repos
|
||||
- [IGNY8-APP-STRUCTURE.md](IGNY8-APP-STRUCTURE.md) - App-specific code structure
|
||||
@@ -0,0 +1,150 @@
|
||||
# Two-Repository Architecture
|
||||
|
||||
**Purpose:** Separate tech stack infrastructure from custom application code for easy server migration and deployment.
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
Instead of one monolithic repository, split into two:
|
||||
|
||||
| Repository | Contains | Changes | Deployment |
|
||||
|------------|----------|---------|------------|
|
||||
| `igny8-stack` | Docker, configs, dependencies | Rarely | Clone once per server |
|
||||
| `igny8-app` | Your custom business logic | Frequently | Copy to deploy |
|
||||
|
||||
---
|
||||
|
||||
## Why This Architecture?
|
||||
|
||||
### Current Problem
|
||||
- Everything mixed together (Dockerfiles, configs, your code)
|
||||
- To deploy to new server, must copy everything
|
||||
- Hard to distinguish "what's mine" vs "what's framework"
|
||||
|
||||
### Solution Benefits
|
||||
- **Clean separation**: Stack vs App code
|
||||
- **Easy migration**: Just copy app folder after stack is installed
|
||||
- **Version independence**: Update stack without touching app
|
||||
- **Reusable stack**: Same stack can run different apps on different servers
|
||||
|
||||
---
|
||||
|
||||
## How It Works
|
||||
|
||||
### Server Structure After Setup
|
||||
|
||||
```
|
||||
/data/
|
||||
├── stack/
|
||||
│ └── igny8-stack/ # Cloned from stack repo (read-only)
|
||||
│
|
||||
├── app/
|
||||
│ └── igny8/ # Your app code + symlinks to stack
|
||||
│ ├── backend/
|
||||
│ │ ├── Dockerfile → symlink to stack
|
||||
│ │ ├── requirements.txt → symlink to stack
|
||||
│ │ ├── manage.py → symlink to stack
|
||||
│ │ └── igny8_core/ # YOUR CODE
|
||||
│ │
|
||||
│ └── frontend/
|
||||
│ ├── package.json → symlink to stack
|
||||
│ ├── vite.config.ts → symlink to stack
|
||||
│ └── src/ # YOUR CODE
|
||||
│
|
||||
└── logs/
|
||||
```
|
||||
|
||||
### Symlinks Explained
|
||||
|
||||
The `install.sh` script creates symbolic links from your app folder to the stack folder. This means:
|
||||
- Stack files (Dockerfile, package.json, etc.) live in one place
|
||||
- Your app folder references them via symlinks
|
||||
- Docker sees a complete project structure
|
||||
- You only manage your custom code
|
||||
|
||||
---
|
||||
|
||||
## Migration Workflow
|
||||
|
||||
### On New Server
|
||||
|
||||
```
|
||||
Step 1: Install Stack (one-time)
|
||||
────────────────────────────────
|
||||
cd /data/stack
|
||||
git clone https://your-repo/igny8-stack.git
|
||||
cd igny8-stack
|
||||
./install.sh
|
||||
|
||||
Step 2: Deploy Your App
|
||||
────────────────────────────────
|
||||
cd /data/app
|
||||
git clone https://your-repo/igny8-app.git igny8
|
||||
# OR: rsync/scp from old server
|
||||
|
||||
Step 3: Configure
|
||||
────────────────────────────────
|
||||
cp .env.example .env
|
||||
nano .env # Set secrets, domains
|
||||
|
||||
Step 4: Start
|
||||
────────────────────────────────
|
||||
docker compose -f docker-compose.app.yml up -d
|
||||
```
|
||||
|
||||
### Updating Existing Server
|
||||
|
||||
**Update app code only:**
|
||||
```
|
||||
cd /data/app/igny8
|
||||
git pull
|
||||
docker compose restart
|
||||
```
|
||||
|
||||
**Update stack (rare):**
|
||||
```
|
||||
cd /data/stack/igny8-stack
|
||||
git pull
|
||||
./scripts/build-images.sh
|
||||
docker compose -f /data/app/igny8/docker-compose.app.yml up -d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## What Goes Where?
|
||||
|
||||
### Stack Repo (igny8-stack)
|
||||
|
||||
Things that are **same for any Django+React app**:
|
||||
- Dockerfiles
|
||||
- Base requirements.txt / package.json
|
||||
- Vite config, TypeScript config
|
||||
- Docker compose templates
|
||||
- Caddy config templates
|
||||
- Utility scripts
|
||||
|
||||
### App Repo (igny8-app)
|
||||
|
||||
Things that are **specific to your application**:
|
||||
- Django app code (models, views, serializers, business logic)
|
||||
- React components, pages, stores
|
||||
- App-specific static assets
|
||||
- Documentation
|
||||
- Environment config templates
|
||||
|
||||
---
|
||||
|
||||
## Key Principle
|
||||
|
||||
> If you deleted your app code and replaced it with a different Django+React app,
|
||||
> would this file still make sense?
|
||||
> - YES → Stack repo
|
||||
> - NO → App repo
|
||||
|
||||
---
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [INFRASTRUCTURE-STACK.md](INFRASTRUCTURE-STACK.md) - Complete stack repo structure
|
||||
- [IGNY8-APP-STRUCTURE.md](IGNY8-APP-STRUCTURE.md) - App repo structure
|
||||
Reference in New Issue
Block a user