<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Feature Flag Resilience | Audit Service</title>
<!-- Tailwind CSS CDN (JIT) -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Google Fonts: JetBrains Mono -->
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap" rel="stylesheet">
<!-- Custom Config for colors -->
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
mono: ['"JetBrains Mono"', 'monospace'],
},
colors: {
cyber: {
cyan: '#00ffff',
cyanDim: 'rgba(0, 255, 255, 0.2)',
cyanGlow: 'rgba(0, 255, 255, 0.6)',
magenta: '#ff00ff',
magentaDim: 'rgba(255, 0, 255, 0.2)',
amber: '#ffaa00',
amberDim: 'rgba(255, 170, 0, 0.2)',
dark: '#050505',
panel: 'rgba(10, 20, 30, 0.85)',
}
},
animation: {
'pulse-slow': 'pulse 3s cubic-bezier(0.4, 0, 0.6, 1) infinite',
'scan': 'scan 8s linear infinite',
'blink': 'blink 1s step-end infinite',
},
keyframes: {
scan: {
'0%': { transform: 'translateY(-100%)' },
'100%': { transform: 'translateY(100%)' },
},
blink: {
'0%, 100%': { opacity: 1 },
'50%': { opacity: 0 },
}
}
}
}
}
</script>
<style>
body {
background-color: #050505;
color: #00ffff;
overflow: hidden;
margin: 0;
font-family: 'JetBrains Mono', monospace;
}
/* CRT Scanline Overlay */
.scanlines {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: repeating-linear-gradient(
0deg,
rgba(0, 0, 0, 0.15),
rgba(0, 0, 0, 0.15) 1px,
transparent 1px,
transparent 2px
);
pointer-events: none;
z-index: 9999;
}
/* Vignette */
.vignette {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: radial-gradient(circle, transparent 50%, rgba(0,0,0,0.8) 100%);
pointer-events: none;
z-index: 9998;
}
/* Glowing borders */
.neon-border {
box-shadow: 0 0 5px #00ffff, inset 0 0 5px rgba(0,255,255,0.2);
}
.neon-text {
text-shadow: 0 0 5px #00ffff;
}
/* Grid background pattern */
.grid-pattern {
background-size: 40px 40px;
background-image: linear-gradient(to right, rgba(0,255,255,0.05) 1px, transparent 1px),
linear-gradient(to bottom, rgba(0,255,255,0.05) 1px, transparent 1px);
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-track {
background: #0a0a0a;
}
::-webkit-scrollbar-thumb {
background: #00ffff;
border-radius: 2px;
}
/* Decoding animation */
.decoding {
font-family: 'JetBrains Mono', monospace;
min-width: 1ch;
}
</style>
</head>
<body class="grid-pattern">
<!-- Overlays -->
<div class="scanlines"></div>
<div class="vignette"></div>
<!-- Top HUD Bar -->
<header class="fixed top-0 left-0 w-full h-12 border-b border-cyber-cyanDim flex items-center justify-between px-4 bg-cyber-dark/90 z-50">
<div class="flex items-center space-x-2">
<div class="w-3 h-3 bg-cyber-cyan rounded-full animate-pulse shadow-[0_0_8px_#0ff]"></div>
<h1 class="text-sm tracking-widest font-bold neon-text">FEATURE FLAG AUDIT</h1>
<span class="text-xs text-cyber-magenta ml-2">v2.4.77</span>
</div>
<div class="flex items-center space-x-6">
<div id="status-indicator" class="flex items-center space-x-1">
<span class="text-xs">SYSTEM</span>
<span class="w-2 h-2 bg-green-500 rounded-full animate-pulse"></span>
</div>
<div id="clock" class="text-xs tabular-nums">00:00:00</div>
</div>
</header>
<!-- Left Navigation -->
<nav class="fixed left-0 top-12 bottom-0 w-16 border-r border-cyber-cyanDim bg-cyber-dark/80 z-40 flex flex-col items-center py-4 space-y-6">
<button class="nav-btn group relative" data-target="dashboard">
<svg class="w-6 h-6 text-cyber-cyan group-hover:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z"></path></svg>
<span class="absolute left-10 bg-cyber-cyan text-black text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition">DASHBOARD</span>
</button>
<button class="nav-btn group relative" data-target="dependencies">
<svg class="w-6 h-6 text-cyber-magenta group-hover:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"></path></svg>
<span class="absolute left-10 bg-cyber-magenta text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition">DEPENDENCIES</span>
</button>
<button class="nav-btn group relative" data-target="health">
<svg class="w-6 h-6 text-cyber-amber group-hover:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
<span class="absolute left-10 bg-cyber-amber text-black text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition">HEALTH</span>
</button>
<button class="nav-btn group relative" data-target="drift">
<svg class="w-6 h-6 text-red-500 group-hover:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path></svg>
<span class="absolute left-10 bg-red-500 text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition">DRIFT</span>
</button>
<button class="nav-btn group relative" data-target="runbooks">
<svg class="w-6 h-6 text-cyber-cyan group-hover:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17V7m0 10a2 2 0 01-2 2H5a2 2 0 01-2-2V7a2 2 0 012-2h2a2 2 0 012 2m0 10a2 2 0 002 2h2a2 2 0 002-2M9 7a2 2 0 012-2h2a2 2 0 012 2m0 10V7m0 10a2 2 0 002 2h2a2 2 0 002-2V7a2 2 0 00-2-2h-2a2 2 0 00-2 2"></path></svg>
<span class="absolute left-10 bg-cyber-cyan text-black text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition">RUNBOOKS</span>
</button>
<button class="nav-btn group relative" data-target="reporting">
<svg class="w-6 h-6 text-cyber-magenta group-hover:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 12l3-3 3 3 4-4M8 21l4-4 4 4M3 4h18M4 4h16v12a1 1 0 01-1 1H5a1 1 0 01-1-1V4z"></path></svg>
<span class="absolute left-10 bg-cyber-magenta text-white text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition">REPORTING</span>
</button>
<button class="nav-btn group relative" data-target="training">
<svg class="w-6 h-6 text-cyber-amber group-hover:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"></path></svg>
<span class="absolute left-10 bg-cyber-amber text-black text-xs px-2 py-1 rounded opacity-0 group-hover:opacity-100 transition">TRAINING</span>
</button>
<div class="flex-grow"></div>
<button class="nav-btn group relative text-red-500 hover:text-red-300" id="emergency-stop">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 10a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z"></path></svg>
</button>
</nav>
<!-- Main Content -->
<main class="ml-16 pt-12 h-screen flex flex-col p-2 gap-2">
<!-- Top Metrics Row -->
<div class="grid grid-cols-4 gap-2 h-16">
<div class="panel border border-cyber-cyanDim bg-cyber-dark/60 p-2 relative overflow-hidden">
<div class="absolute top-0 right-0 w-2 h-2 bg-cyber-cyan animate-ping"></div>
<div class="text-xs text-cyber-cyanDim">ACTIVE FLAGS</div>
<div class="text-2xl font-bold neon-text decoding" data-value="1,247">0</div>
</div>
<div class="panel border border-cyber-magentaDim bg-cyber-dark/60 p-2 relative overflow-hidden">
<div class="absolute top-0 right-0 w-2 h-2 bg-cyber-magenta animate-ping"></div>
<div class="text-xs text-cyber-magentaDim">DRIFT EVENTS</div>
<div class="text-2xl font-bold text-cyber-magenta decoding" data-value="12">0</div>
</div>
<div class="panel border border-cyber-amberDim bg-cyber-dark/60 p-2 relative overflow-hidden">
<div class="absolute top-0 right-0 w-2 h-2 bg-cyber-amber animate-ping"></div>
<div class="text-xs text-cyber-amberDim">ROLLBACKS (24h)</div>
<div class="text-2xl font-bold text-cyber-amber decoding" data-value="3">0</div>
</div>
<div class="panel border border-green-900/50 bg-cyber-dark/60 p-2 relative overflow-hidden">
<div class="absolute top-0 right-0 w-2 h-2 bg-green-500 animate-ping"></div>
<div class="text-xs text-green-500">SYSTEM HEALTH</div>
<div class="text-2xl font-bold text-green-400 decoding" data-value="98.2%">0%</div>
</div>
</div>
<!-- Main Grid -->
<div class="flex-grow grid grid-cols-3 grid-rows-2 gap-2">
<!-- Row 1, Col 1: Dependency Graph -->
<div id="panel-dependencies" class="panel border border-cyber-cyanDim bg-cyber-dark/60 flex flex-col">
<div class="flex-none border-b border-cyber-cyanDim px-2 py-1 text-sm text-cyber-cyan flex justify-between">
<span>DEPENDENCY GRAPH</span>
<span class="text-xs animate-pulse">LIVE</span>
</div>
<div class="flex-grow relative overflow-hidden">
<canvas id="graph-canvas" class="w-full h-full"></canvas>
<!-- Tooltip -->
<div id="graph-tooltip" class="absolute hidden bg-black/90 border border-cyber-cyan p-2 text-xs z-50 pointer-events-none">
<div class="text-cyber-magenta font-bold">Flag Name</div>
<div>Type: feature</div>
<div>Connections: 5</div>
</div>
</div>
</div>
<!-- Row 1, Col 2: Health Checks -->
<div id="panel-health" class="panel border border-cyber-amberDim bg-cyber-dark/60 flex flex-col">
<div class="flex-none border-b border-cyber-amberDim px-2 py-1 text-sm text-cyber-amber">
HEALTH MONITOR
</div>
<div class="flex-grow overflow-auto p-2 space-y-2" id="health-list">
<!-- dynamic content -->
</div>
</div>
<!-- Row 1, Col 3: Drift Detection -->
<div id="panel-drift" class="panel border border-red-900/50 bg-cyber-dark/60 flex flex-col">
<div class="flex-none border-b border-red-900/50 px-2 py-1 text-sm text-red-500">
DRIFT DETECTION
</div>
<div class="flex-grow overflow-auto">
<table class="w-full text-xs">
<thead class="bg-red-900/20 text-red-300 sticky top-0">
<tr>
<th class="px-2 py-1 text-left">FLAG</th>
<th class="px-2 py-1 text-left">CHANGE</th>
<th class="px-2 py-1 text-left">TIME</th>
<th class="px-2 py-1 text-center">STATUS</th>
</tr>
</thead>
<tbody id="drift-table" class="text-cyber-cyan">
<!-- rows -->
</tbody>
</table>
</div>
</div>
<!-- Row 2, Col 1: Reporting -->
<div id="panel-reporting" class="panel border border-cyber-amberDim bg-cyber-dark/60 flex flex-col">
<div class="flex-none border-b border-cyber-amberDim px-2 py-1 text-sm text-cyber-amber">
REPORTING & METRICS
</div>
<div class="flex-grow relative p-2">
<canvas id="chart-canvas" class="w-full h-full"></canvas>
</div>
</div>
<!-- Row 2, Col 2: Runbooks -->
<div id="panel-runbooks" class="panel border border-cyber-cyanDim bg-cyber-dark/60 flex flex-col">
<div class="flex-none border-b border-cyber-cyanDim px-2 py-1 text-sm text-cyber-cyan flex justify-between">
<span>ROLLBACK RUNBOOKS</span>
<span class="text-xs" id="active-runbook-count">0 ACTIVE</span>
</div>
<div class="flex-grow overflow-auto p-2 space-y-2" id="runbook-list">
<!-- runbook steps -->
</div>
</div>
<!-- Row 2, Col 3: Training -->
<div id="panel-training" class="panel border border-cyber-magentaDim bg-cyber-dark/60 flex flex-col">
<div class="flex-none border-b border-cyber-magentaDim px-2 py-1 text-sm text-cyber-magenta">
STAKEHOLDER TRAINING
</div>
<div class="flex-grow overflow-auto p-2 space-y-3" id="training-list">
<!-- training modules -->
</div>
</div>
</div>
</main>
<!-- Footer log -->
<footer class="ml-16 h-24 border-t border-cyber-cyanDim bg-black flex flex-col">
<div class="text-xs text-cyber-cyanDim px-2 py-0.5 flex justify-between">
<span>SYSTEM LOG</span>
<span>CONN: SECURE</span>
</div>
<div id="system-log" class="flex-grow overflow-auto p-2 text-xs font-mono text-cyber-cyan/80 space-y-0.5">
<!-- log entries -->
</div>
</footer>
<script>
// ========================
// DATA & STATE MANAGEMENT
// ========================
const state = {
flags: [
{ id: 'FF_001', name: 'NEW_CHECKOUT', env: 'prod', status: 'active', dependencies: ['FF_002', 'FF_005'] },
{ id: 'FF_002', name: 'PAYMENT_GATEWAY', env: 'prod', status: 'active', dependencies: [] },
{ id: 'FF_003', name: 'DARK_MODE', env: 'staging', status: 'disabled', dependencies: ['FF_004'] },
{ id: 'FF_004', name: 'UI_REVAMP', env: 'dev', status: 'active', dependencies: [] },
{ id: 'FF_005', name: 'LOGGING_LEVEL', env: 'prod', status: 'active', dependencies: [] },
{ id: 'FF_006', name: 'RECOMMENDATIONS', env: 'prod', status: 'active', dependencies: ['FF_007'] },
{ id: 'FF_007', name: 'AI_MODEL_V2', env: 'prod', status: 'active', dependencies: [] },
{ id: 'FF_008', name: 'SIGNUP_FLOW', env: 'prod', status: 'active', dependencies: ['FF_009', 'FF_010'] },
{ id: 'FF_009', name: 'SOCIAL_LOGIN', env: 'prod', status: 'active', dependencies: [] },
{ id: 'FF_010', name: 'CAPTCHA_SERVICE', env: 'prod', status: 'active', dependencies: [] },
],
health: [
{ name: 'API Gateway', status: 'healthy', uptime: '99.98%' },
{ name: 'Auth Service', status: 'healthy', uptime: '99.95%' },
{ name: 'Flag Service', status: 'warning', uptime: '99.80%' },
{ name: 'Config DB', status: 'healthy', uptime: '100%' },
{ name: 'Event Store', status: 'healthy', uptime: '99.99%' },
{ name: 'Dashboard API', status: 'healthy', uptime: '99.97%' },
],
drift: [
{ flag: 'FF_001', change: 'enabled → disabled', time: '12:34:45', status: 'detected' },
{ flag: 'FF_005', change: 'level: INFO → DEBUG', time: '12:33:22', status: 'approved' },
{ flag: 'FF_008', change: 'audience: 10% → 25%', time: '12:30:15', status: 'rollback' },
],
runbooks: [
{ title: 'Rollback Unauthorized Flag Change', steps: ['Identify flag & target value', 'Initiate rollback via API', 'Verify propagation to all nodes', 'Post-mortem analysis'], active: true },
{ title: 'Mitigate Cascading Failure', steps: ['Isolate affected subsystem', 'Disable dependent flags', 'Restart services', 'Monitor recovery'], active: false },
{ title: 'Recover from Deployment', steps: ['Check deployment history', 'Rollback to previous version', 'Validate health', 'Gradual traffic shift'], active: false },
],
training: [
{ title: 'Feature Flag Fundamentals', duration: '20 min', progress: 100 },
{ title: 'Audit & Compliance', duration: '15 min', progress: 45 },
{ title: 'Emergency Runbook Execution', duration: '10 min', progress: 0 },
{ title: 'Drift Detection Deep Dive', duration: '25 min', progress: 0 },
]
};
// ========================
// UTILITIES
// ========================
function $ (id) { return document.getElementById(id); }
// Decoding effect: scrambles text to final value
function decodeText(element, finalText, duration = 800) {
const start = performance.now();
const original = element.textContent;
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*';
function update(time) {
let elapsed = time - start;
if (elapsed < duration) {
const prob = elapsed / duration;
let displayed = '';
for (let i = 0; i < finalText.length; i++) {
if (i < prob * finalText.length) {
displayed += finalText[i];
} else {
displayed += chars[Math.floor(Math.random() * chars.length)];
}
}
element.textContent = displayed;
requestAnimationFrame(update);
} else {
element.textContent = finalText;
}
}
requestAnimationFrame(update);
}
// Clock
function updateClock() {
const now = new Date();
$('clock').textContent = now.toLocaleTimeString('en-US', { hour12: false });
}
setInterval(updateClock, 1000);
updateClock();
// Logging
function log(message, type = 'info') {
const logContainer = $('system-log');
const time = new Date().toLocaleTimeString('en-US', { hour12: false });
let color = 'text-cyber-cyan';
if (type === 'warn') color = 'text-cyber-amber';
if (type === 'alert') color = 'text-red-500';
const line = document.createElement('div');
line.className = `${color}`;
line.textContent = `[${time}] ${message}`;
logContainer.appendChild(line);
logContainer.scrollTop = logContainer.scrollHeight;
}
// ========================
// DEPENDENCY GRAPH (CANVAS)
// ========================
const graphCanvas = $('graph-canvas');
const graphCtx = graphCanvas.getContext('2d');
let graphNodes = [];
let graphAnimationId;
function initGraph() {
// Resize canvas to container
const container = graphCanvas.parentElement;
graphCanvas.width = container.clientWidth;
graphCanvas.height = container.clientHeight;
// Create nodes from flags
graphNodes = state.flags.map((flag, i) => {
// Distribute in a circle with some randomness
const angle = (i / state.flags.length) * 2 * Math.PI;
const radius = Math.min(graphCanvas.width, graphCanvas.height) * 0.35;
return {
id: flag.id,
name: flag.name,
x: graphCanvas.width/2 + Math.cos(angle) * radius,
y: graphCanvas.height/2 + Math.sin(angle) * radius,
vx: 0,
vy: 0,
radius: 12,
color: flag.status === 'active' ? '#00ffff' : '#555',
connections: flag.dependencies.length
};
});
// Start simulation
if (graphAnimationId) cancelAnimationFrame(graphAnimationId);
graphAnimationId = requestAnimationFrame(animateGraph);
}
function simulateGraph() {
const repulsion = 50;
const attraction = 0.02;
const centerForce = 0.005;
const damping = 0.9;
// Reset forces
graphNodes.forEach(node => {
node.vx = 0;
node.vy = 0;
});
// Apply repulsion between nodes
for (let i = 0; i < graphNodes.length; i++) {
for (let j = i + 1; j < graphNodes.length; j++) {
const a = graphNodes[i];
const b = graphNodes[j];
const dx = a.x - b.x;
const dy = a.y - b.y;
const distSq = dx*dx + dy*dy;
if (distSq > 0) {
const dist = Math.sqrt(distSq);
const force = repulsion / (distSq + 10);
const fx = (dx / dist) * force;
const fy = (dy / dist) * force;
a.vx += fx;
a.vy += fy;
b.vx -= fx;
b.vy -= fy;
}
}
}
// Apply attraction for dependencies
state.flags.forEach(flag => {
const nodeA = graphNodes.find(n => n.id === flag.id);
if (!nodeA) return;
flag.dependencies.forEach(depId => {
const nodeB = graphNodes.find(n => n.id === depId);
if (nodeB) {
const dx = nodeB.x - nodeA.x;
const dy = nodeB.y - nodeA.y;
nodeA.vx += dx * attraction;
nodeA.vy += dy * attraction;
nodeB.vx -= dx * attraction;
nodeB.vy -= dy * attraction;
}
});
});
// Center gravity
const cx = graphCanvas.width / 2;
const cy = graphCanvas.height / 2;
graphNodes.forEach(node => {
node.vx += (cx - node.x) * centerForce;
node.vy += (cy - node.y) * centerForce;
});
// Update positions and damp
graphNodes.forEach(node => {
node.vx *= damping;
node.vy *= damping;
node.x += node.vx;
node.y += node.vy;
// Boundary check
node.x = Math.max(node.radius, Math.min(graphCanvas.width - node.radius, node.x));
node.y = Math.max(node.radius, Math.min(graphCanvas.height - node.radius, node.y));
});
}
function drawGraph() {
graphCtx.clearRect(0, 0, graphCanvas.width, graphCanvas.height);
// Draw connections
graphCtx.strokeStyle = 'rgba(0, 255, 255, 0.3)';
graphCtx.lineWidth = 1;
state.flags.forEach(flag => {
const nodeA = graphNodes.find(n => n.id === flag.id);
if (!nodeA) return;
flag.dependencies.forEach(depId => {
const nodeB = graphNodes.find(n => n.id === depId);
if (nodeB) {
graphCtx.beginPath();
graphCtx.moveTo(nodeA.x, nodeA.y);
graphCtx.lineTo(nodeB.x, nodeB.y);
graphCtx.stroke();
}
});
});
// Draw nodes
graphNodes.forEach(node => {
// Glow
graphCtx.shadowColor = node.color;
graphCtx.shadowBlur = 10;
graphCtx.fillStyle = node.color;
graphCtx.beginPath();
graphCtx.arc(node.x, node.y, node.radius, 0, Math.PI * 2);
graphCtx.fill();
// Reset shadow
graphCtx.shadowBlur = 0;
// ID text
graphCtx.fillStyle = '#000';
graphCtx.font = '8px JetBrains Mono';
graphCtx.textAlign = 'center';
graphCtx.textBaseline = 'middle';
graphCtx.fillText(node.id.split('_')[1], node.x, node.y);
});
// Draw legend
graphCtx.fillStyle = '#00ffff';
graphCtx.font = '10px JetBrains Mono';
graphCtx.fillText('ACTIVE', 10, 20);
graphCtx.fillStyle = '#555';
graphCtx.fillText('INACTIVE', 10, 35);
}
function animateGraph() {
simulateGraph();
drawGraph();
graphAnimationId = requestAnimationFrame(animateGraph);
}
// Canvas interaction (tooltip)
const tooltip = $('graph-tooltip');
graphCanvas.addEventListener('mousemove', (e) => {
const rect = graphCanvas.getBoundingClientRect();
const mx = e.clientX - rect.left;
const my = e.clientY - rect.top;
let hovered = null;
for (const node of graphNodes) {
const dist = Math.sqrt((mx - node.x)**2 + (my - node.y)**2);
if (dist <= node.radius + 2) {
hovered = node;
break;
}
}
if (hovered) {
tooltip.style.left = `${e.clientX + 10}px`;
tooltip.style.top = `${e.clientY + 10}px`;
tooltip.style.display = 'block';
tooltip.querySelector('.text-cyber-magenta').textContent = hovered.name;
tooltip.querySelectorAll('div')[1].textContent = `ID: ${hovered.id}`;
tooltip.querySelectorAll('div')[2].textContent = `Connections: ${hovered.connections}`;
graphCanvas.style.cursor = 'pointer';
} else {
tooltip.style.display = 'none';
graphCanvas.style.cursor = 'default';
}
});
// ========================
// HEALTH CHECKS RENDERER
// ========================
function renderHealth() {
const list = $('health-list');
list.innerHTML = '';
state.health.forEach(item => {
const div = document.createElement('div');
div.className = 'flex items-center justify-between p-2 border border-cyber-amberDim rounded hover:bg-white/5 transition';
const statusColor = item.status === 'healthy' ? 'text-green-400' : (item.status === 'warning' ? 'text-cyber-amber' : 'text-red-500');
const pulse = item.status === 'healthy' ? '' : 'animate-pulse';
div.innerHTML = `
<div class="flex items-center space-x-2">
<div class="w-2 h-2 rounded-full ${statusColor} ${pulse}"></div>
<span class="text-sm">${item.name}</span>
</div>
<span class="text-xs font-mono ${statusColor}">${item.uptime}</span>
`;
list.appendChild(div);
});
}
// Simulate health changes
function tickHealth() {
// Randomly change one service status
const idx = Math.floor(Math.random() * state.health.length);
const svc = state.health[idx];
const statuses = ['healthy', 'healthy', 'healthy', 'warning', 'warning', 'unhealthy'];
const newStatus = statuses[Math.floor(Math.random() * statuses.length)];
svc.status = newStatus;
svc.uptime = (Math.random() * (99.99 - 99.5) + 99.5).toFixed(2) + '%';
renderHealth();
if (newStatus !== 'healthy') {
log(`Health check: ${svc.name} status changed to ${newStatus}`, 'warn');
}
}
// ========================
// DRIFT DETECTION RENDERER
// ========================
function renderDrift() {
const tbody = $('drift-table');
tbody.innerHTML = '';
state.drift.forEach((row, idx) => {
const tr = document.createElement('tr');
const statusClass = row.status === 'detected' ? 'text-red-500' : (row.status === 'approved' ? 'text-green-400' : 'text-cyber-amber');
tr.innerHTML = `
<td class="px-2 py-1 text-cyber-magenta font-bold">${row.flag}</td>
<td class="px-2 py-1">${row.change}</td>
<td class="px-2 py-1 text-cyber-cyanDim tabular-nums">${row.time}</td>
<td class="px-2 py-1 text-center"><span class="px-1 border border-current rounded text-[10px] ${statusClass}">${row.status.toUpperCase()}</span></td>
`;
// Insert at top if new
if (idx === 0) tr.classList.add('bg-red-900/10');
tbody.appendChild(tr);
});
}
function addDriftEvent() {
const flags = state.flags.filter(f => f.status === 'active');
const flag = flags[Math.floor(Math.random() * flags.length)];
const changes = ['enabled → disabled', 'disabled → enabled', 'rollout: 10% → 50%', 'audience: 5% → 100%', 'config: {} → {"debug":true}'];
const change = changes[Math.floor(Math.random() * changes.length)];
const now = new Date().toLocaleTimeString('en-US', { hour12: false });
const statuses = ['detected', 'approved', 'rollback'];
const status = statuses[Math.floor(Math.random() * statuses.length)];
state.drift.unshift({ flag: flag.id, change, time: now, status });
if (state.drift.length > 10) state.drift.pop();
renderDrift();
if (status === 'detected') {
log(`Drift detected on ${flag.id}: ${change}`, 'alert');
}
}
// ========================
// REPORTING CHARTS (CANVAS)
// ========================
const chartCanvas = $('chart-canvas');
const chartCtx = chartCanvas.getContext('2d');
let chartData = Array.from({length: 20}, () => Math.floor(Math.random() * 100));
let chartAnimationId;
function resizeChart() {
const container = chartCanvas.parentElement;
chartCanvas.width = container.clientWidth;
chartCanvas.height = container.clientHeight;
}
function drawChart() {
const w = chartCanvas.width;
const h = chartCanvas.height;
chartCtx.clearRect(0, 0, w, h);
// Grid lines
chartCtx.strokeStyle = 'rgba(0, 255, 255, 0.1)';
chartCtx.lineWidth = 1;
for (let i = 1; i < 5; i++) {
const y = i * h / 5;
chartCtx.beginPath();
chartCtx.moveTo(0, y);
chartCtx.lineTo(w, y);
chartCtx.stroke();
}
// Draw line
chartCtx.strokeStyle = '#00ffff';
chartCtx.lineWidth = 2;
chartCtx.beginPath();
const stepX = w / (chartData.length - 1);
const max = Math.max(...chartData, 100);
chartData.forEach((val, i) => {
const x = i * stepX;
const y = h - (val / max) * h;
if (i === 0) chartCtx.moveTo(x, y);
else chartCtx.lineTo(x, y);
});
chartCtx.stroke();
// Area under
chartCtx.fillStyle = 'rgba(0, 255, 255, 0.1)';
chartCtx.lineTo(w, h);
chartCtx.lineTo(0, h);
chartCtx.fill();
// Draw points
chartCtx.fillStyle = '#ff00ff';
chartData.forEach((val, i) => {
const x = i * stepX;
const y = h - (val / max) * h;
chartCtx.beginPath();
chartCtx.arc(x, y, 3, 0, Math.PI * 2);
chartCtx.fill();
});
// Label
chartCtx.fillStyle = '#00ffff';
chartCtx.font = '10px JetBrains Mono';
chartCtx.fillText('FLAG CHANGES / MIN', 5, 12);
}
function animateChart() {
// Simulate new data point, shift old ones out
chartData.shift();
const prev = chartData[chartData.length-1];
let newVal = prev + (Math.random() - 0.5) * 30;
newVal = Math.max(0, Math.min(100, newVal));
chartData.push(newVal);
drawChart();
chartAnimationId = requestAnimationFrame(animateChart);
}
// ========================
// RUNBOOKS RENDERER
// ========================
function renderRunbooks() {
const list = $('runbook-list');
list.innerHTML = '';
let activeCount = 0;
state.runbooks.forEach(rb => {
if (rb.active) activeCount++;
const div = document.createElement('div');
div.className = `border ${rb.active ? 'border-cyber-cyan' : 'border-cyber-cyanDim/30'} bg-black/40 p-2 rounded text-xs`;
div.innerHTML = `
<div class="flex items-center justify-between mb-2">
<span class="${rb.active ? 'text-cyber-cyan font-bold' : 'text-cyber-cyanDim'}">${rb.title}</span>
<button class="runbook-execute px-2 py-0.5 border border-cyber-cyanDim text-cyber-cyanDim hover:bg-cyber-cyan hover:text-black transition ${rb.active?'opacity-50 cursor-not-allowed':''}" data-index="${state.runbooks.indexOf(rb)}" ${rb.active?'disabled':''}>
${rb.active ? 'RUNNING' : 'EXECUTE'}
</button>
</div>
<ul class="space-y-1 text-cyber-cyan/70">
${rb.steps.map(step => `<li class="flex items-start"><span class="mr-1">▹</span>${step}</li>`).join('')}
</ul>
`;
list.appendChild(div);
});
$('active-runbook-count').textContent = `${activeCount} ACTIVE`;
}
function executeRunbook(index) {
const rb = state.runbooks[index];
if (rb.active) return;
rb.active = true;
renderRunbooks();
log(`Runbook started: ${rb.title}`);
// Simulate completion after 5 seconds
setTimeout(() => {
rb.active = false;
renderRunbooks();
log(`Runbook completed: ${rb.title}`, 'success');
}, 5000);
}
// ========================
// TRAINING RENDERER
// ========================
function renderTraining() {
const list = $('training-list');
list.innerHTML = '';
state.training.forEach((mod, idx) => {
const div = document.createElement('div');
div.className = 'border border-cyber-magentaDim p-2 rounded text-xs';
const progressPct = mod.progress;
div.innerHTML = `
<div class="flex justify-between mb-1">
<span class="text-cyber-magenta font-bold">${mod.title}</span>
<span class="text-cyber-magentaDim">${mod.duration}</span>
</div>
<div class="w-full bg-cyber-dark border border-cyber-magentaDim h-2 mb-2">
<div class="bg-cyber-magenta h-full transition-all duration-500" style="width: ${progressPct}%"></div>
</div>
<button class="training-start w-full py-1 border border-cyber-magentaDim text-cyber-magentaDim hover:bg-cyber-magenta hover:text-black transition" data-index="${idx}" ${progressPct===100?'disabled':''}>
${progressPct===100?'COMPLETED':'START MODULE'}
</button>
`;
list.appendChild(div);
});
}
function startTraining(index) {
const mod = state.training[index];
if (mod.progress === 100) return;
log(`Training module started: ${mod.title}`);
// Simulate progress over 5 seconds
let interval = setInterval(() => {
mod.progress += 20;
if (mod.progress > 100) mod.progress = 100;
renderTraining();
if (mod.progress === 100) {
clearInterval(interval);
log(`Training completed: ${mod.title}`, 'success');
}
}, 1000);
}
// ========================
// METRICS DECODING
// ========================
function updateMetrics() {
// Active flags
const activeFlagsEl = document.querySelector('.decoding[data-value*=","]');
if (activeFlagsEl) {
const val = (state.flags.length * 100 + Math.floor(Math.random()*50)).toLocaleString();
if (activeFlagsEl.textContent !== val) {
decodeText(activeFlagsEl, val);
}
}
// Drift events
const driftEl = document.querySelector('.decoding[data-value*="12"]');
if (driftEl) {
const val = state.drift.length.toString();
if (driftEl.textContent !== val) {
decodeText(driftEl, val);
}
}
// Rollbacks
const rollbackEl = document.querySelector('.decoding[data-value*="3"]');
if (rollbackEl) {
const val = (Math.random()*5).toFixed(1);
if (rollbackEl.textContent !== val) {
decodeText(rollbackEl, val);
}
}
// Health
const healthEl = document.querySelector('.decoding[data-value*="98"]');
if (healthEl) {
const val = (98 + Math.random() * 1.99).toFixed(1) + '%';
if (healthEl.textContent !== val) {
decodeText(healthEl, val);
}
}
}
// ========================
// EVENT LISTENERS & INIT
// ========================
function initEvents() {
// Navigation buttons (we could show/hide panels, but we already have them all; maybe highlight active)
document.querySelectorAll('.nav-btn').forEach(btn => {
btn.addEventListener('click', () => {
log(`Navigation: ${btn.dataset.target}`);
});
});
// Emergency stop
$('emergency-stop').addEventListener('click', () => {
log('EMERGENCY STOP TRIGGERED: Disabling all global flags', 'alert');
// Visual effect
document.body.classList.add('bg-red-900/20');
setTimeout(() => document.body.classList.remove('bg-red-900/20'), 500);
});
// Runbook execute buttons (delegate)
$('runbook-list').addEventListener('click', (e) => {
if (e.target.classList.contains('runbook-execute')) {
const idx = parseInt(e.target.dataset.index);
executeRunbook(idx);
}
});
// Training start buttons
$('training-list').addEventListener('click', (e) => {
if (e.target.classList.contains('training-start')) {
const idx = parseInt(e.target.dataset.index);
startTraining(idx);
}
});
// Window resize
window.addEventListener('resize', () => {
initGraph();
resizeChart();
});
}
function init() {
log('System initializing...');
initGraph();
renderHealth();
renderDrift();
renderRunbooks();
renderTraining();
resizeChart(); // initial size
animateChart();
initEvents();
log('Feature Flag Audit Service online.');
// Periodic updates
setInterval(tickHealth, 5000);
setInterval(addDriftEvent, 8000);
setInterval(updateMetrics, 2000);
}
// Boot
window.addEventListener('DOMContentLoaded', init);
</script>
</body>
</html>