File size: 9,044 Bytes
09fa60b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# ============================================
# AudioForge - Professional Demo Launch
# ============================================
# Uses alternative ports to avoid conflicts
# Perfect for live presentations

param(
    [switch]$Build
)

# Colors
$ESC = [char]27
$GREEN = "$ESC[32m"
$BLUE = "$ESC[34m"
$YELLOW = "$ESC[33m"
$RED = "$ESC[31m"
$CYAN = "$ESC[36m"
$MAGENTA = "$ESC[35m"
$RESET = "$ESC[0m"
$BOLD = "$ESC[1m"

# Banner
function Show-Banner {
    Clear-Host
    Write-Host ""
    Write-Host "${CYAN}${BOLD}╔═══════════════════════════════════════════════════════════════╗${RESET}"
    Write-Host "${CYAN}${BOLD}β•‘                                                               β•‘${RESET}"
    Write-Host "${CYAN}${BOLD}β•‘                    ${MAGENTA}🎡 AUDIOFORGE 🎡${CYAN}                        β•‘${RESET}"
    Write-Host "${CYAN}${BOLD}β•‘                                                               β•‘${RESET}"
    Write-Host "${CYAN}${BOLD}β•‘          ${RESET}Open-Source Text-to-Music Generation Platform${CYAN}        β•‘${RESET}"
    Write-Host "${CYAN}${BOLD}β•‘                                                               β•‘${RESET}"
    Write-Host "${CYAN}${BOLD}β•‘              ${GREEN}πŸš€ LIVE DEMONSTRATION MODE πŸš€${CYAN}                  β•‘${RESET}"
    Write-Host "${CYAN}${BOLD}β•‘                                                               β•‘${RESET}"
    Write-Host "${CYAN}${BOLD}β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•${RESET}"
    Write-Host ""
}

function Write-Status { param([string]$Message) Write-Host "${BLUE}[INFO]${RESET} $Message" }
function Write-Success { param([string]$Message) Write-Host "${GREEN}[βœ“]${RESET} $Message" }
function Write-Warning { param([string]$Message) Write-Host "${YELLOW}[!]${RESET} $Message" }
function Write-Error-Custom { param([string]$Message) Write-Host "${RED}[βœ—]${RESET} $Message" }
function Write-Section { param([string]$Title) Write-Host ""; Write-Host "${BOLD}${CYAN}═══ $Title ═══${RESET}"; Write-Host "" }

Show-Banner

Write-Section "System Check"

# Check Docker
try {
    $dockerVersion = docker --version
    Write-Success "Docker: $dockerVersion"
} catch {
    Write-Error-Custom "Docker not found"
    exit 1
}

# Check if Docker is running
try {
    docker ps | Out-Null
    Write-Success "Docker daemon is running"
} catch {
    Write-Error-Custom "Docker daemon is not running"
    exit 1
}

Write-Section "Port Configuration"
Write-Status "Using alternative ports to avoid conflicts:"
Write-Host "  ${CYAN}Frontend:${RESET}   http://localhost:3000"
Write-Host "  ${CYAN}Backend:${RESET}    http://localhost:8001 ${YELLOW}(Note: Port 8001)${RESET}"
Write-Host "  ${CYAN}PostgreSQL:${RESET} localhost:5433"
Write-Host "  ${CYAN}Redis:${RESET}      localhost:6380"
Write-Host ""

if ($Build) {
    Write-Section "Building Docker Images"
    Write-Status "This may take 5-10 minutes on first run..."
    docker-compose -f docker-compose.demo.yml build --no-cache
    if ($LASTEXITCODE -eq 0) {
        Write-Success "Build completed successfully"
    } else {
        Write-Error-Custom "Build failed"
        exit 1
    }
}

Write-Section "Starting Services"

Write-Status "Starting database services..."
docker-compose -f docker-compose.demo.yml up -d postgres redis
Start-Sleep -Seconds 8

Write-Status "Starting backend API..."
docker-compose -f docker-compose.demo.yml up -d backend
Start-Sleep -Seconds 15

Write-Status "Starting frontend..."
docker-compose -f docker-compose.demo.yml up -d frontend
Start-Sleep -Seconds 10

Write-Section "Health Check"

$maxRetries = 20
$retryCount = 0

Write-Status "Checking PostgreSQL..."
while ($retryCount -lt $maxRetries) {
    $health = docker inspect --format='{{.State.Health.Status}}' audioforge-postgres 2>$null
    if ($health -eq "healthy") {
        Write-Success "PostgreSQL is healthy"
        break
    }
    Start-Sleep -Seconds 2
    $retryCount++
}

Write-Status "Checking Redis..."
$retryCount = 0
while ($retryCount -lt $maxRetries) {
    $health = docker inspect --format='{{.State.Health.Status}}' audioforge-redis 2>$null
    if ($health -eq "healthy") {
        Write-Success "Redis is healthy"
        break
    }
    Start-Sleep -Seconds 2
    $retryCount++
}

