# LittleShop Hostinger Deployment Guide

## Overview
This guide covers deploying the LittleShop web application to your Hostinger VPS server that already has BTCPay Server running.

## Server Information
- **Host**: srv1002428.hstgr.cloud / thebankofdebbie.giize.com
- **IP**: 31.97.57.205
- **SSH Port**: 2255
- **User**: sysadmin
- **BTCPay Server**: Already running at https://thebankofdebbie.giize.com

## Prerequisites
1. SSH access to the Hostinger server
2. Docker and Docker Compose installed (already available)
3. SSH key for authentication (vps_hardening_key)

## Deployment Files Created
- `hostinger-docker-compose.yml` - Docker Compose configuration for Hostinger
- `.env.hostinger` - Environment variables template
- `nginx.conf` - Reverse proxy configuration
- `deploy-to-hostinger.sh` - Automated deployment script
- `HOSTINGER_DEPLOYMENT.md` - This documentation

## Quick Deployment

### Automatic Deployment
```bash
# Run the automated deployment script
./deploy-to-hostinger.sh
```

### Manual Deployment
If you prefer manual control:

```bash
# 1. Copy files to server
scp -i ./Hostinger/vps_hardening_key -P 2255 -r LittleShop/ sysadmin@31.97.57.205:/opt/littleshop/
scp -i ./Hostinger/vps_hardening_key -P 2255 hostinger-docker-compose.yml sysadmin@31.97.57.205:/opt/littleshop/docker-compose.yml

# 2. SSH to server
ssh -i ./Hostinger/vps_hardening_key -p 2255 sysadmin@31.97.57.205

# 3. Deploy on server
cd /opt/littleshop
docker-compose build
docker-compose up -d
```

## Configuration

### Environment Variables
Copy `.env.hostinger` to `.env` and update:

```bash
# BTCPay Server integration (already running on same server)
BTCPAY_SERVER_URL=https://thebankofdebbie.giize.com
BTCPAY_STORE_ID=your_store_id_from_btcpay
BTCPAY_API_KEY=your_api_key_from_btcpay
BTCPAY_WEBHOOK_SECRET=your_webhook_secret

# Security
JWT_SECRET_KEY=generate_a_strong_32_character_secret_key
```

### Port Configuration
- **Application**: Runs on internal port 5000
- **External Access**: Port 8081 (to avoid conflict with BTCPay on 80/443)
- **Nginx Proxy**: Available for custom domain setup

## DNS Configuration
To use a custom domain:

1. Point your domain to the server IP: `31.97.57.205`
2. Update the domain in `nginx.conf` or docker-compose labels
3. Consider using a subdomain like `shop.thebankofdebbie.giize.com`

## SSL/HTTPS Setup
The configuration is ready for SSL with Let's Encrypt:

1. Install Certbot on the server
2. Generate certificates for your domain
3. Update nginx.conf with certificate paths
4. Restart the nginx container

## BTCPay Server Integration
Your LittleShop will integrate with the existing BTCPay Server:

1. Log into BTCPay at https://thebankofdebbie.giize.com
2. Create a store for LittleShop
3. Generate API keys
4. Configure webhooks pointing to your LittleShop instance
5. Update the environment variables

## Monitoring and Maintenance

### Check Application Status
```bash
# SSH to server
ssh -i ./Hostinger/vps_hardening_key -p 2255 sysadmin@31.97.57.205

# Check containers
docker-compose ps

# View logs
docker-compose logs littleshop

# Check application health
curl http://localhost:8081/api/test
```

### Container Management
```bash
# Update application
docker-compose pull
docker-compose build
docker-compose up -d

# Restart application
docker-compose restart littleshop

# View resource usage
docker stats
```

## Security Considerations
- Application runs in isolated Docker containers
- Firewall is already configured on the server
- Use HTTPS for production (configure SSL certificates)
- Regularly update container images for security patches

## Troubleshooting

### Common Issues
1. **Port conflicts**: Ensure port 8081 is available
2. **DNS issues**: Check domain configuration
3. **SSL problems**: Verify certificate paths and permissions
4. **BTCPay connection**: Ensure correct API keys and URLs

### Log Locations
- Application logs: `docker-compose logs littleshop`
- Nginx logs: `docker-compose logs nginx`
- Server logs: `/var/log/syslog`

## Backup Strategy
1. **Database**: Backup SQLite database file regularly
2. **Uploads**: Backup product images and uploads
3. **Configuration**: Keep copies of .env and docker-compose files
4. **Docker volumes**: Use docker volume backup tools

## Performance Optimization
- The server has 16GB RAM and should handle LittleShop easily
- Monitor disk usage as BTCPay Server also uses storage
- Consider setting up log rotation
- Use nginx caching for static assets

## Support
- Check the main LittleShop documentation
- Review Hostinger server status in `Infrastructure.txt`
- BTCPay Server documentation for payment integration