Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
"""
|
| 2 |
-
🚀 ARF ULTIMATE INVESTOR DEMO v3.5.0 -
|
| 3 |
-
|
| 4 |
-
ALL VISUALIZATIONS WORKING - APPROVAL FLOW SYNCED - CLEAN NAVIGATION
|
| 5 |
"""
|
| 6 |
|
| 7 |
import datetime
|
|
@@ -10,275 +9,608 @@ import logging
|
|
| 10 |
import uuid
|
| 11 |
import random
|
| 12 |
from typing import Dict, Any, List
|
| 13 |
-
from collections import deque
|
| 14 |
-
|
| 15 |
import gradio as gr
|
| 16 |
import plotly.graph_objects as go
|
| 17 |
import plotly.express as px
|
| 18 |
import pandas as pd
|
| 19 |
from plotly.subplots import make_subplots
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
# ===========================================
|
| 22 |
-
#
|
| 23 |
# ===========================================
|
| 24 |
|
| 25 |
-
|
| 26 |
-
"
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
|
|
|
| 34 |
try:
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
)]
|
| 47 |
-
)
|
| 48 |
-
return fig
|
| 49 |
-
|
| 50 |
-
# Sample demo data if empty
|
| 51 |
-
if len(incidents) < 5:
|
| 52 |
-
times = pd.date_range(end=datetime.datetime.now(), periods=10, freq='5min')
|
| 53 |
-
sample_incidents = [
|
| 54 |
-
{"timestamp": times[0], "service": "Database", "severity": 3,
|
| 55 |
-
"type": "Connection Pool Exhaustion", "marker": "Incident Detected"},
|
| 56 |
-
{"timestamp": times[2], "service": "ARF", "severity": 1,
|
| 57 |
-
"type": "Analysis Complete", "marker": "ARF Analysis"},
|
| 58 |
-
{"timestamp": times[4], "service": "ARF", "severity": 1,
|
| 59 |
-
"type": "Remediation Executed", "marker": "Healing Actions"},
|
| 60 |
-
{"timestamp": times[6], "service": "Database", "severity": 1,
|
| 61 |
-
"type": "Recovery Complete", "marker": "System Recovered"}
|
| 62 |
-
]
|
| 63 |
-
incidents = sample_incidents + incidents[-5:]
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
|
| 68 |
-
marker_symbols = {'Incident': 'x', 'ARF Analysis': 'star',
|
| 69 |
-
'Healing Actions': 'triangle-up', 'Recovery': 'circle'}
|
| 70 |
|
| 71 |
-
for
|
| 72 |
-
|
| 73 |
fig.add_trace(go.Scatter(
|
| 74 |
-
x=[
|
| 75 |
-
y=[
|
| 76 |
mode='markers+text',
|
| 77 |
-
name=
|
| 78 |
marker=dict(
|
| 79 |
-
size=
|
| 80 |
-
|
| 81 |
-
|
| 82 |
line=dict(width=2, color='white')
|
| 83 |
),
|
| 84 |
-
text=[
|
| 85 |
textposition="top center",
|
| 86 |
-
hoverinfo='text
|
| 87 |
-
))
|
| 88 |
-
|
| 89 |
-
# Add connecting line for flow
|
| 90 |
-
if len(incidents) > 1:
|
| 91 |
-
sorted_incidents = sorted(incidents, key=lambda x: x['timestamp'])
|
| 92 |
-
fig.add_trace(go.Scatter(
|
| 93 |
-
x=[inc['timestamp'] for inc in sorted_incidents],
|
| 94 |
-
y=[inc.get('service', 'ARF') for inc in sorted_incidents],
|
| 95 |
-
mode='lines',
|
| 96 |
-
line=dict(color='gray', width=1, dash='dot'),
|
| 97 |
-
name='Timeline Flow',
|
| 98 |
-
hoverinfo='none'
|
| 99 |
))
|
| 100 |
|
| 101 |
fig.update_layout(
|
| 102 |
-
title="<b>Incident Timeline -
|
| 103 |
xaxis_title="Time →",
|
| 104 |
-
yaxis_title="
|
|
|
|
|
|
|
| 105 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 106 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 107 |
-
height=450,
|
| 108 |
hovermode='closest',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
showlegend=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
legend=dict(
|
| 111 |
yanchor="top",
|
| 112 |
y=0.99,
|
| 113 |
xanchor="left",
|
| 114 |
x=0.01
|
| 115 |
-
),
|
| 116 |
-
xaxis=dict(
|
| 117 |
-
showgrid=True,
|
| 118 |
-
gridcolor='rgba(200,200,200,0.2)',
|
| 119 |
-
tickformat='%H:%M'
|
| 120 |
)
|
| 121 |
)
|
| 122 |
|
| 123 |
return fig
|
| 124 |
except Exception as e:
|
| 125 |
-
|
| 126 |
-
return
|
| 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 |
fig.update_layout(
|
| 198 |
-
height=600,
|
| 199 |
-
showlegend=True,
|
| 200 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 201 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
)
|
| 204 |
-
|
| 205 |
return fig
|
| 206 |
|
| 207 |
# ===========================================
|
| 208 |
-
#
|
| 209 |
# ===========================================
|
| 210 |
|
| 211 |
-
|
| 212 |
-
"""
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
self.approval_required = True # Sync with checkbox
|
| 217 |
-
self.current_scenario = None
|
| 218 |
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 228 |
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
approval_html = """
|
| 232 |
-
<div style='padding:
|
| 233 |
-
<
|
| 234 |
-
<p><b>
|
| 235 |
-
<p><b>
|
| 236 |
-
<p><b>
|
| 237 |
-
<div style='margin: 20px 0;'>
|
| 238 |
-
<button style='background: #4CAF50; color: white; padding: 10px 20px; border: none; border-radius: 5px; margin-right: 10px;'>
|
| 239 |
-
✅ Approve & Execute
|
| 240 |
-
</button>
|
| 241 |
-
<button style='background: #f44336; color: white; padding: 10px 20px; border: none; border-radius: 5px;'>
|
| 242 |
-
❌ Reject Action
|
| 243 |
-
</button>
|
| 244 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
</div>
|
| 246 |
"""
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 259 |
else:
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
|
| 272 |
# ===========================================
|
| 273 |
-
# GRADIO INTERFACE
|
| 274 |
# ===========================================
|
| 275 |
|
| 276 |
-
def
|
| 277 |
-
"""Create the
|
| 278 |
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
|
| 283 |
# ============ HEADER ============
|
| 284 |
gr.Markdown("""
|
|
@@ -288,204 +620,157 @@ def create_enhanced_interface():
|
|
| 288 |
**Experience the transformation:** OSS (Advisory) ↔ Enterprise (Autonomous)
|
| 289 |
""")
|
| 290 |
|
| 291 |
-
# ============ MAIN TABS
|
| 292 |
with gr.Tabs():
|
| 293 |
|
| 294 |
# TAB 1: LIVE INCIDENT DEMO
|
| 295 |
-
with gr.TabItem("🔥 Live Incident Demo", id=
|
| 296 |
with gr.Row():
|
| 297 |
# Left Panel
|
| 298 |
with gr.Column(scale=1):
|
| 299 |
gr.Markdown("### 🎬 Incident Scenario")
|
| 300 |
-
|
| 301 |
-
choices=
|
| 302 |
-
"Database Connection Pool Exhaustion",
|
| 303 |
-
"Cache Miss Storm",
|
| 304 |
-
"Memory Leak in Production",
|
| 305 |
-
"API Rate Limit Exceeded",
|
| 306 |
-
"Microservice Cascading Failure"
|
| 307 |
-
],
|
| 308 |
value="Cache Miss Storm",
|
| 309 |
label="Select critical incident:"
|
| 310 |
)
|
| 311 |
|
| 312 |
gr.Markdown("### 📊 Current Crisis Metrics")
|
| 313 |
-
|
| 314 |
-
"Cache
|
| 315 |
-
|
| 316 |
-
"Response Time": "1850ms (Slow)",
|
| 317 |
-
"Affected Users": "45,000"
|
| 318 |
-
})
|
| 319 |
|
| 320 |
gr.Markdown("### 💰 Business Impact")
|
| 321 |
-
|
| 322 |
-
"
|
| 323 |
-
|
| 324 |
-
"Users Impacted": "45,000"
|
| 325 |
-
})
|
| 326 |
|
| 327 |
-
# Right Panel
|
| 328 |
with gr.Column(scale=2):
|
| 329 |
-
# Visualization
|
| 330 |
gr.Markdown("### 📈 Incident Timeline Visualization")
|
| 331 |
-
|
| 332 |
choices=["Interactive Timeline", "Metrics Stream", "Performance Radar"],
|
| 333 |
value="Interactive Timeline",
|
| 334 |
label="Choose visualization:"
|
| 335 |
)
|
| 336 |
|
| 337 |
-
|
| 338 |
-
timeline_viz = gr.Plot(label="Timeline Visualization")
|
| 339 |
|
| 340 |
-
#
|
| 341 |
with gr.Row():
|
| 342 |
oss_btn = gr.Button("🆓 Run OSS Analysis", variant="secondary")
|
| 343 |
enterprise_btn = gr.Button("🚀 Execute Enterprise Healing", variant="primary")
|
| 344 |
|
| 345 |
-
# Approval Toggle
|
| 346 |
approval_toggle = gr.Checkbox(
|
| 347 |
label="🔐 Require Manual Approval",
|
| 348 |
value=True,
|
| 349 |
info="Toggle to show approval workflow vs auto-execution"
|
| 350 |
)
|
| 351 |
|
| 352 |
-
# Approval Display
|
| 353 |
-
approval_display = gr.HTML(
|
|
|
|
|
|
|
| 354 |
|
| 355 |
-
# Configuration
|
| 356 |
config_display = gr.JSON(
|
| 357 |
label="⚙️ Enterprise Configuration",
|
| 358 |
value={"approval_required": True, "compliance_mode": "strict"}
|
| 359 |
)
|
| 360 |
|
| 361 |
-
#
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
def sync_approval_toggle(approval_value):
|
| 366 |
-
"""Sync checkbox with configuration"""
|
| 367 |
-
demo.approval_required = approval_value
|
| 368 |
-
return {"approval_required": approval_value, "compliance_mode": "strict"}
|
| 369 |
-
|
| 370 |
-
approval_toggle.change(
|
| 371 |
-
sync_approval_toggle,
|
| 372 |
-
inputs=[approval_toggle],
|
| 373 |
-
outputs=[config_display]
|
| 374 |
-
)
|
| 375 |
-
|
| 376 |
-
# Update visualization based on selection
|
| 377 |
-
def update_visualization(scenario_name, viz_type_name):
|
| 378 |
-
"""Update visualization based on selection"""
|
| 379 |
-
if viz_type_name == "Interactive Timeline":
|
| 380 |
-
fig = demo.viz_engine.create_interactive_timeline([])
|
| 381 |
-
else:
|
| 382 |
-
fig = go.Figure()
|
| 383 |
-
fig.update_layout(
|
| 384 |
-
paper_bgcolor='rgba(0,0,0,0)',
|
| 385 |
-
height=400,
|
| 386 |
-
annotations=[dict(
|
| 387 |
-
text=f"{viz_type_name} Visualization<br>for {scenario_name}",
|
| 388 |
-
xref="paper", yref="paper",
|
| 389 |
-
x=0.5, y=0.5, showarrow=False
|
| 390 |
-
)]
|
| 391 |
)
|
| 392 |
-
return fig
|
| 393 |
-
|
| 394 |
-
scenario.change(
|
| 395 |
-
update_visualization,
|
| 396 |
-
inputs=[scenario, viz_type],
|
| 397 |
-
outputs=[timeline_viz]
|
| 398 |
-
)
|
| 399 |
-
|
| 400 |
-
viz_type.change(
|
| 401 |
-
update_visualization,
|
| 402 |
-
inputs=[scenario, viz_type],
|
| 403 |
-
outputs=[timeline_viz]
|
| 404 |
-
)
|
| 405 |
-
|
| 406 |
-
# Enterprise execution with approval flow
|
| 407 |
-
enterprise_btn.click(
|
| 408 |
-
demo.execute_with_approval_flow,
|
| 409 |
-
inputs=[scenario, approval_toggle],
|
| 410 |
-
outputs=[approval_display, results, config_display]
|
| 411 |
-
)
|
| 412 |
|
| 413 |
# TAB 2: BUSINESS IMPACT & ROI
|
| 414 |
-
with gr.TabItem("💰 Business Impact & ROI", id=
|
| 415 |
with gr.Column():
|
|
|
|
| 416 |
gr.Markdown("### 📊 Business Health Dashboard")
|
| 417 |
-
|
| 418 |
|
|
|
|
| 419 |
gr.Markdown("### 🧮 Interactive ROI Calculator")
|
| 420 |
with gr.Row():
|
| 421 |
with gr.Column(scale=1):
|
| 422 |
-
|
| 423 |
1, 100, value=15, step=1,
|
| 424 |
label="Monthly incidents"
|
| 425 |
)
|
| 426 |
-
|
| 427 |
1000, 50000, value=8500, step=500,
|
| 428 |
label="Avg incident impact ($)"
|
| 429 |
)
|
| 430 |
-
|
| 431 |
1, 20, value=5, step=1,
|
| 432 |
label="Reliability team size"
|
| 433 |
)
|
| 434 |
calculate_btn = gr.Button("Calculate My ROI", variant="primary")
|
| 435 |
|
| 436 |
with gr.Column(scale=2):
|
| 437 |
-
|
|
|
|
|
|
|
|
|
|
| 438 |
|
| 439 |
-
#
|
| 440 |
gr.Markdown("### 📋 Capability Comparison")
|
| 441 |
with gr.Row():
|
| 442 |
with gr.Column():
|
| 443 |
gr.Markdown("""
|
| 444 |
**OSS Edition (Free)**
|
| 445 |
- Advisory recommendations only
|
| 446 |
-
- Manual implementation
|
| 447 |
- No auto-healing
|
| 448 |
- Community support
|
|
|
|
| 449 |
""")
|
| 450 |
with gr.Column():
|
| 451 |
gr.Markdown("""
|
| 452 |
**Enterprise Edition**
|
| 453 |
- Autonomous execution
|
| 454 |
- 81.7% auto-heal rate
|
| 455 |
-
- Full audit trails
|
| 456 |
- 24/7 enterprise support
|
| 457 |
- 5.2× average ROI
|
|
|
|
| 458 |
""")
|
| 459 |
|
| 460 |
-
# TAB 3: AUDIT TRAIL
|
| 461 |
-
with gr.TabItem("📜 Audit Trail", id=
|
| 462 |
with gr.Row():
|
| 463 |
-
with gr.Column():
|
| 464 |
gr.Markdown("### 📋 Recent Executions")
|
| 465 |
with gr.Row():
|
| 466 |
refresh_btn = gr.Button("🔄 Refresh", size="sm")
|
| 467 |
clear_btn = gr.Button("🗑️ Clear All", variant="stop", size="sm")
|
| 468 |
-
export_btn = gr.Button("📥 Export to CSV", size="sm")
|
| 469 |
|
| 470 |
audit_table = gr.Dataframe(
|
| 471 |
headers=["Time", "Scenario", "Actions", "Status", "Savings"],
|
| 472 |
value=[
|
| 473 |
["22:14", "Cache Miss Storm", "4", "✅ Executed", "$7,200"],
|
| 474 |
-
["21:58", "Memory Leak", "3", "✅ Executed", "$5,200"]
|
|
|
|
|
|
|
| 475 |
],
|
| 476 |
-
interactive=False
|
|
|
|
| 477 |
)
|
| 478 |
|
| 479 |
-
with gr.Column():
|
| 480 |
gr.Markdown("### 📈 Execution History")
|
| 481 |
-
|
| 482 |
|
| 483 |
# ============ FOOTER ============
|
| 484 |
gr.Markdown("---")
|
| 485 |
with gr.Row():
|
| 486 |
with gr.Column(scale=2):
|
| 487 |
gr.Markdown("""
|
| 488 |
-
**📞 Contact & Demo**
|
| 489 |
📧 enterprise@arf.dev
|
| 490 |
🌐 [https://arf.dev](https://arf.dev)
|
| 491 |
📚 [Documentation](https://docs.arf.dev)
|
|
@@ -493,78 +778,100 @@ def create_enhanced_interface():
|
|
| 493 |
""")
|
| 494 |
with gr.Column(scale=1):
|
| 495 |
gr.Markdown("""
|
| 496 |
-
**🎯 Schedule a Demo**
|
| 497 |
[https://arf.dev/demo](https://arf.dev/demo)
|
| 498 |
""")
|
| 499 |
|
| 500 |
-
# ============
|
| 501 |
-
def load_initial_dashboard():
|
| 502 |
-
"""Load initial dashboard data"""
|
| 503 |
-
dashboard_fig = demo.viz_engine.create_business_health_dashboard()
|
| 504 |
-
|
| 505 |
-
# Default ROI calculation
|
| 506 |
-
roi_data = {
|
| 507 |
-
"estimated_annual_impact": "$1,530,000",
|
| 508 |
-
"enterprise_savings": "$1,254,600",
|
| 509 |
-
"enterprise_cost": "$750,000",
|
| 510 |
-
"roi_multiplier": "1.7×",
|
| 511 |
-
"payback_period": "7.2 months",
|
| 512 |
-
"recommendation": "✅ Strong Enterprise ROI potential"
|
| 513 |
-
}
|
| 514 |
-
|
| 515 |
-
return dashboard_fig, roi_data
|
| 516 |
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 520 |
)
|
| 521 |
|
| 522 |
-
#
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
roi = savings / team_cost if team_cost > 0 else 0
|
| 530 |
-
|
| 531 |
-
return {
|
| 532 |
-
"your_annual_impact": f"${annual_impact:,.0f}",
|
| 533 |
-
"your_team_cost": f"${team_cost:,.0f}",
|
| 534 |
-
"potential_savings": f"${savings:,.0f}",
|
| 535 |
-
"your_roi": f"{roi:.1f}×",
|
| 536 |
-
"vs_industry": f"Industry average: 5.2× ROI",
|
| 537 |
-
"recommendation": "✅ Enterprise recommended" if roi >= 2 else "⚠️ Consider OSS edition"
|
| 538 |
-
}
|
| 539 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
calculate_btn.click(
|
| 541 |
calculate_roi,
|
| 542 |
-
inputs=[
|
| 543 |
-
outputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 544 |
)
|
| 545 |
|
| 546 |
-
return
|
| 547 |
|
| 548 |
# ===========================================
|
| 549 |
# LAUNCH APPLICATION
|
| 550 |
# ===========================================
|
| 551 |
|
| 552 |
if __name__ == "__main__":
|
| 553 |
-
|
| 554 |
-
|
| 555 |
-
logger
|
| 556 |
-
|
| 557 |
-
logger.info("
|
| 558 |
-
logger.info("✅ All UX fixes applied")
|
| 559 |
-
logger.info("✅ Approval flow synchronized")
|
| 560 |
-
logger.info("✅ Interactive timeline working")
|
| 561 |
-
logger.info("✅ Business dashboard enhanced")
|
| 562 |
|
| 563 |
-
|
| 564 |
-
demo = create_enhanced_interface()
|
| 565 |
demo.launch(
|
| 566 |
server_name="0.0.0.0",
|
| 567 |
server_port=7860,
|
| 568 |
share=False,
|
| 569 |
-
debug=False
|
|
|
|
| 570 |
)
|
|
|
|
| 1 |
"""
|
| 2 |
+
🚀 ARF ULTIMATE INVESTOR DEMO v3.5.0 - FULLY WORKING VERSION
|
| 3 |
+
All buttons working, all visualizations rendering, no errors
|
|
|
|
| 4 |
"""
|
| 5 |
|
| 6 |
import datetime
|
|
|
|
| 9 |
import uuid
|
| 10 |
import random
|
| 11 |
from typing import Dict, Any, List
|
|
|
|
|
|
|
| 12 |
import gradio as gr
|
| 13 |
import plotly.graph_objects as go
|
| 14 |
import plotly.express as px
|
| 15 |
import pandas as pd
|
| 16 |
from plotly.subplots import make_subplots
|
| 17 |
|
| 18 |
+
# Configure logging
|
| 19 |
+
logging.basicConfig(level=logging.INFO)
|
| 20 |
+
logger = logging.getLogger(__name__)
|
| 21 |
+
|
| 22 |
# ===========================================
|
| 23 |
+
# INCIDENT DATA STORAGE
|
| 24 |
# ===========================================
|
| 25 |
|
| 26 |
+
INCIDENT_SCENARIOS = {
|
| 27 |
+
"Cache Miss Storm": {
|
| 28 |
+
"metrics": {
|
| 29 |
+
"Cache Hit Rate": "18.5% (Critical)",
|
| 30 |
+
"Database Load": "92% (Overloaded)",
|
| 31 |
+
"Response Time": "1850ms (Slow)",
|
| 32 |
+
"Affected Users": "45,000"
|
| 33 |
+
},
|
| 34 |
+
"impact": {
|
| 35 |
+
"Revenue Loss": "$8,500/hour",
|
| 36 |
+
"Page Load Time": "+300%",
|
| 37 |
+
"Users Impacted": "45,000"
|
| 38 |
+
},
|
| 39 |
+
"oss_analysis": {
|
| 40 |
+
"status": "✅ Analysis Complete",
|
| 41 |
+
"recommendations": [
|
| 42 |
+
"Increase Redis cache memory allocation",
|
| 43 |
+
"Implement cache warming strategy",
|
| 44 |
+
"Optimize key patterns (TTL adjustments)",
|
| 45 |
+
"Add circuit breaker for database fallback"
|
| 46 |
+
],
|
| 47 |
+
"estimated_time": "60+ minutes",
|
| 48 |
+
"engineers_needed": "2-3 SREs",
|
| 49 |
+
"manual_effort": "High"
|
| 50 |
+
},
|
| 51 |
+
"enterprise_results": {
|
| 52 |
+
"actions_completed": [
|
| 53 |
+
"✅ Auto-scaled Redis: 4GB → 8GB",
|
| 54 |
+
"✅ Deployed cache warming service",
|
| 55 |
+
"✅ Optimized 12 key patterns",
|
| 56 |
+
"✅ Implemented circuit breaker"
|
| 57 |
+
],
|
| 58 |
+
"metrics_improvement": {
|
| 59 |
+
"Cache Hit Rate": "18.5% → 72%",
|
| 60 |
+
"Response Time": "1850ms → 450ms",
|
| 61 |
+
"Database Load": "92% → 45%"
|
| 62 |
+
},
|
| 63 |
+
"business_impact": {
|
| 64 |
+
"Recovery Time": "60 min → 12 min",
|
| 65 |
+
"Cost Saved": "$7,200",
|
| 66 |
+
"Users Impacted": "45,000 → 0"
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
},
|
| 70 |
+
"Database Connection Pool Exhaustion": {
|
| 71 |
+
"metrics": {
|
| 72 |
+
"Active Connections": "98/100 (Critical)",
|
| 73 |
+
"API Latency": "2450ms",
|
| 74 |
+
"Error Rate": "15.2%",
|
| 75 |
+
"Queue Depth": "1250"
|
| 76 |
+
},
|
| 77 |
+
"impact": {
|
| 78 |
+
"Revenue Loss": "$4,200/hour",
|
| 79 |
+
"Affected Services": "API Gateway, User Service",
|
| 80 |
+
"SLA Violation": "Yes"
|
| 81 |
+
},
|
| 82 |
+
"oss_analysis": {
|
| 83 |
+
"status": "✅ Analysis Complete",
|
| 84 |
+
"recommendations": [
|
| 85 |
+
"Increase connection pool from 100 to 200",
|
| 86 |
+
"Add connection timeout (30s)",
|
| 87 |
+
"Implement leak detection",
|
| 88 |
+
"Add connection health checks"
|
| 89 |
+
],
|
| 90 |
+
"estimated_time": "45+ minutes",
|
| 91 |
+
"engineers_needed": "1-2 DBAs",
|
| 92 |
+
"manual_effort": "Medium-High"
|
| 93 |
+
}
|
| 94 |
+
},
|
| 95 |
+
"Memory Leak in Production": {
|
| 96 |
+
"metrics": {
|
| 97 |
+
"Memory Usage": "96% (Critical)",
|
| 98 |
+
"GC Pause Time": "4500ms",
|
| 99 |
+
"Error Rate": "28.5%",
|
| 100 |
+
"Restart Frequency": "12/hour"
|
| 101 |
+
},
|
| 102 |
+
"impact": {
|
| 103 |
+
"Revenue Loss": "$5,500/hour",
|
| 104 |
+
"Session Loss": "8,500 users",
|
| 105 |
+
"Customer Impact": "High"
|
| 106 |
+
}
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
# ===========================================
|
| 111 |
+
# VISUALIZATION ENGINE
|
| 112 |
+
# ===========================================
|
| 113 |
+
|
| 114 |
+
class VisualizationEngine:
|
| 115 |
+
"""Working visualization engine with no errors"""
|
| 116 |
|
| 117 |
+
@staticmethod
|
| 118 |
+
def create_timeline_visualization():
|
| 119 |
+
"""Create interactive incident timeline"""
|
| 120 |
try:
|
| 121 |
+
# Create sample timeline data
|
| 122 |
+
now = datetime.datetime.now()
|
| 123 |
+
events = [
|
| 124 |
+
{"time": now - datetime.timedelta(minutes=25), "event": "📉 Cache Hit Rate drops to 18.5%", "type": "problem"},
|
| 125 |
+
{"time": now - datetime.timedelta(minutes=22), "event": "⚠️ Alert: Database load hits 92%", "type": "alert"},
|
| 126 |
+
{"time": now - datetime.timedelta(minutes=20), "event": "🤖 ARF detects pattern", "type": "detection"},
|
| 127 |
+
{"time": now - datetime.timedelta(minutes=18), "event": "🧠 Analysis: Cache Miss Storm identified", "type": "analysis"},
|
| 128 |
+
{"time": now - datetime.timedelta(minutes=15), "event": "⚡ Enterprise healing executed", "type": "action"},
|
| 129 |
+
{"time": now - datetime.timedelta(minutes=12), "event": "✅ Cache Hit Rate recovers to 72%", "type": "recovery"},
|
| 130 |
+
{"time": now - datetime.timedelta(minutes=10), "event": "📊 System stabilized", "type": "stable"}
|
| 131 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
+
df = pd.DataFrame(events)
|
| 134 |
+
df['time_str'] = df['time'].dt.strftime('%H:%M:%S')
|
| 135 |
+
|
| 136 |
+
# Color mapping
|
| 137 |
+
color_map = {
|
| 138 |
+
"problem": "red",
|
| 139 |
+
"alert": "orange",
|
| 140 |
+
"detection": "blue",
|
| 141 |
+
"analysis": "purple",
|
| 142 |
+
"action": "green",
|
| 143 |
+
"recovery": "lightgreen",
|
| 144 |
+
"stable": "darkgreen"
|
| 145 |
+
}
|
| 146 |
|
| 147 |
+
fig = go.Figure()
|
|
|
|
|
|
|
| 148 |
|
| 149 |
+
for event_type in df['type'].unique():
|
| 150 |
+
type_df = df[df['type'] == event_type]
|
| 151 |
fig.add_trace(go.Scatter(
|
| 152 |
+
x=type_df['time'],
|
| 153 |
+
y=[event_type] * len(type_df),
|
| 154 |
mode='markers+text',
|
| 155 |
+
name=event_type.capitalize(),
|
| 156 |
marker=dict(
|
| 157 |
+
size=15,
|
| 158 |
+
color=color_map.get(event_type, 'gray'),
|
| 159 |
+
symbol='circle' if event_type in ['problem', 'alert'] else 'diamond',
|
| 160 |
line=dict(width=2, color='white')
|
| 161 |
),
|
| 162 |
+
text=type_df['event'],
|
| 163 |
textposition="top center",
|
| 164 |
+
hoverinfo='text'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
))
|
| 166 |
|
| 167 |
fig.update_layout(
|
| 168 |
+
title="<b>Incident Timeline - Cache Miss Storm Resolution</b>",
|
| 169 |
xaxis_title="Time →",
|
| 170 |
+
yaxis_title="Event Type",
|
| 171 |
+
height=500,
|
| 172 |
+
showlegend=True,
|
| 173 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 174 |
plot_bgcolor='rgba(0,0,0,0)',
|
|
|
|
| 175 |
hovermode='closest',
|
| 176 |
+
xaxis=dict(
|
| 177 |
+
tickformat='%H:%M',
|
| 178 |
+
gridcolor='rgba(200,200,200,0.2)'
|
| 179 |
+
),
|
| 180 |
+
yaxis=dict(
|
| 181 |
+
gridcolor='rgba(200,200,200,0.1)'
|
| 182 |
+
)
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
return fig
|
| 186 |
+
except Exception as e:
|
| 187 |
+
logger.error(f"Error creating timeline: {e}")
|
| 188 |
+
return VisualizationEngine._create_error_figure("Timeline")
|
| 189 |
+
|
| 190 |
+
@staticmethod
|
| 191 |
+
def create_business_dashboard():
|
| 192 |
+
"""Create business health dashboard"""
|
| 193 |
+
try:
|
| 194 |
+
fig = make_subplots(
|
| 195 |
+
rows=2, cols=2,
|
| 196 |
+
subplot_titles=('Annual Cost Impact', 'Team Time Reclaimed',
|
| 197 |
+
'MTTR Comparison', 'ROI Analysis'),
|
| 198 |
+
vertical_spacing=0.15,
|
| 199 |
+
horizontal_spacing=0.15
|
| 200 |
+
)
|
| 201 |
+
|
| 202 |
+
# 1. Cost Impact
|
| 203 |
+
categories = ['Without ARF', 'With ARF Enterprise', 'Net Savings']
|
| 204 |
+
values = [2960000, 1000000, 1960000]
|
| 205 |
+
|
| 206 |
+
fig.add_trace(
|
| 207 |
+
go.Bar(
|
| 208 |
+
x=categories,
|
| 209 |
+
y=values,
|
| 210 |
+
marker_color=['#FF6B6B', '#4ECDC4', '#45B7D1'],
|
| 211 |
+
text=[f'${v/1000000:.1f}M' for v in values],
|
| 212 |
+
textposition='auto',
|
| 213 |
+
name='Cost Impact'
|
| 214 |
+
),
|
| 215 |
+
row=1, col=1
|
| 216 |
+
)
|
| 217 |
+
|
| 218 |
+
# 2. Time Allocation
|
| 219 |
+
labels = ['Firefighting', 'Innovation', 'Maintenance']
|
| 220 |
+
before = [60, 20, 20]
|
| 221 |
+
after = [10, 60, 30]
|
| 222 |
+
|
| 223 |
+
fig.add_trace(
|
| 224 |
+
go.Bar(
|
| 225 |
+
x=labels,
|
| 226 |
+
y=before,
|
| 227 |
+
name='Before ARF',
|
| 228 |
+
marker_color='#FF6B6B'
|
| 229 |
+
),
|
| 230 |
+
row=1, col=2
|
| 231 |
+
)
|
| 232 |
+
|
| 233 |
+
fig.add_trace(
|
| 234 |
+
go.Bar(
|
| 235 |
+
x=labels,
|
| 236 |
+
y=after,
|
| 237 |
+
name='After ARF Enterprise',
|
| 238 |
+
marker_color='#4ECDC4'
|
| 239 |
+
),
|
| 240 |
+
row=1, col=2
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
# 3. MTTR Comparison
|
| 244 |
+
mttr_categories = ['Traditional', 'ARF OSS', 'ARF Enterprise']
|
| 245 |
+
mttr_values = [45, 25, 8]
|
| 246 |
+
|
| 247 |
+
fig.add_trace(
|
| 248 |
+
go.Bar(
|
| 249 |
+
x=mttr_categories,
|
| 250 |
+
y=mttr_values,
|
| 251 |
+
marker_color=['#FF6B6B', '#FFE66D', '#4ECDC4'],
|
| 252 |
+
text=[f'{v} min' for v in mttr_values],
|
| 253 |
+
textposition='auto',
|
| 254 |
+
name='MTTR'
|
| 255 |
+
),
|
| 256 |
+
row=2, col=1
|
| 257 |
+
)
|
| 258 |
+
|
| 259 |
+
# 4. ROI Gauge
|
| 260 |
+
fig.add_trace(
|
| 261 |
+
go.Indicator(
|
| 262 |
+
mode="gauge+number+delta",
|
| 263 |
+
value=5.2,
|
| 264 |
+
title={'text': "ROI Multiplier"},
|
| 265 |
+
delta={'reference': 1.0, 'increasing': {'color': "green"}},
|
| 266 |
+
gauge={
|
| 267 |
+
'axis': {'range': [0, 10], 'tickwidth': 1},
|
| 268 |
+
'bar': {'color': "#4ECDC4"},
|
| 269 |
+
'steps': [
|
| 270 |
+
{'range': [0, 2], 'color': "lightgray"},
|
| 271 |
+
{'range': [2, 4], 'color': "gray"},
|
| 272 |
+
{'range': [4, 6], 'color': "lightgreen"},
|
| 273 |
+
{'range': [6, 10], 'color': "green"}
|
| 274 |
+
],
|
| 275 |
+
'threshold': {
|
| 276 |
+
'line': {'color': "red", 'width': 4},
|
| 277 |
+
'thickness': 0.75,
|
| 278 |
+
'value': 5.2
|
| 279 |
+
}
|
| 280 |
+
}
|
| 281 |
+
),
|
| 282 |
+
row=2, col=2
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
fig.update_layout(
|
| 286 |
+
height=700,
|
| 287 |
showlegend=True,
|
| 288 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 289 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 290 |
+
title_text="<b>Executive Business Health Dashboard</b>",
|
| 291 |
+
barmode='group'
|
| 292 |
+
)
|
| 293 |
+
|
| 294 |
+
# Update axes
|
| 295 |
+
fig.update_xaxes(title_text="Cost Categories", row=1, col=1)
|
| 296 |
+
fig.update_yaxes(title_text="Annual Cost ($)", row=1, col=1)
|
| 297 |
+
|
| 298 |
+
fig.update_xaxes(title_text="Activity Type", row=1, col=2)
|
| 299 |
+
fig.update_yaxes(title_text="Percentage (%)", row=1, col=2)
|
| 300 |
+
|
| 301 |
+
fig.update_xaxes(title_text="Solution Type", row=2, col=1)
|
| 302 |
+
fig.update_yaxes(title_text="Minutes to Resolve", row=2, col=1)
|
| 303 |
+
|
| 304 |
+
return fig
|
| 305 |
+
except Exception as e:
|
| 306 |
+
logger.error(f"Error creating dashboard: {e}")
|
| 307 |
+
return VisualizationEngine._create_error_figure("Dashboard")
|
| 308 |
+
|
| 309 |
+
@staticmethod
|
| 310 |
+
def create_metrics_stream():
|
| 311 |
+
"""Create metrics stream visualization"""
|
| 312 |
+
try:
|
| 313 |
+
# Generate time series data
|
| 314 |
+
times = pd.date_range(end=datetime.datetime.now(), periods=50, freq='1min')
|
| 315 |
+
|
| 316 |
+
fig = go.Figure()
|
| 317 |
+
|
| 318 |
+
# Cache Hit Rate
|
| 319 |
+
fig.add_trace(go.Scatter(
|
| 320 |
+
x=times,
|
| 321 |
+
y=[18.5 + i * 1.2 for i in range(50)], # Recovery trend
|
| 322 |
+
mode='lines',
|
| 323 |
+
name='Cache Hit Rate',
|
| 324 |
+
line=dict(color='blue', width=2),
|
| 325 |
+
yaxis='y1'
|
| 326 |
+
))
|
| 327 |
+
|
| 328 |
+
# Database Load
|
| 329 |
+
fig.add_trace(go.Scatter(
|
| 330 |
+
x=times,
|
| 331 |
+
y=[92 - i * 0.94 for i in range(50)], # Decreasing trend
|
| 332 |
+
mode='lines',
|
| 333 |
+
name='Database Load',
|
| 334 |
+
line=dict(color='red', width=2),
|
| 335 |
+
yaxis='y2'
|
| 336 |
+
))
|
| 337 |
+
|
| 338 |
+
fig.update_layout(
|
| 339 |
+
title="<b>Real-time Metrics Recovery</b>",
|
| 340 |
+
xaxis_title="Time",
|
| 341 |
+
height=500,
|
| 342 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 343 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 344 |
+
yaxis=dict(
|
| 345 |
+
title="Cache Hit Rate (%)",
|
| 346 |
+
side='left',
|
| 347 |
+
range=[0, 100]
|
| 348 |
+
),
|
| 349 |
+
yaxis2=dict(
|
| 350 |
+
title="Database Load (%)",
|
| 351 |
+
side='right',
|
| 352 |
+
overlaying='y',
|
| 353 |
+
range=[0, 100]
|
| 354 |
+
),
|
| 355 |
legend=dict(
|
| 356 |
yanchor="top",
|
| 357 |
y=0.99,
|
| 358 |
xanchor="left",
|
| 359 |
x=0.01
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 360 |
)
|
| 361 |
)
|
| 362 |
|
| 363 |
return fig
|
| 364 |
except Exception as e:
|
| 365 |
+
logger.error(f"Error creating stream: {e}")
|
| 366 |
+
return VisualizationEngine._create_error_figure("Metrics Stream")
|
| 367 |
+
|
| 368 |
+
@staticmethod
|
| 369 |
+
def create_performance_radar():
|
| 370 |
+
"""Create performance radar chart"""
|
| 371 |
+
try:
|
| 372 |
+
categories = ['Reliability', 'Speed', 'Cost Savings', 'Auto-Heal Rate', 'ROI']
|
| 373 |
+
values = [95, 88, 92, 82, 85]
|
| 374 |
+
|
| 375 |
+
fig = go.Figure(data=go.Scatterpolar(
|
| 376 |
+
r=values + [values[0]],
|
| 377 |
+
theta=categories + [categories[0]],
|
| 378 |
+
fill='toself',
|
| 379 |
+
fillcolor='rgba(52, 152, 219, 0.3)',
|
| 380 |
+
line=dict(color='rgba(52, 152, 219, 0.8)', width=2),
|
| 381 |
+
name="ARF Enterprise"
|
| 382 |
+
))
|
| 383 |
+
|
| 384 |
+
fig.update_layout(
|
| 385 |
+
polar=dict(
|
| 386 |
+
radialaxis=dict(
|
| 387 |
+
visible=True,
|
| 388 |
+
range=[0, 100],
|
| 389 |
+
gridcolor='rgba(200, 200, 200, 0.3)'
|
| 390 |
+
)),
|
| 391 |
+
showlegend=True,
|
| 392 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 393 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 394 |
+
height=500,
|
| 395 |
+
title="<b>Performance Radar - ARF Enterprise</b>"
|
| 396 |
+
)
|
| 397 |
+
|
| 398 |
+
return fig
|
| 399 |
+
except Exception as e:
|
| 400 |
+
logger.error(f"Error creating radar: {e}")
|
| 401 |
+
return VisualizationEngine._create_error_figure("Radar Chart")
|
| 402 |
+
|
| 403 |
+
@staticmethod
|
| 404 |
+
def create_execution_history():
|
| 405 |
+
"""Create execution history chart"""
|
| 406 |
+
try:
|
| 407 |
+
executions = [
|
| 408 |
+
{"time": "22:14", "scenario": "Cache Miss Storm", "savings": 7200},
|
| 409 |
+
{"time": "21:58", "scenario": "Memory Leak", "savings": 5200},
|
| 410 |
+
{"time": "21:45", "scenario": "API Rate Limit", "savings": 2800},
|
| 411 |
+
{"time": "21:30", "scenario": "DB Pool Exhaustion", "savings": 3800},
|
| 412 |
+
{"time": "21:15", "scenario": "Cache Miss Storm", "savings": 7200},
|
| 413 |
+
{"time": "21:00", "scenario": "Cascading Failure", "savings": 12500}
|
| 414 |
+
]
|
| 415 |
+
|
| 416 |
+
df = pd.DataFrame(executions)
|
| 417 |
+
|
| 418 |
+
fig = go.Figure(data=[
|
| 419 |
+
go.Bar(
|
| 420 |
+
x=df['scenario'],
|
| 421 |
+
y=df['savings'],
|
| 422 |
+
marker_color='#4ECDC4',
|
| 423 |
+
text=[f'${s:,.0f}' for s in df['savings']],
|
| 424 |
+
textposition='outside',
|
| 425 |
+
name='Cost Saved'
|
| 426 |
+
)
|
| 427 |
+
])
|
| 428 |
+
|
| 429 |
+
fig.update_layout(
|
| 430 |
+
title="<b>Execution History - Cost Savings</b>",
|
| 431 |
+
xaxis_title="Incident Scenario",
|
| 432 |
+
yaxis_title="Cost Saved ($)",
|
| 433 |
+
height=500,
|
| 434 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 435 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 436 |
+
showlegend=False
|
| 437 |
+
)
|
| 438 |
+
|
| 439 |
+
return fig
|
| 440 |
+
except Exception as e:
|
| 441 |
+
logger.error(f"Error creating history chart: {e}")
|
| 442 |
+
return VisualizationEngine._create_error_figure("History Chart")
|
| 443 |
+
|
| 444 |
+
@staticmethod
|
| 445 |
+
def _create_error_figure(chart_type: str):
|
| 446 |
+
"""Create error figure with message"""
|
| 447 |
+
fig = go.Figure()
|
| 448 |
fig.update_layout(
|
|
|
|
|
|
|
| 449 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 450 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 451 |
+
height=400,
|
| 452 |
+
annotations=[dict(
|
| 453 |
+
text=f"{chart_type} visualization<br>will appear here",
|
| 454 |
+
xref="paper", yref="paper",
|
| 455 |
+
x=0.5, y=0.5,
|
| 456 |
+
showarrow=False,
|
| 457 |
+
font=dict(size=16, color="gray")
|
| 458 |
+
)]
|
| 459 |
)
|
|
|
|
| 460 |
return fig
|
| 461 |
|
| 462 |
# ===========================================
|
| 463 |
+
# MAIN APPLICATION
|
| 464 |
# ===========================================
|
| 465 |
|
| 466 |
+
def run_oss_analysis(scenario_name: str):
|
| 467 |
+
"""Run OSS analysis - NOW WORKING"""
|
| 468 |
+
try:
|
| 469 |
+
scenario = INCIDENT_SCENARIOS.get(scenario_name, {})
|
| 470 |
+
analysis = scenario.get("oss_analysis", {})
|
|
|
|
|
|
|
| 471 |
|
| 472 |
+
if not analysis:
|
| 473 |
+
analysis = {
|
| 474 |
+
"status": "✅ Analysis Complete",
|
| 475 |
+
"recommendations": [
|
| 476 |
+
"Increase resource allocation",
|
| 477 |
+
"Implement monitoring",
|
| 478 |
+
"Add circuit breakers",
|
| 479 |
+
"Optimize configuration"
|
| 480 |
+
],
|
| 481 |
+
"estimated_time": "45-60 minutes",
|
| 482 |
+
"engineers_needed": "2-3",
|
| 483 |
+
"manual_effort": "Required"
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
return analysis
|
| 487 |
+
except Exception as e:
|
| 488 |
+
logger.error(f"OSS analysis error: {e}")
|
| 489 |
+
return {
|
| 490 |
+
"status": "❌ Analysis Failed",
|
| 491 |
+
"error": "Please try again",
|
| 492 |
+
"recommendations": ["Check system configuration"]
|
| 493 |
+
}
|
| 494 |
+
|
| 495 |
+
def execute_enterprise_healing(scenario_name: str, approval_required: bool):
|
| 496 |
+
"""Execute enterprise healing - NOW WORKING"""
|
| 497 |
+
try:
|
| 498 |
+
scenario = INCIDENT_SCENARIOS.get(scenario_name, {})
|
| 499 |
+
results = scenario.get("enterprise_results", {})
|
| 500 |
+
|
| 501 |
+
if not results:
|
| 502 |
+
results = {
|
| 503 |
+
"status": "✅ Auto-Executed" if not approval_required else "✅ Approved and Executed",
|
| 504 |
+
"actions_completed": [
|
| 505 |
+
"✅ Auto-scaled resources",
|
| 506 |
+
"✅ Implemented optimization",
|
| 507 |
+
"✅ Deployed monitoring",
|
| 508 |
+
"✅ Validated recovery"
|
| 509 |
+
],
|
| 510 |
+
"cost_saved": f"${random.randint(2000, 8000):,}",
|
| 511 |
+
"time_savings": f"{random.randint(30, 60)} min → {random.randint(5, 15)} min"
|
| 512 |
+
}
|
| 513 |
|
| 514 |
+
# Add approval info
|
| 515 |
+
if approval_required:
|
| 516 |
+
approval_html = f"""
|
| 517 |
+
<div style='padding: 15px; background: #f8f9fa; border-radius: 8px; border-left: 4px solid #007bff; margin: 10px 0;'>
|
| 518 |
+
<h4 style='margin: 0 0 10px 0;'>🛡️ Approval Required</h4>
|
| 519 |
+
<p><b>Action:</b> Scale cache for {scenario_name}</p>
|
| 520 |
+
<p><b>Risk:</b> Low (auto-rollback available)</p>
|
| 521 |
+
<p><b>Status:</b> ✅ <span style='color: green;'>Approved & Executed</span></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
</div>
|
| 523 |
+
"""
|
| 524 |
+
else:
|
| 525 |
+
approval_html = f"""
|
| 526 |
+
<div style='padding: 15px; background: #e8f5e8; border-radius: 8px; border-left: 4px solid #28a745; margin: 10px 0;'>
|
| 527 |
+
<h4 style='margin: 0 0 10px 0;'>⚡ Auto-Executed</h4>
|
| 528 |
+
<p><b>Action:</b> Autonomous healing for {scenario_name}</p>
|
| 529 |
+
<p><b>Mode:</b> Fully autonomous (guardrails active)</p>
|
| 530 |
+
<p><b>Status:</b> ✅ <span style='color: green;'>Successfully completed</span></p>
|
| 531 |
</div>
|
| 532 |
"""
|
| 533 |
+
|
| 534 |
+
return approval_html, {"approval_required": approval_required, "compliance_mode": "strict"}, results
|
| 535 |
+
except Exception as e:
|
| 536 |
+
logger.error(f"Enterprise execution error: {e}")
|
| 537 |
+
error_html = f"<div style='color: red; padding: 10px;'>❌ Execution error: {str(e)}</div>"
|
| 538 |
+
return error_html, {"error": True}, {"status": "Failed"}
|
| 539 |
+
|
| 540 |
+
def update_visualization(scenario_name: str, viz_type: str):
|
| 541 |
+
"""Update visualization based on selection"""
|
| 542 |
+
try:
|
| 543 |
+
viz_engine = VisualizationEngine()
|
| 544 |
+
|
| 545 |
+
if viz_type == "Interactive Timeline":
|
| 546 |
+
return viz_engine.create_timeline_visualization()
|
| 547 |
+
elif viz_type == "Metrics Stream":
|
| 548 |
+
return viz_engine.create_metrics_stream()
|
| 549 |
+
elif viz_type == "Performance Radar":
|
| 550 |
+
return viz_engine.create_performance_radar()
|
| 551 |
+
else:
|
| 552 |
+
return viz_engine.create_timeline_visualization()
|
| 553 |
+
except Exception as e:
|
| 554 |
+
logger.error(f"Visualization error: {e}")
|
| 555 |
+
return VisualizationEngine._create_error_figure("Visualization")
|
| 556 |
+
|
| 557 |
+
def calculate_roi(monthly_incidents: int, avg_impact: int, team_size: int):
|
| 558 |
+
"""Calculate ROI - NOW WORKING"""
|
| 559 |
+
try:
|
| 560 |
+
annual_impact = monthly_incidents * 12 * avg_impact
|
| 561 |
+
team_cost = team_size * 150000 # $150k per engineer
|
| 562 |
+
savings = annual_impact * 0.82 # 82% savings with ARF
|
| 563 |
+
|
| 564 |
+
if team_cost > 0:
|
| 565 |
+
roi_multiplier = savings / team_cost
|
| 566 |
else:
|
| 567 |
+
roi_multiplier = 0
|
| 568 |
+
|
| 569 |
+
# Determine recommendation
|
| 570 |
+
if roi_multiplier >= 5.0:
|
| 571 |
+
recommendation = "✅ Excellent fit for ARF Enterprise"
|
| 572 |
+
icon = "🚀"
|
| 573 |
+
elif roi_multiplier >= 2.0:
|
| 574 |
+
recommendation = "✅ Good ROI with ARF Enterprise"
|
| 575 |
+
icon = "✅"
|
| 576 |
+
elif roi_multiplier >= 1.0:
|
| 577 |
+
recommendation = "⚠️ Consider ARF OSS edition first"
|
| 578 |
+
icon = "ℹ️"
|
| 579 |
+
else:
|
| 580 |
+
recommendation = "⚠️ Start with ARF OSS (free)"
|
| 581 |
+
icon = "🆓"
|
| 582 |
+
|
| 583 |
+
return {
|
| 584 |
+
"analysis": {
|
| 585 |
+
"your_annual_impact": f"${annual_impact:,.0f}",
|
| 586 |
+
"your_team_cost": f"${team_cost:,.0f}",
|
| 587 |
+
"potential_savings": f"${savings:,.0f}",
|
| 588 |
+
"your_roi_multiplier": f"{roi_multiplier:.1f}×",
|
| 589 |
+
"vs_industry_average": "5.2× average ROI",
|
| 590 |
+
"recommendation": f"{icon} {recommendation}",
|
| 591 |
+
"payback_period": f"{(team_cost / (savings / 12)):.1f} months" if savings > 0 else "N/A"
|
| 592 |
}
|
| 593 |
+
}
|
| 594 |
+
except Exception as e:
|
| 595 |
+
logger.error(f"ROI calculation error: {e}")
|
| 596 |
+
return {"error": f"Calculation error: {str(e)}"}
|
| 597 |
|
| 598 |
# ===========================================
|
| 599 |
+
# GRADIO INTERFACE
|
| 600 |
# ===========================================
|
| 601 |
|
| 602 |
+
def create_interface():
|
| 603 |
+
"""Create the Gradio interface"""
|
| 604 |
|
| 605 |
+
with gr.Blocks(
|
| 606 |
+
title="🚀 ARF Investor Demo v3.5.0",
|
| 607 |
+
theme=gr.themes.Soft(),
|
| 608 |
+
css="""
|
| 609 |
+
.gradio-container { max-width: 1200px; margin: auto; }
|
| 610 |
+
h1, h2, h3 { color: #1a365d !important; }
|
| 611 |
+
.primary-button { background: linear-gradient(90deg, #667eea 0%, #764ba2 100%) !important; }
|
| 612 |
+
"""
|
| 613 |
+
) as demo:
|
| 614 |
|
| 615 |
# ============ HEADER ============
|
| 616 |
gr.Markdown("""
|
|
|
|
| 620 |
**Experience the transformation:** OSS (Advisory) ↔ Enterprise (Autonomous)
|
| 621 |
""")
|
| 622 |
|
| 623 |
+
# ============ MAIN TABS ============
|
| 624 |
with gr.Tabs():
|
| 625 |
|
| 626 |
# TAB 1: LIVE INCIDENT DEMO
|
| 627 |
+
with gr.TabItem("🔥 Live Incident Demo", id="live-demo"):
|
| 628 |
with gr.Row():
|
| 629 |
# Left Panel
|
| 630 |
with gr.Column(scale=1):
|
| 631 |
gr.Markdown("### 🎬 Incident Scenario")
|
| 632 |
+
scenario_dropdown = gr.Dropdown(
|
| 633 |
+
choices=list(INCIDENT_SCENARIOS.keys()),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 634 |
value="Cache Miss Storm",
|
| 635 |
label="Select critical incident:"
|
| 636 |
)
|
| 637 |
|
| 638 |
gr.Markdown("### 📊 Current Crisis Metrics")
|
| 639 |
+
metrics_display = gr.JSON(
|
| 640 |
+
value=INCIDENT_SCENARIOS["Cache Miss Storm"]["metrics"]
|
| 641 |
+
)
|
|
|
|
|
|
|
|
|
|
| 642 |
|
| 643 |
gr.Markdown("### 💰 Business Impact")
|
| 644 |
+
impact_display = gr.JSON(
|
| 645 |
+
value=INCIDENT_SCENARIOS["Cache Miss Storm"]["impact"]
|
| 646 |
+
)
|
|
|
|
|
|
|
| 647 |
|
| 648 |
+
# Right Panel
|
| 649 |
with gr.Column(scale=2):
|
| 650 |
+
# Visualization
|
| 651 |
gr.Markdown("### 📈 Incident Timeline Visualization")
|
| 652 |
+
viz_radio = gr.Radio(
|
| 653 |
choices=["Interactive Timeline", "Metrics Stream", "Performance Radar"],
|
| 654 |
value="Interactive Timeline",
|
| 655 |
label="Choose visualization:"
|
| 656 |
)
|
| 657 |
|
| 658 |
+
timeline_output = gr.Plot()
|
|
|
|
| 659 |
|
| 660 |
+
# Action Buttons
|
| 661 |
with gr.Row():
|
| 662 |
oss_btn = gr.Button("🆓 Run OSS Analysis", variant="secondary")
|
| 663 |
enterprise_btn = gr.Button("🚀 Execute Enterprise Healing", variant="primary")
|
| 664 |
|
| 665 |
+
# Approval Toggle
|
| 666 |
approval_toggle = gr.Checkbox(
|
| 667 |
label="🔐 Require Manual Approval",
|
| 668 |
value=True,
|
| 669 |
info="Toggle to show approval workflow vs auto-execution"
|
| 670 |
)
|
| 671 |
|
| 672 |
+
# Approval Display
|
| 673 |
+
approval_display = gr.HTML(
|
| 674 |
+
value="<div style='padding: 10px; background: #f8f9fa; border-radius: 5px;'>Approval status will appear here</div>"
|
| 675 |
+
)
|
| 676 |
|
| 677 |
+
# Configuration
|
| 678 |
config_display = gr.JSON(
|
| 679 |
label="⚙️ Enterprise Configuration",
|
| 680 |
value={"approval_required": True, "compliance_mode": "strict"}
|
| 681 |
)
|
| 682 |
|
| 683 |
+
# Results
|
| 684 |
+
results_display = gr.JSON(
|
| 685 |
+
label="🎯 Execution Results",
|
| 686 |
+
value={"status": "Ready for execution..."}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 687 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 688 |
|
| 689 |
# TAB 2: BUSINESS IMPACT & ROI
|
| 690 |
+
with gr.TabItem("💰 Business Impact & ROI", id="business-roi"):
|
| 691 |
with gr.Column():
|
| 692 |
+
# Business Dashboard
|
| 693 |
gr.Markdown("### 📊 Business Health Dashboard")
|
| 694 |
+
dashboard_output = gr.Plot()
|
| 695 |
|
| 696 |
+
# ROI Calculator
|
| 697 |
gr.Markdown("### 🧮 Interactive ROI Calculator")
|
| 698 |
with gr.Row():
|
| 699 |
with gr.Column(scale=1):
|
| 700 |
+
monthly_slider = gr.Slider(
|
| 701 |
1, 100, value=15, step=1,
|
| 702 |
label="Monthly incidents"
|
| 703 |
)
|
| 704 |
+
impact_slider = gr.Slider(
|
| 705 |
1000, 50000, value=8500, step=500,
|
| 706 |
label="Avg incident impact ($)"
|
| 707 |
)
|
| 708 |
+
team_slider = gr.Slider(
|
| 709 |
1, 20, value=5, step=1,
|
| 710 |
label="Reliability team size"
|
| 711 |
)
|
| 712 |
calculate_btn = gr.Button("Calculate My ROI", variant="primary")
|
| 713 |
|
| 714 |
with gr.Column(scale=2):
|
| 715 |
+
roi_output = gr.JSON(
|
| 716 |
+
label="Your ROI Analysis",
|
| 717 |
+
value={"analysis": "Adjust sliders and click 'Calculate My ROI'"}
|
| 718 |
+
)
|
| 719 |
|
| 720 |
+
# Capability Comparison
|
| 721 |
gr.Markdown("### 📋 Capability Comparison")
|
| 722 |
with gr.Row():
|
| 723 |
with gr.Column():
|
| 724 |
gr.Markdown("""
|
| 725 |
**OSS Edition (Free)**
|
| 726 |
- Advisory recommendations only
|
| 727 |
+
- Manual implementation required
|
| 728 |
- No auto-healing
|
| 729 |
- Community support
|
| 730 |
+
- No ROI measurement
|
| 731 |
""")
|
| 732 |
with gr.Column():
|
| 733 |
gr.Markdown("""
|
| 734 |
**Enterprise Edition**
|
| 735 |
- Autonomous execution
|
| 736 |
- 81.7% auto-heal rate
|
| 737 |
+
- Full audit trails & compliance
|
| 738 |
- 24/7 enterprise support
|
| 739 |
- 5.2× average ROI
|
| 740 |
+
- 2-3 month payback
|
| 741 |
""")
|
| 742 |
|
| 743 |
+
# TAB 3: AUDIT TRAIL
|
| 744 |
+
with gr.TabItem("📜 Audit Trail", id="audit-trail"):
|
| 745 |
with gr.Row():
|
| 746 |
+
with gr.Column(scale=1):
|
| 747 |
gr.Markdown("### 📋 Recent Executions")
|
| 748 |
with gr.Row():
|
| 749 |
refresh_btn = gr.Button("🔄 Refresh", size="sm")
|
| 750 |
clear_btn = gr.Button("🗑️ Clear All", variant="stop", size="sm")
|
|
|
|
| 751 |
|
| 752 |
audit_table = gr.Dataframe(
|
| 753 |
headers=["Time", "Scenario", "Actions", "Status", "Savings"],
|
| 754 |
value=[
|
| 755 |
["22:14", "Cache Miss Storm", "4", "✅ Executed", "$7,200"],
|
| 756 |
+
["21:58", "Memory Leak", "3", "✅ Executed", "$5,200"],
|
| 757 |
+
["21:45", "API Rate Limit", "4", "✅ Executed", "$2,800"],
|
| 758 |
+
["21:30", "DB Connection Pool", "4", "✅ Executed", "$3,800"]
|
| 759 |
],
|
| 760 |
+
interactive=False,
|
| 761 |
+
wrap=True
|
| 762 |
)
|
| 763 |
|
| 764 |
+
with gr.Column(scale=2):
|
| 765 |
gr.Markdown("### 📈 Execution History")
|
| 766 |
+
history_output = gr.Plot()
|
| 767 |
|
| 768 |
# ============ FOOTER ============
|
| 769 |
gr.Markdown("---")
|
| 770 |
with gr.Row():
|
| 771 |
with gr.Column(scale=2):
|
| 772 |
gr.Markdown("""
|
| 773 |
+
**📞 Contact & Demo**
|
| 774 |
📧 enterprise@arf.dev
|
| 775 |
🌐 [https://arf.dev](https://arf.dev)
|
| 776 |
📚 [Documentation](https://docs.arf.dev)
|
|
|
|
| 778 |
""")
|
| 779 |
with gr.Column(scale=1):
|
| 780 |
gr.Markdown("""
|
| 781 |
+
**🎯 Schedule a Demo**
|
| 782 |
[https://arf.dev/demo](https://arf.dev/demo)
|
| 783 |
""")
|
| 784 |
|
| 785 |
+
# ============ EVENT HANDLERS ============
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 786 |
|
| 787 |
+
# Scenario change updates metrics and visualization
|
| 788 |
+
scenario_dropdown.change(
|
| 789 |
+
lambda name: (
|
| 790 |
+
INCIDENT_SCENARIOS.get(name, {}).get("metrics", {}),
|
| 791 |
+
INCIDENT_SCENARIOS.get(name, {}).get("impact", {}),
|
| 792 |
+
update_visualization(name, "Interactive Timeline")
|
| 793 |
+
),
|
| 794 |
+
inputs=[scenario_dropdown],
|
| 795 |
+
outputs=[metrics_display, impact_display, timeline_output]
|
| 796 |
)
|
| 797 |
|
| 798 |
+
# Visualization type change
|
| 799 |
+
viz_radio.change(
|
| 800 |
+
lambda scenario, viz: update_visualization(scenario, viz),
|
| 801 |
+
inputs=[scenario_dropdown, viz_radio],
|
| 802 |
+
outputs=[timeline_output]
|
| 803 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 804 |
|
| 805 |
+
# OSS Analysis button - NOW WORKING
|
| 806 |
+
oss_btn.click(
|
| 807 |
+
lambda scenario: run_oss_analysis(scenario),
|
| 808 |
+
inputs=[scenario_dropdown],
|
| 809 |
+
outputs=[results_display]
|
| 810 |
+
)
|
| 811 |
+
|
| 812 |
+
# Enterprise Execution button - NOW WORKING
|
| 813 |
+
enterprise_btn.click(
|
| 814 |
+
lambda scenario, approval: execute_enterprise_healing(scenario, approval),
|
| 815 |
+
inputs=[scenario_dropdown, approval_toggle],
|
| 816 |
+
outputs=[approval_display, config_display, results_display]
|
| 817 |
+
)
|
| 818 |
+
|
| 819 |
+
# Approval toggle updates config
|
| 820 |
+
approval_toggle.change(
|
| 821 |
+
lambda approval: {"approval_required": approval, "compliance_mode": "strict"},
|
| 822 |
+
inputs=[approval_toggle],
|
| 823 |
+
outputs=[config_display]
|
| 824 |
+
)
|
| 825 |
+
|
| 826 |
+
# ROI Calculation - NOW WORKING
|
| 827 |
calculate_btn.click(
|
| 828 |
calculate_roi,
|
| 829 |
+
inputs=[monthly_slider, impact_slider, team_slider],
|
| 830 |
+
outputs=[roi_output]
|
| 831 |
+
)
|
| 832 |
+
|
| 833 |
+
# Load initial visualizations
|
| 834 |
+
demo.load(
|
| 835 |
+
lambda: (
|
| 836 |
+
VisualizationEngine.create_business_dashboard(),
|
| 837 |
+
VisualizationEngine.create_execution_history()
|
| 838 |
+
),
|
| 839 |
+
outputs=[dashboard_output, history_output]
|
| 840 |
+
)
|
| 841 |
+
|
| 842 |
+
# Refresh audit trail
|
| 843 |
+
refresh_btn.click(
|
| 844 |
+
lambda: VisualizationEngine.create_execution_history(),
|
| 845 |
+
outputs=[history_output]
|
| 846 |
+
)
|
| 847 |
+
|
| 848 |
+
# Clear audit trail
|
| 849 |
+
clear_btn.click(
|
| 850 |
+
lambda: (
|
| 851 |
+
[],
|
| 852 |
+
VisualizationEngine._create_error_figure("History cleared")
|
| 853 |
+
),
|
| 854 |
+
outputs=[audit_table, history_output]
|
| 855 |
)
|
| 856 |
|
| 857 |
+
return demo
|
| 858 |
|
| 859 |
# ===========================================
|
| 860 |
# LAUNCH APPLICATION
|
| 861 |
# ===========================================
|
| 862 |
|
| 863 |
if __name__ == "__main__":
|
| 864 |
+
logger.info("🚀 Launching ARF Investor Demo v3.5.0 - ALL FIXES APPLIED")
|
| 865 |
+
logger.info("✅ OSS Analysis button: FIXED")
|
| 866 |
+
logger.info("✅ Enterprise Execution: FIXED")
|
| 867 |
+
logger.info("✅ ROI Calculator: FIXED")
|
| 868 |
+
logger.info("✅ All visualizations: WORKING")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 869 |
|
| 870 |
+
demo = create_interface()
|
|
|
|
| 871 |
demo.launch(
|
| 872 |
server_name="0.0.0.0",
|
| 873 |
server_port=7860,
|
| 874 |
share=False,
|
| 875 |
+
debug=False,
|
| 876 |
+
show_error=True
|
| 877 |
)
|