# VIP Coordinator - Interactive Setup Script (Windows PowerShell) # This script collects configuration details and sets up everything for deployment param( [switch]$Help ) if ($Help) { Write-Host "VIP Coordinator Setup Script" -ForegroundColor Green Write-Host "Usage: .\setup.ps1" -ForegroundColor Yellow Write-Host "This script will interactively set up VIP Coordinator for deployment." exit } Clear-Host Write-Host "🚀 VIP Coordinator - Interactive Setup" -ForegroundColor Green Write-Host "======================================" -ForegroundColor Green Write-Host "" Write-Host "This script will help you set up VIP Coordinator by:" -ForegroundColor Cyan Write-Host " ✅ Collecting your configuration details" -ForegroundColor Green Write-Host " ✅ Generating .env file" -ForegroundColor Green Write-Host " ✅ Creating docker-compose.yml" -ForegroundColor Green Write-Host " ✅ Setting up deployment files" -ForegroundColor Green Write-Host " ✅ Providing Google OAuth setup instructions" -ForegroundColor Green Write-Host "" # Function to prompt for input with default value function Get-UserInput { param( [string]$Prompt, [string]$Default = "", [bool]$Required = $false ) do { if ($Default) { $input = Read-Host "$Prompt [$Default]" if ([string]::IsNullOrEmpty($input)) { $input = $Default } } else { $input = Read-Host $Prompt } if ($Required -and [string]::IsNullOrEmpty($input)) { Write-Host "This field is required. Please enter a value." -ForegroundColor Red } } while ($Required -and [string]::IsNullOrEmpty($input)) return $input } # Function to generate random password function New-RandomPassword { $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" $password = "" for ($i = 0; $i -lt 25; $i++) { $password += $chars[(Get-Random -Maximum $chars.Length)] } return $password } Write-Host "📋 Configuration Setup" -ForegroundColor Yellow Write-Host "=====================" -ForegroundColor Yellow Write-Host "" # Deployment type Write-Host "1. Deployment Type" -ForegroundColor Cyan Write-Host "------------------" -ForegroundColor Cyan Write-Host "Choose your deployment type:" Write-Host " 1) Local development (localhost)" Write-Host " 2) Production with custom domain" Write-Host "" $deploymentType = Get-UserInput "Select option [1-2]" "1" $true if ($deploymentType -eq "2") { Write-Host "" Write-Host "2. Domain Configuration" -ForegroundColor Cyan Write-Host "----------------------" -ForegroundColor Cyan $domain = Get-UserInput "Enter your main domain (e.g., mycompany.com)" "" $true $apiDomain = Get-UserInput "Enter your API subdomain (e.g., api.mycompany.com)" "api.$domain" $frontendUrl = "https://$domain" $viteApiUrl = "https://$apiDomain" $googleRedirectUri = "https://$apiDomain/auth/google/callback" } else { $domain = "localhost" $apiDomain = "localhost:3000" $frontendUrl = "http://localhost" $viteApiUrl = "http://localhost:3000" $googleRedirectUri = "http://localhost:3000/auth/google/callback" } Write-Host "" Write-Host "3. Security Configuration" -ForegroundColor Cyan Write-Host "-------------------------" -ForegroundColor Cyan $dbPassword = New-RandomPassword $adminPassword = New-RandomPassword Write-Host "Generated secure passwords:" -ForegroundColor Green Write-Host " Database Password: $dbPassword" -ForegroundColor Yellow Write-Host " Admin Password: $adminPassword" -ForegroundColor Yellow Write-Host "" $useGenerated = Get-UserInput "Use these generated passwords? [Y/n]" "Y" if ($useGenerated -match "^[Nn]$") { $dbPassword = Get-UserInput "Enter database password" "" $true $adminPassword = Get-UserInput "Enter admin password" "" $true } Write-Host "" Write-Host "4. Google OAuth Setup" -ForegroundColor Cyan Write-Host "--------------------" -ForegroundColor Cyan Write-Host "To set up Google OAuth:" -ForegroundColor Yellow Write-Host " 1. Go to https://console.cloud.google.com/" Write-Host " 2. Create a new project or select existing" Write-Host " 3. Enable Google+ API" Write-Host " 4. Go to Credentials → Create Credentials → OAuth 2.0 Client IDs" Write-Host " 5. Set application type to 'Web application'" Write-Host " 6. Add authorized redirect URI: $googleRedirectUri" -ForegroundColor Green Write-Host " 7. Copy the Client ID and Client Secret" Write-Host "" $googleClientId = Get-UserInput "Enter Google OAuth Client ID" "" $true $googleClientSecret = Get-UserInput "Enter Google OAuth Client Secret" "" $true Write-Host "" Write-Host "5. Optional Configuration" -ForegroundColor Cyan Write-Host "------------------------" -ForegroundColor Cyan $aviationStackApiKey = Get-UserInput "Enter AviationStack API Key (optional, for flight data)" "optional" if ($aviationStackApiKey -eq "optional") { $aviationStackApiKey = "" } # Generate .env file Write-Host "" Write-Host "📝 Generating configuration files..." -ForegroundColor Green $envContent = @" # VIP Coordinator Environment Configuration # Generated by setup script on $(Get-Date) # Database Configuration DB_PASSWORD=$dbPassword # Domain Configuration DOMAIN=$domain VITE_API_URL=$viteApiUrl # Google OAuth Configuration GOOGLE_CLIENT_ID=$googleClientId GOOGLE_CLIENT_SECRET=$googleClientSecret GOOGLE_REDIRECT_URI=$googleRedirectUri # Frontend URL FRONTEND_URL=$frontendUrl # Admin Configuration ADMIN_PASSWORD=$adminPassword # Flight API Configuration AVIATIONSTACK_API_KEY=$aviationStackApiKey # Port Configuration PORT=3000 "@ $envContent | Out-File -FilePath ".env" -Encoding UTF8 # Generate docker-compose.yml $dockerComposeContent = @' version: '3.8' services: db: image: postgres:15 environment: POSTGRES_DB: vip_coordinator POSTGRES_PASSWORD: ${DB_PASSWORD} volumes: - postgres-data:/var/lib/postgresql/data restart: unless-stopped healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 30s timeout: 10s retries: 3 redis: image: redis:7 restart: unless-stopped healthcheck: test: ["CMD", "redis-cli", "ping"] interval: 30s timeout: 10s retries: 3 backend: image: t72chevy/vip-coordinator:backend-latest environment: DATABASE_URL: postgresql://postgres:${DB_PASSWORD}@db:5432/vip_coordinator REDIS_URL: redis://redis:6379 GOOGLE_CLIENT_ID: ${GOOGLE_CLIENT_ID} GOOGLE_CLIENT_SECRET: ${GOOGLE_CLIENT_SECRET} GOOGLE_REDIRECT_URI: ${GOOGLE_REDIRECT_URI} FRONTEND_URL: ${FRONTEND_URL} ADMIN_PASSWORD: ${ADMIN_PASSWORD} PORT: 3000 ports: - "3000:3000" depends_on: db: condition: service_healthy redis: condition: service_healthy restart: unless-stopped frontend: image: t72chevy/vip-coordinator:frontend-latest ports: - "80:80" depends_on: - backend restart: unless-stopped volumes: postgres-data: '@ $dockerComposeContent | Out-File -FilePath "docker-compose.yml" -Encoding UTF8 # Generate start script $startScriptContent = @" Write-Host "🚀 Starting VIP Coordinator..." -ForegroundColor Green # Pull latest images Write-Host "📥 Pulling latest images..." -ForegroundColor Cyan docker-compose pull # Start services Write-Host "🔄 Starting services..." -ForegroundColor Cyan docker-compose up -d # Wait for services Write-Host "⏳ Waiting for services to start..." -ForegroundColor Yellow Start-Sleep -Seconds 15 # Check status Write-Host "📊 Service Status:" -ForegroundColor Cyan docker-compose ps Write-Host "" Write-Host "🎉 VIP Coordinator is starting!" -ForegroundColor Green Write-Host "================================" -ForegroundColor Green Write-Host "Frontend: $frontendUrl" -ForegroundColor Yellow Write-Host "Backend API: $viteApiUrl" -ForegroundColor Yellow Write-Host "" Write-Host "The first user to log in will become the administrator." -ForegroundColor Cyan "@ $startScriptContent | Out-File -FilePath "start.ps1" -Encoding UTF8 # Generate stop script $stopScriptContent = @' Write-Host "🛑 Stopping VIP Coordinator..." -ForegroundColor Yellow docker-compose down Write-Host "✅ VIP Coordinator stopped." -ForegroundColor Green '@ $stopScriptContent | Out-File -FilePath "stop.ps1" -Encoding UTF8 # Generate update script $updateScriptContent = @' Write-Host "🔄 Updating VIP Coordinator..." -ForegroundColor Cyan # Pull latest images Write-Host "📥 Pulling latest images..." -ForegroundColor Yellow docker-compose pull # Restart with new images Write-Host "🔄 Restarting services..." -ForegroundColor Yellow docker-compose up -d Write-Host "✅ VIP Coordinator updated!" -ForegroundColor Green '@ $updateScriptContent | Out-File -FilePath "update.ps1" -Encoding UTF8 # Generate README $readmeContent = @" # VIP Coordinator Deployment This directory contains your configured VIP Coordinator deployment. ## Quick Start (Windows) ``````powershell # Start the application .\start.ps1 # Stop the application .\stop.ps1 # Update to latest version .\update.ps1 `````` ## Quick Start (Linux/Mac) ``````bash # Start the application docker-compose up -d # Stop the application docker-compose down # Update to latest version docker-compose pull && docker-compose up -d `````` ## Configuration Your configuration is stored in `.env`. Key details: - **Frontend URL**: $frontendUrl - **Backend API**: $viteApiUrl - **Admin Password**: $adminPassword - **Database Password**: $dbPassword ## First Time Setup 1. Run `.\start.ps1` (Windows) or `docker-compose up -d` (Linux/Mac) 2. Open $frontendUrl in your browser 3. Click "Continue with Google" to set up your admin account 4. The first user to log in becomes the administrator ## Management - **View logs**: `docker-compose logs` - **View specific service logs**: `docker-compose logs backend` - **Check status**: `docker-compose ps` - **Access database**: `docker-compose exec db psql -U postgres vip_coordinator` ## Support If you encounter issues, check the logs and ensure all required ports are available. "@ $readmeContent | Out-File -FilePath "README.md" -Encoding UTF8 Write-Host "" Write-Host "✅ Setup completed successfully!" -ForegroundColor Green Write-Host "===============================" -ForegroundColor Green Write-Host "" Write-Host "Generated files:" -ForegroundColor Cyan Write-Host " 📄 .env - Environment configuration" -ForegroundColor Yellow Write-Host " 📄 docker-compose.yml - Docker services" -ForegroundColor Yellow Write-Host " 📄 start.ps1 - Start the application" -ForegroundColor Yellow Write-Host " 📄 stop.ps1 - Stop the application" -ForegroundColor Yellow Write-Host " 📄 update.ps1 - Update to latest version" -ForegroundColor Yellow Write-Host " 📄 README.md - Documentation" -ForegroundColor Yellow Write-Host "" Write-Host "🚀 Next steps:" -ForegroundColor Green Write-Host " 1. Run: .\start.ps1" -ForegroundColor Cyan Write-Host " 2. Open: $frontendUrl" -ForegroundColor Cyan Write-Host " 3. Login with Google to set up your admin account" -ForegroundColor Cyan Write-Host "" Write-Host "💡 Important notes:" -ForegroundColor Yellow Write-Host " - Admin password: $adminPassword" -ForegroundColor Red Write-Host " - Database password: $dbPassword" -ForegroundColor Red Write-Host " - Keep these passwords secure!" -ForegroundColor Red Write-Host "" Write-Host "🎉 VIP Coordinator is ready to deploy!" -ForegroundColor Green