<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nexus | Data Lineage Explorer</title>
<!-- Fonts: Inter (UI) and JetBrains Mono (Code/Data) -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<!-- Tailwind CSS (CDN) -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
},
colors: {
brand: {
dark: '#050507',
panel: 'rgba(20, 20, 25, 0.6)',
border: 'rgba(255, 255, 255, 0.12)',
accent: '#3b82f6', // Cyber Blue
glow: '#00f2ff',
secondary: '#8b5cf6', // Neon Violet
}
},
boxShadow: {
'glow': '0 0 20px rgba(59, 130, 246, 0.3)',
}
}
}
}
</script>
<!-- GSAP for Animations -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<style>
:root {
--node-bg: rgba(30, 30, 40, 0.7);
--node-border: rgba(255, 255, 255, 0.2);
--line-color: rgba(100, 150, 255, 0.4);
}
body {
background-color: #050507;
color: #e2e8f0;
overflow: hidden;
margin: 0;
font-family: 'Inter', sans-serif;
}
/* WebGL Background Canvas */
#bg-canvas {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
/* Noise Texture Overlay */
.noise-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 0;
opacity: 0.07;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
/* Glassmorphism Panels */
.glass-panel {
background: rgba(10, 10, 12, 0.65);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}
/* Graph SVG Styles */
#graph-svg {
cursor: grab;
}
#graph-svg:active {
cursor: grabbing;
}
.link {
fill: none;
stroke: var(--line-color);
stroke-width: 2;
stroke-linecap: round;
stroke-dasharray: 6 6;
animation: dashMove 2s linear infinite;
transition: stroke 0.3s ease;
}
.link.highlighted {
stroke: rgba(59, 130, 246, 0.9);
stroke-width: 2.5;
filter: drop-shadow(0 0 4px rgba(59, 130, 246, 0.5));
}
.link.dimmed {
opacity: 0.1;
}
.node rect {
fill: var(--node-bg);
stroke: var(--node-border);
stroke-width: 1;
rx: 12;
ry: 12;
transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}
.node:hover rect {
fill: rgba(40, 40, 60, 0.9);
stroke: var(--brand-accent);
filter: drop-shadow(0 0 15px rgba(59, 130, 246, 0.5));
}
.node.active rect {
fill: rgba(30, 40, 70, 0.9);
stroke: var(--brand-accent);
stroke-width: 2;
filter: drop-shadow(0 0 20px rgba(59, 130, 246, 0.8));
}
.node text {
font-family: 'Inter', sans-serif;
font-size: 14px;
fill: white;
pointer-events: none;
font-weight: 500;
}
.node-icon {
opacity: 0.7;
}
@keyframes dashMove {
to { stroke-dashoffset: -12; }
}
/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
/* Utilities */
.text-glow { text-shadow: 0 0 10px rgba(255,255,255,0.5); }
.tag-pill { font-size: 10px; padding: 2px 8px; border-radius: 999px; letter-spacing: 0.5px; text-transform: uppercase; }
</style>
</head>
<body>
<!-- Three.js Background -->
<canvas id="bg-canvas"></canvas>
<!-- Noise Texture -->
<div class="noise-overlay"></div>
<!-- Layout Container -->
<div class="relative w-full h-screen flex z-10 select-none">
<!-- Top Bar -->
<header class="absolute top-0 left-0 right-0 h-16 flex items-center justify-between px-6 pointer-events-none z-50">
<div class="flex items-center gap-3 pointer-events-auto">
<div class="w-8 h-8 rounded-lg bg-gradient-to-br from-brand-accent to-brand-secondary flex items-center justify-center shadow-glow">
<svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"></path></svg>
</div>
<h1 class="text-xl font-bold tracking-tight text-white">Nexus <span class="text-gray-500 text-sm font-normal">| Lineage Explorer</span></h1>
</div>
<div class="flex items-center gap-4 pointer-events-auto">
<!-- Magnetic Search -->
<div class="magnetic-wrapper relative">
<div class="flex items-center bg-white/5 border border-white/10 rounded-full pl-4 pr-2 py-1.5 transition-all duration-300 hover:bg-white/10 hover:border-white/20 backdrop-blur-md">
<svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>
<input type="text" placeholder="Search assets..." class="bg-transparent border-none outline-none text-sm text-white ml-2 w-48 placeholder-gray-500 font-mono">
</div>
</div>
<button class="magnetic-btn px-4 py-2 bg-brand-accent/90 hover:bg-brand-accent text-white text-sm font-semibold rounded-lg shadow-lg shadow-brand-accent/20 transition-all duration-300 transform hover:scale-105">
Refresh
</button>
</div>
</header>
<!-- Sidebar (Right) -->
<aside id="sidebar" class="absolute right-0 top-16 bottom-0 w-[380px] glass-panel border-l border-white/10 flex flex-col transform translate-x-full transition-transform duration-500 ease-[cubic-bezier(0.16,1,0.3,1)] z-40">
<!-- Sidebar Header -->
<div class="p-6 border-b border-white/5 bg-black/20">
<div class="flex justify-between items-start mb-4">
<div class="flex items-center gap-3">
<div id="sidebar-icon" class="w-10 h-10 rounded-lg bg-slate-800 border border-white/10 flex items-center justify-center text-brand-accent">
<!-- Icon injected by JS -->
</div>
<div>
<h2 id="sidebar-title" class="text-lg font-bold text-white leading-tight">Table Name</h2>
<span class="text-xs text-gray-400 font-mono">asset.id_12345</span>
</div>
</div>
<div class="h-8 w-8 rounded-full bg-gradient-to-br from-emerald-400 to-teal-600 flex items-center justify-center text-xs font-bold text-black shadow-sm cursor-pointer">
JD
</div>
</div>
<div class="grid grid-cols-2 gap-2">
<div class="bg-white/5 rounded p-2 border border-white/5">
<div class="text-[10px] text-gray-500 uppercase tracking-wider">Upstream</div>
<div class="text-sm font-semibold text-white mt-0.5" id="upstream-count">0</div>
</div>
<div class="bg-white/5 rounded p-2 border border-white/5">
<div class="text-[10px] text-gray-500 uppercase tracking-wider">Downstream</div>
<div class="text-sm font-semibold text-white mt-0.5" id="downstream-count">0</div>
</div>
</div>
</div>
<!-- Sidebar Content -->
<div class="flex-1 overflow-y-auto p-6 space-y-6">
<!-- Description -->
<section>
<h3 class="text-xs font-bold text-gray-400 uppercase tracking-widest mb-2">Description</h3>
<p class="text-sm text-gray-300 leading-relaxed" id="sidebar-desc">
This node represents the aggregated view of user transactional data, joined with demographic profiles.
</p>
</section>
<!-- Column Impact -->
<section>
<div class="flex justify-between items-center mb-3">
<h3 class="text-xs font-bold text-gray-400 uppercase tracking-widest">Column Impact</h3>
<span class="text-[10px] text-brand-accent font-mono">v2.4.0</span>
</div>
<div class="bg-black/20 rounded-lg border border-white/5 overflow-hidden">
<table class="w-full text-left border-collapse">
<thead>
<tr class="text-[10px] text-gray-500 border-b border-white/5 bg-white/5">
<th class="p-2 font-medium">Name</th>
<th class="p-2 font-medium">Type</th>
<th class="p-2 font-medium text-center">Sensitivity</th>
</tr>
</thead>
<tbody id="column-list" class="text-sm">
<!-- Rows injected by JS -->
</tbody>
</table>
</div>
</section>
</div>
</aside>
<!-- Graph Canvas Area -->
<main id="graph-container" class="w-full h-full cursor-grab active:cursor-grabbing relative z-0 overflow-hidden">
<!-- The SVG is populated by JS -->
<svg id="graph-svg" class="absolute top-0 left-0 w-full h-full" style="touch-action: none;">
<g id="graph-viewport">
<g id="edges-layer"></g>
<g id="nodes-layer"></g>
</g>
</svg>
<!-- Empty State / Tooltip hint -->
<div id="graph-hint" class="absolute bottom-8 left-1/2 transform -translate-x-1/2 px-4 py-2 rounded-full bg-black/40 backdrop-blur-md border border-white/5 text-xs text-gray-400 pointer-events-none opacity-70">
Scroll to zoom • Drag to pan • Click nodes for details
</div>
</main>
</div>
<!-- Scripts -->
<script>
/**
* 1. THREE.JS BACKGROUND (Shader)
* Creates a flowing, nebula-like plasma background to give depth.
*/
const initBackground = () => {
const canvas = document.getElementById('bg-canvas');
const renderer = new THREE.WebGLRenderer({ canvas, alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
const scene = new THREE.Scene();
const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
const geometry = new THREE.PlaneGeometry(2, 2);
// Simple GLSL shader for organic cloud movement
const fragmentShader = `
uniform float uTime;
uniform vec2 uResolution;
vec3 palette( float t ) {
vec3 a = vec3(0.5, 0.5, 0.5);
vec3 b = vec3(0.5, 0.5, 0.5);
vec3 c = vec3(1.0, 1.0, 1.0);
vec3 d = vec3(0.263,0.416,0.557);
return a + b*cos( 6.28318*(c*t+d) );
}
void main() {
vec2 uv = (gl_FragCoord.xy * 2.0 - uResolution.xy) / uResolution.y;
vec2 uv0 = uv;
vec3 finalColor = vec3(0.0);
for (float i = 0.0; i < 3.0; i++) {
uv = fract(uv * 1.5) - 0.5;
float d = length(uv) * exp(-length(uv0));
vec3 col = palette(length(uv0) + i*.4 + uTime*.4);
d = sin(d*8. + uTime)/8.;
d = abs(d);
d = pow(0.01 / d, 1.2);
finalColor += col * d;
}
// Dark tint to keep it subtle behind UI
gl_FragColor = vec4(finalColor, 0.6);
}
`;
const material = new THREE.ShaderMaterial({
uniforms: {
uTime: { value: 0 },
uResolution: { value: new THREE.Vector2(window.innerWidth, window.innerHeight) }
},
vertexShader: `
void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader
});
const mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
const animate = (time) => {
material.uniforms.uTime.value = time * 0.001;
renderer.render(scene, camera);
requestAnimationFrame(animate);
};
animate();
window.addEventListener('resize', () => {
renderer.setSize(window.innerWidth, window.innerHeight);
material.uniforms.uResolution.value.set(window.innerWidth, window.innerHeight);
});
};
/**
* 2. DATA MODEL & GENERATION
*/
const generateData = () => {
const types = ['int', 'varchar', 'timestamp', 'decimal', 'boolean'];
const sensitivities = ['Public', 'Internal', 'Sensitive', 'PII'];
// Mock Nodes
const nodeConfigs = [
{ id: 'src_sales', label: 'Stg_Sales_Raw', type: 'source', owner: 'ETL Team' },
{ id: 'src_customers', label: 'Stg_Customers_API', type: 'source', owner: 'Data Eng' },
{ id: 'dim_customer', label: 'Dim_Customer', type: 'dimension', owner: 'Analytics' },
{ id: 'fact_sales', label: 'Fact_Sales', type: 'fact', owner: 'Finance' },
{ id: 'agg_daily', label: 'Agg_Daily_Revenue', type: 'aggregation', owner: 'BI Team' },
{ id: 'report_dash', label: 'Master_Report_DB', type: 'report', owner: 'CEO Office' }
];
const nodes = nodeConfigs.map((n, i) => {
// Generate random columns based on type heuristics
const cols = [];
const count = 4 + Math.floor(Math.random() * 4);
for(let j=0; j<count; j++) {
const type = types[Math.floor(Math.random() * types.length)];
const isPII = type === 'varchar' && Math.random() > 0.7;
const sensitivity = isPII ? 'PII' : sensitivities[Math.floor(Math.random() * (sensitivities.length - 1))];
cols.push({
name: `${n.id}_col_${j+1}`,
type: type,
sensitivity: sensitivity
});
}
return {
...n,
columns: cols,
description: `Core data entity for ${n.label}. Last updated: 2h ago. Storage: Iceberg/Parquet.`
};
});
// Mock Edges (DAG flow)
const edges = [
{ source: 'src_sales', target: 'fact_sales' },
{ source: 'src_customers', target: 'dim_customer' },
{ source: 'fact_sales', target: 'agg_daily' },
{ source: 'dim_customer', target: 'fact_sales' },
{ source: 'dim_customer', target: 'report_dash' },
{ source: 'fact_sales', target: 'report_dash' },
{ source: 'agg_daily', target: 'report_dash' }
];
return { nodes, edges };
};
const data = generateData();
/**
* 3. GRAPH LAYOUT ENGINE
* Simple hierarchical layout (Rank-based) for DAG.
*/
const calculateLayout = () => {
const nodeMap = new Map(data.nodes.map(n => [n.id, n]));
data.nodes.forEach(n => { n.rank = 0; n.children = []; n.parents = []; });
// Build graph connections
data.edges.forEach(e => {
if(nodeMap.has(e.source) && nodeMap.has(e.target)) {
nodeMap.get(e.source).children.push(e.target);
nodeMap.get(e.target).parents.push(e.source);
}
});
// Assign approximate ranks (Longest Path from source)
const sources = data.nodes.filter(n => n.parents.length === 0);
const visited = new Set();
const dfsAssignRank = (nodeId, currentRank) => {
if(visited.has(nodeId)) return;
visited.add(nodeId);
const node = nodeMap.get(nodeId);
node.rank = Math.max(node.rank, currentRank);
node.children.forEach(child => dfsAssignRank(child, currentRank + 1));
};
sources.forEach(s => dfsAssignRank(s.id, 0));
// Handle disconnected components (hack: set min rank to max of parents)
// (Simplified for this demo)
// Group nodes by rank
const ranks = {};
data.nodes.forEach(n => {
if(!ranks[n.rank]) ranks[n.rank] = [];
ranks[n.rank].push(n);
});
// Sort ranks
const rankKeys = Object.keys(ranks).map(Number).sort((a,b)=>a-b);
// Assign X coordinates: center nodes in each rank
const spacingX = 180;
const spacingY = 120;
rankKeys.forEach((rank, idx) => {
const levelNodes = ranks[rank];
const totalWidth = (levelNodes.length - 1) * spacingX;
const startX = -totalWidth / 2;
levelNodes.forEach((node, j) => {
node.x = startX + j * spacingX;
node.y = rank * spacingY - (rankKeys.length * spacingY) / 2; // Center vertically
});
});
};
calculateLayout();
/**
* 4. RENDERING (SVG)
*/
const svgNodes = document.getElementById('nodes-layer');
const svgEdges = document.getElementById('edges-layer');
const graphViewport = document.getElementById('graph-viewport');
// Render Edges first (so they are behind nodes)
function renderGraph() {
// Clear
svgNodes.innerHTML = '';
svgEdges.innerHTML = '';
// Draw Edges
data.edges.forEach(edge => {
const source = data.nodes.find(n => n.id === edge.source);
const target = data.nodes.find(n => n.id === edge.target);
if(!source || !target) return;
// Cubic Bezier for smooth hierarchical flow
const startX = source.x;
const startY = source.y;
const endX = target.x;
const endY = target.y;
// Control points depend on direction (vertical hierarchy)
const cp1x = startX;
const cp1y = startY + (endY > startY ? 60 : -60);
const cp2x = endX;
const cp2y = endY + (endY < startY ? 60 : -60);
const pathData = `M ${startX} ${startY} C ${cp1x} ${cp1y}, ${cp2x} ${cp2y}, ${endX} ${endY}`;
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
path.setAttribute("d", pathData);
path.setAttribute("class", "link");
path.setAttribute("id", `edge-${source.id}-${target.id}`);
path.dataset.source = source.id;
path.dataset.target = target.id;
svgEdges.appendChild(path);
});
// Draw Nodes
// Icon selection based on type
const getIcon = (type) => {
const icons = {
source: '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />',
dimension: '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />',
fact: '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z" />',
aggregation: '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />',
report: '<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" 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" />'
};
return icons[type] || icons.source;
};
data.nodes.forEach(node => {
const g = document.createElementNS("http://www.w3.org/2000/svg", "g");
g.setAttribute("class", "node");
g.setAttribute("transform", `translate(${node.x}, ${node.y})`);
g.dataset.id = node.id;
// Node Box (Width ~120, Height ~50)
const width = 140;
const height = 52;
// Rect
const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
rect.setAttribute("x", -width/2);
rect.setAttribute("y", -height/2);
rect.setAttribute("width", width);
rect.setAttribute("height", height);
// Icon (SVG inside)
const iconBox = 20;
const iconGroup = document.createElementNS("http://www.w3.org/2000/svg", "g");
iconGroup.setAttribute("transform", `translate(${-width/2 + 10}, ${-height/2 + 10})`);
iconGroup.innerHTML = `<svg width="${iconBox}" height="${iconBox}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" class="text-brand-accent opacity-80">${getIcon(node.type)}</svg>`;
// Label
const text = document.createElementNS("http://www.w3.org/2000/svg", "text");
text.setAttribute("x", 2);
text.setAttribute("y", 2);
text.setAttribute("text-anchor", "middle");
text.setAttribute("dominant-baseline", "middle");
// Truncate label if needed
text.textContent = node.label;
// Approx width centering with JS, but simpler: anchor middle and shift x slightly right of icon
text.setAttribute("x", 20);
g.appendChild(rect);
g.appendChild(iconGroup);
g.appendChild(text);
// Events
g.addEventListener('click', (e) => {
e.stopPropagation(); // prevent drag start
selectNode(node);
});
svgNodes.appendChild(g);
});
}
renderGraph();
/**
* 5. INTERACTION STATE & ZOOM/PAN
*/
let state = {
scale: 1,
panning: false,
pointX: 0,
pointY: 0,
startX: 0,
startY: 0,
selectedNodeId: null
};
const graphContainer = document.getElementById('graph-container');
const graphViewportEl = document.getElementById('graph-viewport');
function updateTransform() {
graphViewportEl.setAttribute('transform', `translate(${state.pointX}, ${state.pointY}) scale(${state.scale})`);
}
// Mouse Wheel Zoom
graphContainer.addEventListener('wheel', (e) => {
e.preventDefault();
const zoomSensitivity = 0.001;
const newScale = Math.max(0.2, Math.min(3, state.scale - e.deltaY * zoomSensitivity));
// Zoom towards mouse pointer logic (simplified to center for brevity, could be enhanced)
// For this demo, zoom to center of viewport
state.scale = newScale;
updateTransform();
}, { passive: false });
// Panning
graphContainer.addEventListener('mousedown', (e) => {
// Check if target is UI element
if(e.target.closest('.node')) return;
state.panning = true;
state.startX = e.clientX - state.pointX;
state.startY = e.clientY - state.pointY;
graphContainer.style.cursor = 'grabbing';
});
window.addEventListener('mousemove', (e) => {
if (state.panning) {
state.pointX = e.clientX - state.startX;
state.pointY = e.clientY - state.startY;
updateTransform();
}
});
window.addEventListener('mouseup', () => {
state.panning = false;
graphContainer.style.cursor = 'grab';
});
/**
* 6. SIDEBAR LOGIC & MICRO-INTERACTIONS
*/
const sidebar = document.getElementById('sidebar');
const columnList = document.getElementById('column-list');
function selectNode(node) {
state.selectedNodeId = node.id;
// Highlight Logic
document.querySelectorAll('.node').forEach(n => n.classList.remove('active'));
document.querySelectorAll('.link').forEach(l => l.classList.remove('highlighted'));
const activeNodeEl = document.querySelector(`.node[data-id="${node.id}"]`);
if(activeNodeEl) activeNodeEl.classList.add('active');
// Highlight connected edges
data.edges.forEach(edge => {
const edgeEl = document.getElementById(`edge-${edge.source}-${edge.target}`);
if(edge.source === node.id || edge.target === node.id) {
edgeEl.classList.add('highlighted');
edgeEl.style.opacity = 1;
} else {
edgeEl.classList.add('dimmed');
}
});
// Populate Sidebar
populateSidebar(node);
// Show sidebar with animation
sidebar.style.transform = 'translateX(0)';
}
// Close sidebar when clicking empty space
graphContainer.addEventListener('click', (e) => {
if (e.target.classList.contains('graph-container') || e.target.id === 'graph-svg') {
state.selectedNodeId = null;
sidebar.style.transform = 'translateX(100%)';
document.querySelectorAll('.node').forEach(n => n.classList.remove('active'));
document.querySelectorAll('.link').forEach(l => {
l.classList.remove('highlighted', 'dimmed');
l.style.opacity = '';
});
}
});
function populateSidebar(node) {
document.getElementById('sidebar-title').textContent = node.label;
document.getElementById('sidebar-desc').textContent = node.description;
document.getElementById('upstream-count').textContent = node.parents.length;
document.getElementById('downstream-count').textContent = node.children.length;
// Icon mapping
const icons = {
source: 'M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4',
dimension: 'M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10',
fact: 'M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z',
aggregation: 'M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 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',
report: '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'
};
// Simpler icon for sidebar
const iconSvg = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="text-brand-accent">${icons[node.type] || icons.source}</svg>`;
document.getElementById('sidebar-icon').innerHTML = iconSvg;
// Populate Columns
columnList.innerHTML = '';
node.columns.forEach(col => {
let tagColor = 'bg-gray-500';
if(col.sensitivity === 'PII') tagColor = 'bg-red-500/20 text-red-300 border border-red-500/30';
else if(col.sensitivity === 'Sensitive') tagColor = 'bg-amber-500/20 text-amber-300 border border-amber-500/30';
else if(col.sensitivity === 'Public') tagColor = 'bg-emerald-500/10 text-emerald-300 border border-emerald-500/20';
else tagColor = 'bg-blue-500/10 text-blue-300 border border-blue-500/20';
const tr = document.createElement('tr');
tr.className = 'border-b border-white/5 last:border-0 hover:bg-white/5 transition-colors group';
tr.innerHTML = `
<td class="p-2 font-medium text-gray-200 group-hover:text-white font-mono text-xs">
<span class="opacity-50 mr-1">#</span>${col.name}
</td>
<td class="p-2 text-gray-400 text-xs uppercase-mono">${col.type}</td>
<td class="p-2 text-center">
<span class="tag-pill ${tagColor}">${col.sensitivity}</span>
</td>
`;
columnList.appendChild(tr);
});
// Animate Sidebar content refresh slightly
const content = sidebar.querySelector('div.flex-1');
gsap.fromTo(content, { opacity: 0.5, x: 10 }, { opacity: 1, x: 0, duration: 0.3 });
}
/**
* 7. MAGNETIC BUTTON EFFECT
*/
function applyMagneticEffect(elem, pull = 15) {
elem.addEventListener('mousemove', (e) => {
const rect = elem.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width / 2;
const y = e.clientY - rect.top - rect.height / 2;
// Magnetic pull: move element towards mouse slightly
gsap.to(elem, {
x: (x / rect.width) * pull,
y: (y / rect.height) * pull,
duration: 0.3,
ease: 'power2.out'
});
});
elem.addEventListener('mouseleave', () => {
gsap.to(elem, { x: 0, y: 0, duration: 0.5, ease: 'elastic.out(1, 0.3)' });
});
}
document.querySelectorAll('.magnetic-btn, .magnetic-wrapper > div').forEach(el => applyMagneticEffect(el));
/**
* 8. INITIALIZATION
*/
window.onload = () => {
initBackground();
// Entry animations
gsap.from('header', { y: -50, opacity: 0, duration: 1, ease: 'power3.out' });
gsap.from('#graph-container', { opacity: 0, duration: 1.5, delay: 0.2, ease: 'power2.out' });
// Animate graph nodes appearing (staggered)
gsap.fromTo('.node',
{ scale: 0, opacity: 0 },
{ scale: 1, opacity: 1, duration: 0.6, stagger: 0.05, transformOrigin: 'center center', delay: 0.5, ease: 'back.out(1.7)' }
);
};
</script>
</body>
</html>