<# AZA - Diagnose: Find the real AZA backend in this repo (PowerShell 5.1 safe) Searches Python source files for handover signatures: - "/health" - "/license/status" - "X-API-Token" - "/stripe/webhook" Run (from project root): powershell -ExecutionPolicy Bypass -File .\deploy\find_aza_backend.ps1 Output: - Matching files (relative paths) - Best guess uvicorn target(s) in the form: package.module:app #> [CmdletBinding()] param( [string]$Root = ".", [int]$MaxResultsPerNeedle = 30 ) Set-Location -LiteralPath $Root $needles = @( "/license/status", "license/status", "/health", "X-API-Token", "/stripe/webhook" ) Write-Host "[AZA] Repo scan for backend signatures" Write-Host (" Root: " + (Get-Location)) Write-Host "" function Get-Rel([string]$p) { try { return (Resolve-Path $p -Relative) } catch { return $p } } function Find-Needle([string]$needle) { $hits = @() $files = @() try { $files = Get-ChildItem -Path . -Recurse -File -Include *.py -ErrorAction SilentlyContinue } catch { $files = @() } foreach ($f in $files) { try { $m = Select-String -LiteralPath $f.FullName -Pattern $needle -SimpleMatch -List -ErrorAction SilentlyContinue if ($m) { $hits += (Get-Rel $f.FullName) if ($hits.Count -ge $MaxResultsPerNeedle) { break } } } catch { # ignore unreadable files } } return ($hits | Select-Object -Unique) } $allHits = @{} foreach ($n in $needles) { $h = Find-Needle $n $allHits[$n] = $h Write-Host ("Needle: " + $n) if (-not $h -or $h.Count -eq 0) { Write-Host " (no matches)" } else { foreach ($x in $h) { Write-Host (" - " + $x) } } Write-Host "" } # Prime candidates: files that contain BOTH /health and license/status $healthFiles = @() if ($allHits.ContainsKey("/health")) { $healthFiles = @($allHits["/health"]) } $licFiles = @() if ($allHits.ContainsKey("/license/status")) { $licFiles += @($allHits["/license/status"]) } if ($allHits.ContainsKey("license/status")) { $licFiles += @($allHits["license/status"]) } $healthFiles = $healthFiles | Where-Object { $_ } | Select-Object -Unique $licFiles = $licFiles | Where-Object { $_ } | Select-Object -Unique $prime = @() foreach ($f in $healthFiles) { if ($licFiles -contains $f) { $prime += $f } } $prime = $prime | Select-Object -Unique Write-Host ("Prime candidates (contain both /health and /license/status): " + $prime.Count) if ($prime.Count -gt 0) { foreach ($x in $prime) { Write-Host (" - " + $x) } } else { Write-Host " (none found; falling back to license/status-only files)" } Write-Host "" function To-ModulePath([string]$relPyPath) { $p = $relPyPath.Replace("\", "/") if ($p.StartsWith("./")) { $p = $p.Substring(2) } if ($p.EndsWith(".py")) { $p = $p.Substring(0, $p.Length - 3) } return ($p -replace "/", ".") } $candidates = @() if ($prime.Count -gt 0) { $candidates = $prime } elseif ($licFiles.Count -gt 0) { $candidates = $licFiles } $candidates = $candidates | Select-Object -Unique Write-Host "Best-guess uvicorn targets to try:" if (-not $candidates -or $candidates.Count -eq 0) { Write-Host " (none - repo may differ from handover, or routes are defined elsewhere)" } else { foreach ($f in $candidates) { $mod = To-ModulePath $f # Use ${mod}:app to avoid PowerShell parsing issues with ":" Write-Host (" - " + "${mod}:app" + " (from " + $f + ")") } } Write-Host "" Write-Host "Next: we will update the local start script to use the correct target above."