# KitscoApp - Claude Instructions

## Project Overview
This is a Symfony 6.4 application for business management including invoicing, inventory, and accounting.

## Production Server
- **Host:** kitsco-production (158.220.109.21)
- **SSH:** `ssh kitsco-production`
- **App Path:** /var/www/kitscoApp
- **URL:** https://kits.co.tz

## Deploy Command

When the user says "deploy" or "/deploy", execute this deployment routine:

### Step 1: Commit and Push to Main
```bash
git add -A
git commit -m "<descriptive message based on changes>"
git push origin main
```

### Step 2: Sync liveApp Branch with Main
```bash
git checkout liveApp
git merge main
git push origin liveApp
git checkout main
```

### Step 3: Deploy to Production Server
```bash
ssh kitsco-production "cd /var/www/kitscoApp && git pull origin liveApp && COMPOSER_ALLOW_SUPERUSER=1 composer install --no-dev --optimize-autoloader && php bin/console cache:clear --env=prod && php bin/console doctrine:migrations:migrate --no-interaction && chown -R www-data:www-data var"
```

### Step 4: Verify Deployment
```bash
ssh kitsco-production "curl -sI https://kits.co.tz | head -5"
```

## Database
- **Local:** mysql://kitsco:kitsco_2025@127.0.0.1:3306/kitsco_app
- **Production:** mysql://kitsco:kitsco_2025@127.0.0.1:3306/kitsco_app

## Common Commands

### Clear Cache (Production)
```bash
ssh kitsco-production "cd /var/www/kitscoApp && php bin/console cache:clear --env=prod"
```

### Run Migrations (Production)
```bash
ssh kitsco-production "cd /var/www/kitscoApp && php bin/console doctrine:migrations:migrate --no-interaction"
```

### View Logs (Production)
```bash
ssh kitsco-production "tail -50 /var/log/apache2/kitsco_error.log"
```

## Deployer (Alternative Deployment)

Deployer PHP is configured for zero-downtime deployments with rollback capability.

### First-time Setup
Before first Deployer deployment, create the shared .env.local on the server:
```bash
ssh kitsco-production "mkdir -p /var/www/kitscoApp-deployer/shared && nano /var/www/kitscoApp-deployer/shared/.env.local"
```

### Deploy with Deployer
```bash
vendor/bin/dep deploy production
```

### Rollback
```bash
vendor/bin/dep rollback production
```

### List Releases
```bash
vendor/bin/dep releases production
```

### SSH to Production
```bash
vendor/bin/dep ssh production
```

### Features
- **Zero-downtime**: Atomic symlink switch
- **Rollback**: Keep 5 releases, instant rollback
- **Env Check**: Warns about missing environment variables
- **Health Check**: Verifies site responds HTTP 200 after deploy
