# Update Mechanism

This guide covers the built-in update mechanism for Crypto Trader.

## Update System

Crypto Trader includes a built-in update checker and installer for AppImage deployments.

## Update Check

### Automatic Check

Updates are checked on application startup (if enabled):

```yaml
updates:
  check_on_startup: true
  repository_url: "https://github.com/user/crypto_trader"
```

### Manual Check

Check for updates from the application:

1. Navigate to Help > Check for Updates
2. Application checks GitHub releases
3. Notifies if update available

## Update Process

### Automatic Update

1. **Check for Updates**
   - Compares current version with latest release
   - Downloads update information

2. **Download Update**
   - Downloads new AppImage
   - Shows progress
   - Verifies download

3. **Install Update**
   - Creates backup of current version
   - Replaces with new version
   - Makes executable

4. **Restart**
   - Prompts to restart
   - Launches new version

### Manual Update

1. Download new AppImage
2. Replace old file
3. Make executable: `chmod +x crypto_trader-*.AppImage`
4. Run new version

## Version Management

### Version Format

Follows semantic versioning: `MAJOR.MINOR.PATCH`

Example: `1.2.3`

### Version Comparison

- **Major**: Breaking changes
- **Minor**: New features (backward compatible)
- **Patch**: Bug fixes (backward compatible)

## Update Configuration

### Disable Auto-Check

```yaml
updates:
  check_on_startup: false
```

### Custom Repository

```yaml
updates:
  repository_url: "https://github.com/your-org/crypto_trader"
```

## Update Notifications

Users are notified when:

- Update is available on startup
- Manual check finds update
- Critical security update available

## Rollback

If update causes issues:

1. Locate backup: `crypto_trader-*.AppImage.backup`
2. Restore backup:
   ```bash
   mv crypto_trader-*.AppImage.backup crypto_trader-*.AppImage
   chmod +x crypto_trader-*.AppImage
   ```
3. Run previous version

## Best Practices

1. **Test Updates**: Test updates in development first
2. **Backup**: Always backup before updating
3. **Release Notes**: Review release notes before updating
4. **Staged Rollout**: Consider staged rollout for major updates

## Troubleshooting

**Update check fails?**
- Check internet connection
- Verify repository URL
- Review application logs

**Download fails?**
- Check disk space
- Verify download URL
- Check network connection

**Installation fails?**
- Check file permissions
- Verify AppImage integrity
- Review error logs

