# Quick Deployment Guide

## Super Quick Setup (5 minutes)

### 1. SSH into your cPanel server
```bash
ssh yourusername@yourdomain.com
```

### 2. Navigate to your subdomain directory
```bash
cd ~/yoursubdomain.yourdomain.com
# Replace with your actual path
```

### 3. Clone and setup
```bash
# Clone the repo
git clone https://github.com/kevlad/site-comenzi-importuri-distributie.git .

# Install dependencies
npm install

# Create directories
mkdir -p uploads public/images public/catalogue

# Install PM2 globally
npm install -g pm2

# Start the app
pm2 start server.js --name chocolate-ordering

# Save PM2 config
pm2 save

# Setup PM2 to start on reboot
pm2 startup
# Run the command it outputs (with sudo if needed)
```

### 4. Configure cPanel Node.js App (if available)
1. cPanel → **Setup Node.js App**
2. Create new application:
   - Node.js version: 16 or higher
   - Application mode: Production
   - Application root: `/home/username/yoursubdomain.domain.com`
   - Application URL: `yoursubdomain.domain.com`
   - Application startup file: `server.js`

### 5. Done!
Visit `http://yoursubdomain.domain.com` to see your app.

Default login:
- **Admin**: office@methexis.eu / Methexis1234
- **Customer**: customer@example.com / customer123

---

## Deploying Updates

Every time you push to GitHub, SSH into your server and run:

```bash
cd ~/yoursubdomain.domain.com
bash deploy.sh
```

Or manually:
```bash
git pull origin main
npm install
pm2 restart chocolate-ordering
```

---

## Quick Troubleshooting

**App not starting?**
```bash
pm2 logs chocolate-ordering
```

**Check if running:**
```bash
pm2 status
```

**Restart app:**
```bash
pm2 restart chocolate-ordering
```

**Check Node.js version:**
```bash
node --version  # Should be v14+
```

---

## Enable HTTPS (SSL)

1. cPanel → **SSL/TLS Status**
2. Find your subdomain → **Run AutoSSL**
3. Wait 1-2 minutes
4. Your site is now on `https://`

---

## Backup Database

The database is in `database.db`. To back it up:

```bash
cp database.db database-backup-$(date +%Y%m%d).db
```

Or set up automatic daily backups via cron:
```bash
crontab -e
```

Add:
```
0 2 * * * cp ~/yoursubdomain.domain.com/database.db ~/backups/db-$(date +\%Y\%m\%d).db
```

---

## Need More Help?

See the full [DEPLOYMENT.md](DEPLOYMENT.md) guide for:
- Webhook automation
- Reverse proxy setup
- Security hardening
- Advanced configurations
