defmodule SuperintelligenceWeb.StartupController do use SuperintelligenceWeb, :controller def show(conn, _params) do # Get comprehensive startup data timer_report = if Process.whereis(Superintelligence.StartupTimer) do Superintelligence.StartupTimer.report() else "Startup timer not available" end profiler_report = if Process.whereis(Superintelligence.StartupProfiler) do Superintelligence.StartupProfiler.generate_report() else "Profiler not available" end orchestrator_status = if Process.whereis(Superintelligence.StartupOrchestrator) do Superintelligence.StartupOrchestrator.get_status() else %{} end health_status = if Process.whereis(Superintelligence.HealthMonitor) do Superintelligence.HealthMonitor.get_health_status() else %{} end resource_usage = if Process.whereis(Superintelligence.ResourceManager) do Superintelligence.ResourceManager.get_usage() else %{} end telemetry_metrics = if Process.whereis(Superintelligence.TelemetryReporter) do Superintelligence.TelemetryReporter.get_metrics() else %{} end worker_pool_status = if Process.whereis(Superintelligence.WorkerPool.PoolManager) do Superintelligence.WorkerPool.get_status() else %{} end html = """ Startup Execution Flow

🚀 Superintelligence Startup Execution Flow

📊 Startup Performance

Basic Timing

#{html_escape(timer_report)}

🔥 Advanced Profiler Report

#{html_escape(profiler_report)}

🎭 Orchestrator Status

#{html_escape(inspect(orchestrator_status, pretty: true))}

🏥 Health Monitor

#{html_escape(inspect(health_status, pretty: true))}

🎛️ Resource Usage

#{html_escape(inspect(resource_usage, pretty: true))}

📡 Telemetry Metrics

#{html_escape(inspect(telemetry_metrics, pretty: true))}

👷 Worker Pool Status

#{html_escape(inspect(worker_pool_status, pretty: true))}

🔄 Execution Flow

1. mix run → Elixir VM starts
2. Superintelligence.Application.start/2
├─ 📊 StartupProfiler (tracks performance)
├─ 🎭 StartupOrchestrator (manages dependencies)
├─ ⏱️ StartupTimer (basic timing)
├─ 📡 TelemetryReporter (metrics collection)
├─ 🔍 Registry (process discovery)
├─ 🎛️ ResourceManager (CPU/memory/connections)
├─ 🏥 HealthMonitor (circuit breakers)
├─ 🔄 HotReloader (zero-downtime updates)
├─ 👷 WorkerPool (dynamic scaling)
│ ├─ Auto-scaling based on load
│ ├─ Task prioritization
│ └─ Health checks
├─ 🌐 Phoenix.Endpoint (web server)
└─ 📈 Telemetry (monitoring)
3. Orchestrator initializes components:
├─ Dependency graph resolution
├─ Parallel initialization stages
├─ Health check registration
├─ Resource quota allocation
└─ Telemetry alert configuration
4. Bandit binds to port 4000
5. System ready with advanced features! 🚀

🎯 Advanced Features

← Back to Home

""" conn |> put_resp_content_type("text/html") |> send_resp(200, html) end defp get_worker_status do case Registry.select(Superintelligence.Registry, [{{:"$1", :"$2", :"$3"}, [{:==, {:element, 1, :"$1"}, :worker}], [:"$2"]}]) do pids when is_list(pids) -> Enum.map(pids, fn pid -> try do GenServer.call(pid, :status, 1000) catch :exit, _ -> nil end end) |> Enum.filter(&(&1)) _ -> [] end end defp format_workers_html(workers) do if Enum.empty?(workers) do "

No workers active

" else workers |> Enum.map(fn worker -> """
#{worker.name}
PID: #{inspect(worker.pid)}
Uptime: #{worker.uptime_seconds}s
""" end) |> Enum.join("") end end defp html_escape(text) do text |> String.replace("&", "&") |> String.replace("<", "<") |> String.replace(">", ">") |> String.replace("\"", """) |> String.replace("'", "'") end end