160 lines
5.0 KiB
Markdown
160 lines
5.0 KiB
Markdown
# CoopCredits Infrastructure Configuration Summary
|
|
|
|
## Your Server Infrastructure
|
|
|
|
| Service | IP Address | Port | Integration Role |
|
|
|----------|----------------|------|--------------------------------|
|
|
| Plex | 172.20.1.220 | 32400| User authentication, content |
|
|
| Overseer | 172.20.1.225 | 5055 | Content requests, disk space |
|
|
| Tautulli | 172.20.1.255 | 8181 | Watch tracking, $COOP earn |
|
|
| Website | coop.hobokenchicken.com | 443 | User dashboard, admin panel |
|
|
|
|
## Files Created/Updated
|
|
|
|
### Configuration Files
|
|
- `.env` - Production environment
|
|
- `docker-compose.yml` - Docker orchestration
|
|
- `docker-compose.prod.yml` - Production Docker orchestration
|
|
|
|
### Documentation
|
|
- `docs/SETUP-INFRASTRUCTURE.md` - Step-by-step setup guide
|
|
- `docs/INFRASTRUCTURE.md` - Architecture and network documentation
|
|
- `docs/CADDY-CONFIG.md` - Reverse proxy configuration
|
|
- `docs/TROUBLESHOOTING.md` - Common issues and fixes
|
|
|
|
## Network Architecture
|
|
|
|
```
|
|
Internet
|
|
│ HTTPS
|
|
▼
|
|
┌─────────────┐
|
|
│ Caddy │ (443) - SSL termination
|
|
└──────┬──────┘
|
|
│
|
|
┌───┴───┐
|
|
▼ ▼
|
|
┌──────┐ ┌──────┐
|
|
│Front-│ │Back- │
|
|
│end │ │end │
|
|
│:3000 │ │:3002 │
|
|
└──────┘ └───┬───┘
|
|
│
|
|
┌──────┼──────┐
|
|
▼ ▼ ▼
|
|
┌────────┐ ┌────┐ ┌──────┐
|
|
│PostgreSQL│ │Redis│ │External│
|
|
│:5432 │ │:6379│ │Network │
|
|
└────────┘ └────┘ └───┬───┘
|
|
│
|
|
┌─────────────┼─────────────┐
|
|
▼ ▼ ▼
|
|
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
│ Plex │ │Tautulli │ │ Overseer│
|
|
│172.20.1.│ │172.20.1.│ │172.20.1.│
|
|
│ 220 │ │ 255 │ │ 225 │
|
|
└─────────┘ └─────────┘ └─────────┘
|
|
```
|
|
|
|
## Quick Deployment Commands
|
|
|
|
```bash
|
|
# 1. Setup
|
|
cp .env.example .env
|
|
# Edit .env with your API keys
|
|
|
|
# 2. Deploy
|
|
docker-compose up -d --build
|
|
|
|
# 3. Initialize database (first time only)
|
|
docker exec coop-backend npx prisma db push --accept-data-loss
|
|
|
|
# 4. Check health
|
|
curl https://coop.hobokenchicken.com/health
|
|
```
|
|
|
|
## Integration Points
|
|
|
|
### Tautulli → CoopCredits
|
|
- **Trigger**: Watch events
|
|
- **Webhook URL**: `https://coop.hobokenchicken.com/webhooks/tautulli`
|
|
- **Action**: Create WatchEvent + Transaction (EARN), update user balance
|
|
|
|
### Overseer → CoopCredits
|
|
- **Trigger**: Request approval/decline
|
|
- **Webhook URL**: `https://coop.hobokenchicken.com/webhooks/overseer`
|
|
- **Action**: Update ContentRequest status (refund if declined)
|
|
|
|
### Plex → CoopCredits
|
|
- **Trigger**: User login
|
|
- **Method**: OAuth via plex.tv
|
|
- **Action**: Authenticate users, create session
|
|
|
|
### Ko-fi → CoopCredits
|
|
- **Trigger**: Store purchase
|
|
- **Webhook URL**: `https://coop.hobokenchicken.com/webhooks/kofi`
|
|
- **Action**: Create KofiPayment, credit user if email matches
|
|
|
|
## Security Features
|
|
|
|
1. **SSL/TLS**: Caddy with Let's Encrypt
|
|
2. **Rate Limiting**: 1000 req/15min per IP
|
|
3. **Firewall**: UFW rules for local network
|
|
4. **Secrets**: In `.env` file (gitignored)
|
|
5. **CORS**: Configured for your domain
|
|
6. **JWT**: Secure session tokens
|
|
7. **Ko-fi Verification**: Token check on webhook
|
|
|
|
## Monitoring
|
|
|
|
```bash
|
|
# Health check
|
|
curl https://coop.hobokenchicken.com/health
|
|
|
|
# Docker logs
|
|
docker-compose logs -f
|
|
|
|
# Specific service
|
|
docker-compose logs -f backend
|
|
```
|
|
|
|
## Backup Strategy
|
|
|
|
```bash
|
|
# Database backup
|
|
docker exec -T coop-postgres pg_dump -U coop coop_credits > backup_$(date +%Y%m%d).sql
|
|
|
|
# Environment backup
|
|
cp .env .env.backup.$(date +%Y%m%d)
|
|
```
|
|
|
|
## Next Steps
|
|
|
|
1. **Run setup**: `cp .env.example .env` and edit
|
|
2. **Get API keys**:
|
|
- Tautulli: http://172.20.1.255:8181 → Settings → API
|
|
- Overseer: http://172.20.1.225:5055 → Settings → General
|
|
- Plex: https://plex.tv/claim
|
|
3. **Deploy**: `docker-compose up -d --build`
|
|
4. **Configure webhooks** in Tautulli, Overseer, and Ko-fi
|
|
5. **Set admin**: `UPDATE users SET is_admin = true WHERE ...`
|
|
6. **Test**: `curl https://coop.hobokenchicken.com/health`
|
|
|
|
## Troubleshooting
|
|
|
|
| Issue | Solution |
|
|
|-------|----------|
|
|
| Cannot reach local services | Check backend `network_mode: host` |
|
|
| Webhook not received | Check Caddy routes to port 3002 |
|
|
| Database connection failed | Verify `.env` DATABASE_URL |
|
|
| SSL error | Check Caddy certificate status |
|
|
| CORS errors | Verify CORS_ORIGINS in `.env` |
|
|
| Request stuck PENDING | Use admin **SYNC** button or check Overseer webhook |
|
|
|
|
## Support Resources
|
|
|
|
- **Setup Guide**: `docs/SETUP-INFRASTRUCTURE.md`
|
|
- **Architecture**: `docs/INFRASTRUCTURE.md`
|
|
- **Troubleshooting**: `docs/TROUBLESHOOTING.md`
|
|
- **Caddy Config**: `docs/CADDY-CONFIG.md`
|