# Fresh Start Script for Graph-Driven Agentic System (Windows PowerShell) # Run this script to deploy the system from scratch param( [string]$ApiKey = "", [string]$Model = "gpt-4" ) Write-Host "๐Ÿš€ Fresh Start Deployment" -ForegroundColor Green Write-Host "=========================" -ForegroundColor Green Write-Host "" # Step 1: Check prerequisites Write-Host "๐Ÿ“‹ Step 1: Checking prerequisites..." -ForegroundColor Blue try { docker --version | Out-Null Write-Host "โœ… Docker found" -ForegroundColor Green } catch { Write-Host "โŒ Docker not found. Please install Docker Desktop" -ForegroundColor Red exit 1 } try { docker-compose --version | Out-Null Write-Host "โœ… Docker Compose found" -ForegroundColor Green } catch { Write-Host "โŒ Docker Compose not found" -ForegroundColor Red exit 1 } # Step 2: Setup environment Write-Host "" Write-Host "โš™๏ธ Step 2: Setting up environment..." -ForegroundColor Blue if (Test-Path ".env") { Write-Host "โš ๏ธ .env file already exists, backing up to .env.backup" -ForegroundColor Yellow Copy-Item ".env" ".env.backup" } Copy-Item ".env.example" ".env" Write-Host "โœ… Created .env from template" -ForegroundColor Green # Update API key if provided if ($ApiKey -ne "") { (Get-Content ".env") -replace "LLM_API_KEY=.*", "LLM_API_KEY=$ApiKey" | Set-Content ".env" (Get-Content ".env") -replace "LLM_MODEL=.*", "LLM_MODEL=$Model" | Set-Content ".env" Write-Host "โœ… Updated LLM configuration in .env" -ForegroundColor Green } else { Write-Host "โš ๏ธ No API key provided. You will need to edit .env manually" -ForegroundColor Yellow Write-Host " Add your OpenAI or Anthropic API key to the LLM_API_KEY variable" -ForegroundColor Gray } # Step 3: Clean existing containers Write-Host "" Write-Host "๐Ÿงน Step 3: Cleaning existing containers..." -ForegroundColor Blue docker-compose down 2>$null docker system prune -f 2>$null Write-Host "โœ… Cleaned existing containers" -ForegroundColor Green # Step 4: Build services Write-Host "" Write-Host "๐Ÿ”จ Step 4: Building services..." -ForegroundColor Blue docker-compose build if ($LASTEXITCODE -ne 0) { Write-Host "โŒ Build failed" -ForegroundColor Red exit 1 } Write-Host "โœ… All services built successfully" -ForegroundColor Green # Step 5: Start services Write-Host "" Write-Host "๐Ÿš€ Step 5: Starting services..." -ForegroundColor Blue docker-compose up -d if ($LASTEXITCODE -ne 0) { Write-Host "โŒ Failed to start services" -ForegroundColor Red exit 1 } Write-Host "โœ… All services started" -ForegroundColor Green # Step 6: Wait for health checks Write-Host "" Write-Host "โณ Step 6: Waiting for services to be healthy (60 seconds)..." -ForegroundColor Blue $healthyServices = 0 $maxWait = 60 $elapsed = 0 while ($elapsed -lt $maxWait -and $healthyServices -lt 3) { Start-Sleep 5 $elapsed += 5 $healthyServices = 0 # Check Neo4j try { docker-compose exec neo4j cypher-shell -u neo4j -p password "MATCH (n) RETURN count(n) LIMIT 1" 2>$null | Out-Null if ($LASTEXITCODE -eq 0) { $healthyServices++ } } catch {} # Check PostgreSQL try { docker-compose exec postgres pg_isready -U postgres 2>$null | Out-Null if ($LASTEXITCODE -eq 0) { $healthyServices++ } } catch {} # Check MCP try { $response = Invoke-WebRequest -Uri "http://localhost:8000/health" -UseBasicParsing -TimeoutSec 2 2>$null if ($response.StatusCode -eq 200) { $healthyServices++ } } catch {} Write-Host " Healthy services: $healthyServices/3 (${elapsed}s elapsed)" -ForegroundColor Gray } if ($healthyServices -eq 3) { Write-Host "โœ… All core services are healthy" -ForegroundColor Green } else { Write-Host "โš ๏ธ Some services may not be fully ready, but continuing..." -ForegroundColor Yellow } # Step 7: Seed database Write-Host "" Write-Host "๐ŸŒฑ Step 7: Seeding Neo4j database..." -ForegroundColor Blue docker-compose exec mcp python /app/ops/scripts/seed.py if ($LASTEXITCODE -eq 0) { Write-Host "โœ… Database seeded successfully" -ForegroundColor Green } else { Write-Host "โŒ Database seeding failed" -ForegroundColor Red Write-Host " You can try manual seeding later with:" -ForegroundColor Gray Write-Host " docker-compose exec mcp python /app/ops/scripts/seed.py" -ForegroundColor Gray } # Step 8: Final status check Write-Host "" Write-Host "๐Ÿ“Š Step 8: Final status check..." -ForegroundColor Blue docker-compose ps # Step 9: Success message Write-Host "" Write-Host "๐ŸŽ‰ DEPLOYMENT COMPLETE!" -ForegroundColor Green Write-Host "======================" -ForegroundColor Green Write-Host "" Write-Host "๐Ÿ“ฑ Access Points:" -ForegroundColor Yellow Write-Host " โ€ข Frontend Interface: http://localhost:3000" -ForegroundColor White Write-Host " โ€ข Neo4j Browser: http://localhost:7474" -ForegroundColor White Write-Host " Login: neo4j / password" -ForegroundColor Gray Write-Host "" Write-Host "๐Ÿ”ง Management Commands:" -ForegroundColor Yellow Write-Host " โ€ข View logs: docker-compose logs -f" -ForegroundColor White Write-Host " โ€ข Stop system: docker-compose down" -ForegroundColor White Write-Host " โ€ข Check health: docker-compose ps" -ForegroundColor White Write-Host "" Write-Host "๐ŸŽฏ Quick Test:" -ForegroundColor Yellow Write-Host " 1. Open http://localhost:3000" -ForegroundColor White Write-Host " 2. Ask: ""How many customers do we have?""" -ForegroundColor White Write-Host " 3. Watch the agent process the workflow!" -ForegroundColor White Write-Host "" if ($ApiKey -eq "") { Write-Host "โš ๏ธ REMINDER: Update your LLM API key in .env before testing!" -ForegroundColor Yellow Write-Host "" } Write-Host "System is ready for use!" -ForegroundColor Green