# Production Deployment Checklist

## Before Going Live

### 1. Environment Configuration

- [ ] Copy `.env.example` to `.env` on the Pi
- [ ] Set a strong `ADMIN_PASSWORD` in `.env`
- [ ] Generate and set `SESSION_SECRET` in `.env`:

  ```bash
  # On the Pi, generate a secure random key:
  openssl rand -hex 32
  # Copy the output and add to .env as SESSION_SECRET
  ```

### 2. Security

- [ ] Ensure `.env` is in `.gitignore` (already done)
- [ ] Never commit `.env` file to git
- [ ] Change default admin password from example

### 3. Hardware Setup

- [ ] Thermal printer connected via GPIO (Yellow to Pin 8, GND to Pin 6)
- [ ] External 9V power supply for printer
- [ ] Verify printer works: `echo -e "\x1B\x40Test\n\n\n" > /dev/serial0`
- [ ] Serial port enabled: `ls -la /dev/serial0` should point to ttyAMA0

### 4. Service Configuration

- [ ] Run `./setup_service.sh` to enable autostart
- [ ] Verify service is running: `sudo systemctl status autokanban`
- [ ] Test autostart by rebooting: `sudo reboot`

### 5. Network Access

- [ ] Set hostname to `autokanban`: `sudo hostnamectl set-hostname autokanban`
- [ ] Access app at `http://autokanban.local:8000`
- [ ] Verify 124 Hub link in header works

### 6. Production Settings Verified

- [ ] `ENABLE_PHYSICAL_PRINTER = True` in `app/main.py`
- [ ] Debug print statements removed
- [ ] Session secret loaded from environment variable
- [ ] Service runs without `--reload` flag

### 7. Testing

- [ ] Submit a test task
- [ ] Approve task as admin
- [ ] Print task and verify:
  - [ ] Preview image shows on website
  - [ ] Physical card prints with formatting
  - [ ] Icon appears correctly
  - [ ] Text is readable (larger fonts)
- [ ] Test "Erneut drucken" (reprint) function
- [ ] Test service restart: `sudo systemctl restart autokanban`

### 8. Monitoring

- [ ] Check logs: `sudo journalctl -u autokanban -f`
- [ ] Verify no errors in startup
- [ ] Test graceful shutdown: `sudo systemctl stop autokanban`

## Post-Deployment

### Regular Maintenance

```bash
# Update code
cd ~/autokanban
git pull
sudo systemctl restart autokanban

# View logs
sudo journalctl -u autokanban -n 100

# Check service status
sudo systemctl status autokanban

# Backup tasks
cp data/tasks.json data/tasks.json.backup
```

### Troubleshooting

```bash
# Service won't start
sudo journalctl -u autokanban -n 50

# Printer not working
ls -la /dev/serial0
stty -F /dev/serial0

# Check if port is accessible
curl http://localhost:8000

# Restart service
sudo systemctl restart autokanban
```

## Current Configuration

- **Port**: 8000
- **Hostname**: autokanban.local
- **Access URL**: <http://autokanban.local:8000>
- **Printer**: GPIO serial (/dev/serial0, 19200 baud)
- **Service**: Systemd with autostart enabled
- **Data**: JSON file at `data/tasks.json`
- **Previews**: PNG files in `out/`

---
Last updated: 2025-11-20