Write-Status "Checking Backend API..."
$retryCount = 0
while ($retryCount -lt $maxRetries) {
    try {
        $response = Invoke-WebRequest -Uri "http://localhost:8001/health" -UseBasicParsing -TimeoutSec 2 -ErrorAction SilentlyContinue
        if ($response.StatusCode -eq 200) {
            Write-Success "Backend API is healthy"
            break
        }
    } catch { }
    Start-Sleep -Seconds 3
    $retryCount++
}

Write-Status "Checking Frontend..."
$retryCount = 0
while ($retryCount -lt $maxRetries) {
    try {
        $response = Invoke-WebRequest -Uri "http://localhost:3000" -UseBasicParsing -TimeoutSec 2 -ErrorAction SilentlyContinue
        if ($response.StatusCode -eq 200) {
            Write-Success "Frontend is healthy"
            break
        }
    } catch { }
    Start-Sleep -Seconds 3
    $retryCount++
}

Write-Section "Service Status"

docker-compose -f docker-compose.demo.yml ps

Write-Host ""
Write-Host "${BOLD}Container Resource Usage:${RESET}"
docker stats --no-stream --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}" audioforge-postgres audioforge-redis audioforge-backend audioforge-frontend 2>$null

Write-Section "Access Information"

Write-Host "${BOLD}${GREEN}🌐 Application URLs:${RESET}"
Write-Host ""
Write-Host "  ${BOLD}${CYAN}Frontend:${RESET}          ${GREEN}http://localhost:3000${RESET}"
Write-Host "  ${BOLD}${CYAN}Backend API:${RESET}       ${GREEN}http://localhost:8001${RESET}"
Write-Host "  ${BOLD}${CYAN}API Docs:${RESET}          ${GREEN}http://localhost:8001/docs${RESET}"
Write-Host "  ${BOLD}${CYAN}API Redoc:${RESET}         ${GREEN}http://localhost:8001/redoc${RESET}"
Write-Host "  ${BOLD}${CYAN}Health Check:${RESET}      ${GREEN}http://localhost:8001/health${RESET}"
Write-Host ""

Write-Host "${BOLD}${MAGENTA}πŸ“Š Technical Specifications:${RESET}"
Write-Host ""
Write-Host "  ${CYAN}Architecture:${RESET}      Microservices with Docker"
Write-Host "  ${CYAN}Backend:${RESET}           FastAPI + Python 3.11"
Write-Host "  ${CYAN}Frontend:${RESET}          Next.js 14 + TypeScript"
Write-Host "  ${CYAN}Database:${RESET}          PostgreSQL 16"
Write-Host "  ${CYAN}Cache:${RESET}             Redis 7"
Write-Host "  ${CYAN}ML Models:${RESET}         MusicGen + Bark"
Write-Host ""

Write-Section "Recent Logs"

Write-Host "${CYAN}Backend (last 5 lines):${RESET}"
docker-compose -f docker-compose.demo.yml logs --tail=5 backend 2>$null

Write-Host ""
Write-Host "${CYAN}Frontend (last 5 lines):${RESET}"
docker-compose -f docker-compose.demo.yml logs --tail=5 frontend 2>$null

Write-Host ""
Write-Host "${BOLD}${GREEN}╔═══════════════════════════════════════════════════════════════╗${RESET}"
Write-Host "${BOLD}${GREEN}β•‘                                                               β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•‘           πŸŽ‰ AUDIOFORGE IS READY FOR DEMO! πŸŽ‰                 β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•‘                                                               β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•‘         Visit ${CYAN}http://localhost:3000${GREEN} to begin                 β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•‘                                                               β•‘${RESET}"
Write-Host "${BOLD}${GREEN}β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•${RESET}"
Write-Host ""
Write-Host "${YELLOW}πŸ“ Quick Commands:${RESET}"
Write-Host "  ${CYAN}View logs:${RESET}         docker-compose -f docker-compose.demo.yml logs -f"
Write-Host "  ${CYAN}Stop services:${RESET}     docker-compose -f docker-compose.demo.yml down"
Write-Host "  ${CYAN}Restart:${RESET}           docker-compose -f docker-compose.demo.yml restart"
Write-Host ""
Write-Host "${YELLOW}🎯 Demo Tips:${RESET}"
Write-Host "  1. Open ${CYAN}http://localhost:3000${RESET} for the UI"
Write-Host "  2. Try prompt: ${GREEN}'Upbeat electronic dance music'${RESET}"
Write-Host "  3. Show API docs at ${CYAN}http://localhost:8001/docs${RESET}"
Write-Host "  4. Monitor logs in real-time"
Write-Host ""