# DBIS Core - Next Steps Quick Reference

## 🎯 Immediate Actions (Start Here)

### 1. Create Script Directory Structure
```bash
cd /home/intlc/projects/proxmox/dbis_core
mkdir -p scripts/{deployment,management,utils}
mkdir -p templates/{postgresql,redis,nginx,systemd}
```

### 2. Create First Deployment Script (PostgreSQL)
Start with: `scripts/deployment/deploy-postgresql.sh`

**Reference**: `../smom-dbis-138-proxmox/scripts/deployment/deploy-services.sh`

### 3. Deployment Order
1. PostgreSQL (VMID 10100) - Foundation
2. Redis (VMID 10120) - Cache
3. API Primary (VMID 10150) - Application
4. API Secondary (VMID 10151) - HA
5. Frontend (VMID 10130) - UI

## 📋 Quick Task Checklist

### Phase 2: Scripts (Week 1)
- [ ] Create directory structure
- [ ] `deploy-postgresql.sh` (VMID 10100, 10101)
- [ ] `deploy-redis.sh` (VMID 10120)
- [ ] `deploy-api.sh` (VMID 10150, 10151)
- [ ] `deploy-frontend.sh` (VMID 10130)
- [ ] `deploy-all.sh` (orchestration)
- [ ] `common.sh` (utilities)
- [ ] `dbis-core-utils.sh` (DBIS utilities)

### Phase 3: Configuration (Week 1-2)
- [ ] `configure-database.sh`
- [ ] `configure-api.sh`
- [ ] `configure-frontend.sh`
- [ ] Environment variable templates

### Phase 4: Management (Week 2)
- [ ] `start-services.sh`
- [ ] `stop-services.sh`
- [ ] `restart-services.sh`
- [ ] `status.sh`

## 🔧 Key Configuration Values

### VMIDs
- PostgreSQL Primary: **10100**
- PostgreSQL Replica: **10101**
- Redis: **10120**
- Frontend: **10130**
- API Primary: **10150**
- API Secondary: **10151**

### IP Addresses
- PostgreSQL: 192.168.11.100-101
- Redis: 192.168.11.120
- Frontend: 192.168.11.130
- API: 192.168.11.150-151

### Ports
- PostgreSQL: 5432
- Redis: 6379
- API: 3000
- Frontend: 80, 443

## 📝 Script Template Structure

```bash
#!/usr/bin/env bash
# Script Description

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"

# Source common utilities
source "$PROJECT_ROOT/dbis_core/scripts/utils/common.sh" 2>/dev/null || true
source "$PROJECT_ROOT/smom-dbis-138-proxmox/lib/common.sh" 2>/dev/null || true

# Load configuration
source "$PROJECT_ROOT/dbis_core/config/dbis-core-proxmox.conf" 2>/dev/null || true
source "$PROJECT_ROOT/smom-dbis-138-proxmox/config/proxmox.conf" 2>/dev/null || true

# Your script logic here
```

## 🚀 Quick Start Commands

### After Scripts Are Created

```bash
# Deploy all services
cd /home/intlc/projects/proxmox/dbis_core
./scripts/deployment/deploy-all.sh

# Or deploy individually
./scripts/deployment/deploy-postgresql.sh
./scripts/deployment/deploy-redis.sh
./scripts/deployment/deploy-api.sh
./scripts/deployment/deploy-frontend.sh

# Check status
./scripts/management/status.sh

# Start/stop services
./scripts/management/start-services.sh
./scripts/management/stop-services.sh
```

## 📚 Reference Files

- **Complete Task List**: `COMPLETE_TASK_LIST.md`
- **Deployment Plan**: `DEPLOYMENT_PLAN.md`
- **Quick Summary**: `VMID_AND_CONTAINERS_SUMMARY.md`
- **Configuration**: `config/dbis-core-proxmox.conf`

## 🔍 Example Scripts to Reference

From `smom-dbis-138-proxmox/scripts/deployment/`:
- `deploy-services.sh` - Basic container creation
- `deploy-besu-nodes.sh` - Complex service deployment
- `deploy-hyperledger-services.sh` - Application deployment
- `deploy-all.sh` - Orchestration example

## ⚠️ Important Notes

1. **Deployment Order Matters**: PostgreSQL → Redis → API → Frontend
2. **Dependencies**: API needs PostgreSQL and Redis running first
3. **Network**: Use static IPs as defined in config
4. **Security**: All containers use unprivileged mode
5. **Testing**: Test each service after deployment

## 🎯 Success Criteria

After deployment, verify:
- ✅ All containers running (`pct list`)
- ✅ Services responding to health checks
- ✅ Database accessible
- ✅ API endpoints working
- ✅ Frontend accessible

---

**Start with**: Create `scripts/deployment/deploy-postgresql.sh`

