Here's a thinking process that leads to the suggested solution:
-
Analyze the Request:
-
Goal: Build a "multi-cloud data residency orchestrator" that enforces policy-driven placement, replication, encryption, with proof artifacts.
-
Context: I am a top-tier creative front-end engineer and UI/UX designer with 10 years of experience. I have strong opinions about aesthetics (Swiss, Minimalism, depth) and technical execution (Tailwind, GSAP, Three.js optional but good for flair).
-
Specific Requirement: "Single HTML file", "no external dependencies that require build steps" (mostly), "dynamic interactions", "polished UI".
-
Interpretation: This sounds like a dashboard or control panel for a complex backend system. It needs to visualize data flow, policies, encryption status, and multi-cloud infrastructure (AWS, GCP, Azure, maybe others).
-
Core Features to Simulate (since it's a frontend demo):
- Policy Management (Create/Edit rules like "Data must reside in EU", "Encryption: AES-256").
- Cloud Region Map/Visualization (Where data is stored).
- Data Flow/Replication status.
- Proof Artifacts (Audit logs, compliance certificates).
- Dashboard metrics (Compliance score, active regions, encryption coverage).
-
Design Concept (Swiss + Cyberpunk/Orchestration):
- Theme: Dark mode (Deep blue/black background) with high contrast neon accents (Cyan, Magenta, Electric Blue). High-end "Future of Enterprise" look.
- Typography: Inter (clean sans) for UI, maybe a monospaced font (JetBrains Mono) for logs/codes/data.
- Layout: Bento Grid style. Clean, modular.
- Atmosphere: Use subtle mesh gradients, glassmorphism (blur), and particle effects (Three.js or canvas) to imply "network" and "clouds".
-
Technical Stack Selection:
- HTML5.
- CSS: Tailwind CSS (via CDN) + Custom CSS for animations/glassmorphism.
- JS: Vanilla ES6+.
- Visuals: Three.js (for a global network map/globe visualization in the background), GSAP (for smooth scrolling animations), Lenis (for smooth scroll). Actually, to keep it simple and robust in one file, I'll use Three.js for a 3D globe with connection points representing cloud regions. This fits the "multi-cloud" aspect perfectly.
- Icons: FontAwesome (CDN) or Heroicons (SVG strings). I'll use SVG strings to avoid dependency issues.
-
Step-by-Step Implementation Plan:
- Setup: HTML skeleton, import Tailwind, import Three.js, FontAwesome.
- Styling (Custom): Custom scrollbars, glass classes, noise texture overlay, CSS variables for colors.
- The 3D Background: A rotating globe with "points" (cloud regions). Interactive (drag to rotate). This creates the "wow" factor.
- UI Overlay:
- Sidebar: Navigation (Dashboard, Policies, Regions, Proofs, Settings).
- Main Content Area:
- Header: Title, User profile, Notifications.
- Top Cards: Compliance Score, Active Policies, Encrypted Data Volume, Last Sync.
- Main Grid:
- Policy Engine: A form to add/edit policies. List of active policies.
- Live Map/Visualizer: A 2D canvas/DOM overlay over the 3D globe (or separate section) showing data flows. Let's integrate UI panels over the 3D background.
- Audit/Proof Logs: A scrolling terminal-like window showing actions and cryptographic signatures.
- Interactions (Logic):
- State Management: Simple object to hold policies and log entries.
- Policy Creation: Inputs for region, encryption type, retention. "Deploy" button adds to state and updates UI.
- Simulation: A
setInterval to simulate incoming data requests and check them against policies. If a violation occurs, log it. If OK, log success and generate "proof artifact" (a hash string).
- Proof Artifacts: Clicking a log entry should show a modal with details: "Data ID", "Timestamp", "Policy Applied", "Encryption Key Hash", "Region", "Signature".
-
Refining the Aesthetics (The "Creative" Touch):
- Glassmorphism:
backdrop-filter: blur(12px), background: rgba(255,255,255,0.05).
- Borders: Very thin, low opacity white.
- Typography: Huge numbers for metrics. Letter spacing uppercase for labels.
- Animations: Elements slide in using GSAP. The globe rotates slowly. Logs fade in.
- Noise: A base64 noise image overlaid with
mix-blend-mode: overlay and low opacity to give it texture.
-
Drafting the Code Structure (Mental or Scratchpad):
<html>
<head>
<script src="tailwindcss"></script>
<script src="three.js"></script>
<script src="gsap"></script>
<style>
/* Noise texture */
/* Custom scrollbar */
/* Font family */
</style>
</head>
<body class="bg-[#050505] text-white overflow-hidden">
<!-- Canvas for Three.js background -->
<canvas id="globe-canvas"></canvas>
<!-- Noise Overlay -->
<div class="noise-overlay"></div>
<!-- UI Container -->
<div class="relative z-10 flex h-screen">
<!-- Sidebar -->
<aside class="w-64 glass-panel">...</aside>
<!-- Main -->
<main class="flex-1 relative overflow-hidden">
<!-- Header -->
<header>...</header>
<!-- Dashboard Grid (Absolute positioning to float over 3D) -->
<div class="absolute inset-0 p-6 pointer-events-none">
<div class="grid grid-cols-4 gap-6 pointer-events-auto">
<!-- Metrics -->
<!-- Policies -->
<!-- Logs -->
</div>
</div>
</main>
</div>
<!-- Proof Modal (Hidden by default) -->
<div id="proof-modal" class="fixed inset-0 z-50 ...">...</div>
<script>
// Three.js setup
// Data simulation logic
// UI updates
// GSAP animations
</script>
</body>
</html>
-
Detailed Logic Implementation:
- Three.js Globe: Create sphere, point array representing cities (lat/lon to Vector3). Connect with lines if "replication" active. Needs to look techy. Wireframe sphere + particles.
- Policy Rules: Simple array of objects.
{ id, name, region, encryption: 'AES-256', retention: 365, active: true }.
- Incoming Data Simulation: Every few seconds, generate a random data event (e.g., "Patient Record Upload"). Check against policies.
- Logic: If data.origin matches a region in active policies, mark "Compliant", else "Non-Compliant".
- Generate a "Proof" object with a fake ZKP (Zero Knowledge Proof) or just SHA3 hash.
- Log Display: A scrollable div. Prepend new log entries.
- Proof Modal: When clicking a log, show the extracted proof details with a "Copy" button.
-
Writing the Code (Iterative refinement during drafting):
- Tailwind Config: Since I'm using CDN, I need to configure the colors inside the script tag to ensure consistency (e.g.,
bg-primary, accent-cyan).
- Icons: Use generic SVG paths for "Shield", "Globe", "Lock", "File".
- Handling Resize: Three.js must resize correctly.
- Performance: Don't create too many Three.js objects.
-
Addressing "Proof Artifacts":
- The prompt asks for "proof artifacts". In a real system, this might be a Zero-Knowledge Proof or a Merkle proof. I will simulate this by generating a cryptographic hash string and a "Compliance Certificate" lookalike (styled nicely) in the modal.
-
Review against Constraints:
- Single file? Yes.
- No build step? Yes.
- Three.js? Yes, included via CDN.
- GSAP? Yes, via CDN.
- Tailwind? Yes, via CDN.
- Language: English (user asked in English).
- No alerts? Use custom modals/toasts.
-
Final Polish:
- Add a "Scanner" effect on the globe (a moving light ring).
- Ensure the policy form actually creates a policy that appears in the list.
- Ensure the logs show both policy deployment and data flow checks.
- Add a "Toast" notification when a policy is saved.
(Self-Correction during coding): Initially, I might make the UI too complex. I should stick to the "Bento Grid" idea: use CSS Grid to place panels cleanly over the background. The 3D globe should be subtle (lower opacity or blurred) so text remains readable. I will set the canvas position: fixed behind everything, but dim it with a dark overlay to make the text pop.
Let's refine the UI structure:
- Left Panel: Navigation (Vertical).
- Top Bar: Title "Orchestrator", Status.
- Center: Actually, the UI should be floating over the globe. The globe is the "Reality". The UI is the "Control".
- Windows: I'll use absolute positioning relative to the main container for the main panels (Metrics, Policy Engine, Logs) to avoid a boring static grid, and let them "hover" with glass effect. This fits the creative brief better.
Let's execute.
Note on Language: The user asked in English ("Build a multi-cloud data residency orchestrator..."), so the output must be in English.
Technical Check:
- Three.js CDN:
https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js.
- Tailwind CDN:
https://cdn.tailwindcss.com.
- GSAP CDN:
https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js.
- Font: Google Fonts (Inter, JetBrains Mono).
Let's build.
Below is a complete, single-file HTML solution. It integrates Three.js for a 3D global network visualization, Tailwind CSS for styling, and GSAP for smooth animations.
This "Multi-Cloud Data Residency Orchestrator" allows you to:
- Manage Policies: Define where data must reside and the encryption standard.
- Visualize Infrastructure: A 3D globe showing active cloud regions (points) and replication links.
- Simulate Data Flow: The system generates fake data objects and checks them against your policies in real-time.
- View Proof Artifacts: Click on a log entry to reveal a cryptographic compliance proof (hash, signature, applied policy).
The Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nexus: Multi-Cloud Residency Orchestrator</title>
<!-- Fonts -->
<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 -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
},
colors: {
brand: {
dark: '#030508', // Deep void
panel: 'rgba(10, 15, 25, 0.65)',
border: 'rgba(255, 255, 255, 0.08)',
accent: '#00f0ff', // Cyber Blue
accent2: '#7000ff', // Deep Purple
success: '#00ff9d',
warning: '#ffb800',
danger: '#ff2a2a',
}
},
backdropBlur: {
xs: '2px',
}
}
}
}
</script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<!-- GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #030508;
color: #ffffff;
}
/* Noise Texture Overlay */
.noise-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 1;
opacity: 0.05;
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");
}
/* Glass Morphism */
.glass-panel {
background: rgba(16, 24, 40, 0.6);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}
.glass-panel-light {
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.05);
}
/* Scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: transparent;
}
::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.1);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.2);
}
/* Utility */
.text-glow {
text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}
.border-glow {
box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.3);
}
#canvas-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.pointer-events-auto {
pointer-events: auto;
}
</style>
</head>
<body>
<!-- 3D Background -->
<div id="canvas-container"></div>
<div class="noise-overlay"></div>
<!-- UI Layer -->
<div class="relative z-10 flex h-screen w-full p-4 md:p-6 gap-6 pointer-events-none">
<!-- Sidebar -->
<nav class="w-20 md:w-64 flex flex-col gap-4 pointer-events-auto glass-panel rounded-2xl p-4 transition-all duration-500">
<div class="flex items-center gap-3 mb-2">
<div class="w-8 h-8 rounded bg-brand-accent flex items-center justify-center shadow-[0_0_15px_rgba(0,240,255,0.4)]">
<svg class="w-5 h-5 text-black" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"></path></svg>
</div>
<span class="hidden md:block font-bold text-lg tracking-wider text-white">NEXUS</span>
</div>
<ul class="flex flex-col gap-2 flex-1">
<li>
<button class="nav-btn w-full text-left px-3 py-2 rounded-lg flex items-center gap-3 text-brand-accent transition-all hover:bg-white/10 active" data-target="dashboard">
<svg class="w-5 h-5" 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="hidden md:block">Dashboard</span>
</button>
</li>
<li>
<button class="nav-btn w-full text-left px-3 py-2 rounded-lg flex items-center gap-3 text-gray-400 hover:text-white transition-all hover:bg-white/5" data-target="policies">
<svg class="w-5 h-5" 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="hidden md:block">Policy Engine</span>
</button>
</li>
<li>
<button class="nav-btn w-full text-left px-3 py-2 rounded-lg flex items-center gap-3 text-gray-400 hover:text-white transition-all hover:bg-white/5" data-target="proofs">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
<span class="hidden md:block">Audit & Proofs</span>
</button>
</li>
</ul>
<div class="hidden md:block text-[10px] text-gray-500 font-mono uppercase tracking-widest text-center">
v2.4.0-stable
</div>
</nav>
<!-- Main Content -->
<main class="flex-1 flex flex-col pointer-events-none">
<!-- Top Bar (floating) -->
<header class="h-16 glass-panel rounded-2xl mb-6 flex items-center justify-between px-6 pointer-events-auto shrink-0">
<div>
<h1 class="text-xl font-light tracking-tight text-white">Multi-Cloud Orchestrator</h1>
<p class="text-xs text-gray-400 font-mono">Secured Identity: <span class="text-brand-accent">0x4F...A2B</span></p>
</div>
<div class="flex items-center gap-4">
<div class="flex items-center gap-2 px-3 py-1 bg-green-900/30 border border-green-500/30 rounded-full">
<span class="w-2 h-2 rounded-full bg-green-500 animate-pulse"></span>
<span class="text-xs text-green-400 font-mono">SYSTEM HEALTH: 100%</span>
</div>
<button id="simulate-btn" class="bg-brand-accent/10 text-brand-accent border border-brand-accent/30 px-4 py-1 rounded-lg text-sm font-medium hover:bg-brand-accent/20 hover:border-brand-accent transition-all">
Force Data Check
</button>
</div>
</header>
<!-- Grid Layout -->
<div class="grid grid-cols-12 grid-rows-6 gap-6 flex-1 pointer-events-auto">
<!-- Metrics Panel (Top Left) -->
<section class="col-span-12 md:col-span-4 row-span-2 glass-panel rounded-2xl p-6 flex flex-col justify-between normalize-pointer">
<div class="flex items-center justify-between mb-4">
<h3 class="text-sm font-bold text-gray-300 uppercase tracking-wider">Residency Status</h3>
<svg class="w-5 h-5 text-brand-accent opacity-70" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7h8m0 0v8m0-8l-8 8-4-4-6 6"></path></svg>
</div>
<div class="grid grid-cols-2 gap-4">
<div class="p-4 rounded-xl bg-white/5 border border-white/5 flex flex-col">
<span class="text-xs text-gray-400 mb-1">Compliance</span>
<span id="score-display" class="text-3xl font-mono font-bold text-green-400">100%</span>
</div>
<div class="p-4 rounded-xl bg-white/5 border border-white/5 flex flex-col">
<span class="text-xs text-gray-400 mb-1">Encrypted</span>
<span class="text-3xl font-mono font-bold text-brand-accent">Top Secret</span>
<span class="text-[10px] text-gray-500">AES-256 / RSA-4096</span>
</div>
</div>
<div class="mt-4 w-full bg-gray-800 h-1.5 rounded-full overflow-hidden">
<div id="compliance-bar" class="h-full bg-gradient-to-r from-brand-accent to-green-400 w-[100%] transition-all duration-1000 ease-out"></div>
</div>
</section>
<!-- Policy Engine (Middle Left) -->
<section class="col-span-12 md:col-span-4 row-span-4 glass-panel rounded-2xl p-6 flex flex-col normalize-pointer">
<div class="flex items-center justify-between mb-4">
<h3 class="text-sm font-bold text-white uppercase tracking-wider">Active Policies</h3>
<button id="add-policy-btn" class="text-xs bg-white/10 hover:bg-white/20 px-2 py-1 rounded transition-colors">
+ Create New
</button>
</div>
<!-- Policy List -->
<div id="policy-list" class="flex-1 overflow-y-auto space-y-3 pr-2">
<!-- Populated via JS -->
</div>
<!-- Policy Form (Hidden by default) -->
<div id="policy-form" class="hidden border-t border-white/10 pt-4 mt-4 space-y-3 animate-fade-in">
<input type="text" id="policy-name" placeholder="Policy Name (e.g. GDPR-EU)" class="w-full bg-black/30 border border-white/20 rounded p-2 text-sm text-white focus:border-brand-accent focus:ring-1 focus:ring-brand-accent outline-none transition-all">
<div class="grid grid-cols-2 gap-3">
<select id="policy-region" class="bg-black/30 border border-white/20 rounded p-2 text-sm text-white outline-none">
<option value="EU">Europe (EU)</option>
<option value="US">United States (US)</option>
<option value="APAC">Asia Pacific (APAC)</option>
<option value="SA">South America (SA)</option>
</select>
<select id="policy-enc" class="bg-black/30 border border-white/20 rounded p-2 text-sm text-white outline-none">
<option value="AES-256">AES-256</option>
<option value="AES-128">AES-128</option>
<option value="ChaCha20">ChaCha20</option>
</select>
</div>
<div class="flex gap-2">
<button id="save-policy" class="flex-1 bg-brand-accent text-black font-bold text-xs py-2 rounded hover:bg-white transition-colors">DEPLOY POLICY</button>
<button id="cancel-policy" class="px-4 bg-white/5 border border-white/10 rounded text-white text-xs hover:bg-white/10">Cancel</button>
</div>
</div>
</section>
<!-- Auditing/Logs (Bottom Right) -->
<section class="col-span-12 md:col-span-4 row-span-2 row-start-2 glass-panel rounded-2xl p-6 flex flex-col normalize-pointer">
<div class="flex items-center justify-between mb-4">
<h3 class="text-sm font-bold text-white uppercase tracking-wider">Live Audit Artifacts</h3>
<span class="text-[10px] font-mono text-brand-accent border border-brand-accent/30 px-1 rounded">ZK-PROOF MODE</span>
</div>
<div id="log-container" class="flex-1 overflow-hidden font-mono text-xs space-y-2 relative">
<!-- Log entries appear here -->
<div class="absolute inset-0 bg-gradient-to-t from-[#0b1019] to-transparent pointer-events-none"></div>
</div>
</section>
<!-- Global Stats / Map Text Overlay (Transparent) -->
<div class="absolute bottom-8 right-8 pointer-events-none hidden md:block">
<div class="text-right">
<h2 class="text-5xl font-bold text-white/5 select-none">REALTIME</h2>
<h2 class="text-5xl font-bold text-white/5 select-none">COMPLIANCE</h2>
</div>
</div>
</div>
</main>
</div>
<!-- Proof Artifact Modal -->
<div id="proof-modal" class="fixed inset-0 z-[100] flex items-center justify-center pointer-events-none opacity-0 transition-opacity duration-300">
<div class="absolute inset-0 bg-black/80 backdrop-blur-sm" id="proof-backdrop"></div>
<div class="relative glass-panel-light w-full max-w-lg mx-4 border border-brand-accent/30 p-6 rounded-2xl shadow-2xl pointer-events-auto transform scale-95 duration-300" id="proof-card">
<button id="close-proof" class="absolute top-4 right-4 text-gray-400 hover:text-white">
<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="M6 18L18 6M6 6l12 12"></path></svg>
</button>
<div class="flex items-center gap-3 mb-6 border-b border-white/10 pb-4">
<div class="w-10 h-10 rounded-lg bg-green-500/20 flex items-center justify-center text-green-400">
<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="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path></svg>
</div>
<div>
<h3 class="text-lg font-bold text-white">Compliance Verified</h3>
<p class="text-xs text-brand-accent font-mono" id="proof-timestamp">TIMESTAMP_PLACEHOLDER</p>
</div>
</div>
<div class="space-y-4">
<div class="grid grid-cols-2 gap-4">
<div>
<label class="text-[10px] text-gray-400 uppercase block mb-1">Transaction ID</label>
<p class="font-mono text-sm text-white break-all" id="proof-txid">...</p>
</div>
<div>
<label class="text-[10px] text-gray-400 uppercase block mb-1">Applied Policy</label>
<p class="font-mono text-sm text-brand-accent" id="proof-policy">...</p>
</div>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="text-[10px] text-gray-400 uppercase block mb-1">Origin Region</label>
<p class="font-mono text-sm text-white" id="proof-origin">...</p>
</div>
<div>
<label class="text-[10px] text-gray-400 uppercase block mb-1">Encryption</label>
<p class="font-mono text-sm text-white" id="proof-enc">...</p>
</div>
</div>
<div class="border-t border-white/10 pt-4">
<label class="text-[10px] text-gray-400 uppercase block mb-2">Cryptographic Signature (SHA3-256)</label>
<div class="bg-black/40 p-3 rounded border border-white/5 flex items-center justify-between">
<code class="font-mono text-xs text-green-300 truncate" id="proof-hash">...</code>
<button class="text-gray-400 hover:text-brand-accent ml-2" title="Copy Hash">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path></svg>
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Toast Notification -->
<div id="toast" class="fixed bottom-6 right-6 glass-panel border-l-4 border-brand-accent text-white px-6 py-4 rounded shadow-2xl transform translate-y-24 transition-transform duration-300 flex items-center gap-3 z-[200]">
<svg class="w-5 h-5 text-brand-accent" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>
<span id="toast-message">Operation successful</span>
</div>
<!-- JavaScript Logic -->
<script>
// --- 1. Three.js Globe Setup ---
const scene = new THREE.Scene();
// Fog to fade out deep background
scene.fog = new THREE.FogExp2(0x030508, 0.002);
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 18;
camera.position.y = 2;
const renderer = new THREE.WebGLRenderer({ canvas: document.getElementById('canvas-container'), antialias: true, alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
// Group to hold sphere and points
const globeGroup = new THREE.Group();
scene.add(globeGroup);
// Wireframe Sphere (The Planet)
const sphereGeo = new THREE.IcosahedronGeometry(10, 2);
const sphereMat = new THREE.MeshBasicMaterial({
color: 0x1c2e4a, // Dark blue
wireframe: true,
transparent: true,
opacity: 0.15
});
const globe = new THREE.Mesh(sphereGeo, sphereMat);
globeGroup.add(globe);
// Glowing Core (Inner sphere for blocking background stars)
const coreGeo = new THREE.IcosahedronGeometry(9.9, 2);
const coreMat = new THREE.MeshBasicMaterial({ color: 0x020408 });
const core = new THREE.Mesh(coreGeo, coreMat);
globeGroup.add(core);
// Particles (Cities/Regions)
const particlesGeo = new THREE.BufferGeometry();
const particleCount = 40;
const positions = new Float32Array(particleCount * 3);
const colors = new Float32Array(particleCount * 3);
const userData = []; // Store region info for interactivity
const color1 = new THREE.Color(0x00f0ff); // Cyan
const color2 = new THREE.Color(0x7000ff); // Purple
for(let i = 0; i < particleCount; i++) {
// Random point on sphere surface (spherical coords to cartesian)
const theta = THREE.MathUtils.randFloatSpread(360);
const phi = THREE.MathUtils.randFloatSpread(360);
// Simple distribution approximation
const u = Math.random();
const v = Math.random();
const theta2 = 2 * Math.PI * u;
const phi2 = Math.acos(2 * v - 1);
const r = 10.2; // Slightly above surface
const x = r * Math.sin(phi2) * Math.cos(theta2);
const y = r * Math.sin(phi2) * Math.sin(theta2);
const z = r * Math.cos(phi2);
positions[i*3] = x;
positions[i*3+1] = y;
positions[i*3+2] = z;
// Mix colors
const mixedColor = color1.clone().lerp(color2, Math.random());
colors[i*3] = mixedColor.r;
colors[i*3+1] = mixedColor.g;
colors[i*3+2] = mixedColor.b;
userData.push({
region: Math.random() > 0.5 ? 'US-EAST-1' : 'EU-CENTRAL-1',
status: 'active'
});
}
particlesGeo.setAttribute('position', new THREE.BufferAttribute(positions, 3));
particlesGeo.setAttribute('color', new THREE.BufferAttribute(colors, 3));
const particlesMat = new THREE.PointsMaterial({
size: 0.25,
vertexColors: true,
transparent: true,
opacity: 0.8,
blending: THREE.AdditiveBlending
});
const particleSystem = new THREE.Points(particlesGeo, particlesMat);
globeGroup.add(particleSystem);
// Connecting Lines (Arcs)
const linesMaterial = new THREE.LineBasicMaterial({
color: 0x00f0ff,
transparent: true,
opacity: 0.15
});
// Create a few random connections
for(let i=0; i<10; i++) {
const idx1 = Math.floor(Math.random() * particleCount);
const idx2 = Math.floor(Math.random() * particleCount);
if(idx1 === idx2) continue;
const p1 = new THREE.Vector3(positions[idx1*3], positions[idx1*3+1], positions[idx1*3+2]);
const p2 = new THREE.Vector3(positions[idx2*3], positions[idx2*3+1], positions[idx2*3+2]);
const curve = new THREE.Line(
new THREE.Geometry().setFromPoints([p1, p2]),
linesMaterial
);
globeGroup.add(curve);
}
// Data Packet Animation (Small dot traveling along a line)
const packets = [];
function spawnPacket() {
const idx1 = Math.floor(Math.random() * particleCount);
const idx2 = Math.floor(Math.random() * particleCount);
if(idx1 === idx2) return;
const p1 = new THREE.Vector3(positions[idx1*3], positions[idx1*3+1], positions[idx1*3+2]);
const p2 = new THREE.Vector3(positions[idx2*3], positions[idx2*3+1], positions[idx2*3+2]);
const packetGeo = new THREE.SphereGeometry(0.1, 8, 8);
const packetMat = new THREE.MeshBasicMaterial({ color: 0xffffff });
const packet = new THREE.Mesh(packetGeo, packetMat);
globeGroup.add(packet);
packets.push({ mesh: packet, p1: p1, p2: p2, progress: 0, speed: 0.01 + Math.random() * 0.02 });
}
// Lights
const ambientLight = new THREE.AmbientLight(0xffffff, 0.2);
scene.add(ambientLight);
// Mouse Interaction for Rotation
let isDragging = false;
let previousMousePosition = { x: 0, y: 0 };
const canvas3D = document.getElementById('canvas-container');
canvas3D.addEventListener('mousedown', (e) => {
isDragging = true;
});
window.addEventListener('mouseup', () => isDragging = false);
window.addEventListener('mousemove', (e) => {
if (isDragging) {
const deltaX = e.portalX - previousMousePosition.x;
const deltaY = e.portalY - previousMousePosition.y;
globeGroup.rotation.y += deltaX * 0.005;
globeGroup.rotation.x += deltaY * 0.005;
}
previousMousePosition.x = e.portalX;
previousMousePosition.y = e.portalY;
});
// Handle Window Resize
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// Animation Loop
function animate() {
requestAnimationFrame(animate);
// Rotate globe slightly
if(!isDragging) {
globeGroup.rotation.y += 0.001;
}
// Pulse effect on points
const time = Date.now() * 0.002;
const newSizes = new Float32Array(particleCount);
for(let i=0; i<particleCount; i++) {
const offset = i * 0.5;
newSizes[i] = 0.2 + Math.sin(time + offset) * 0.05;
}
particlesGeo.setAttribute('size', new THREE.BufferAttribute(newSizes, 1));
particlesMat.size = 0.25; // Base size, dynamic requires custom shader or setAttribute, but we'll skip complexity for pure material.
// Animate packets
for(let i = packets.length - 1; i >= 0; i--) {
const p = packets[i];
p.progress += p.speed;
p.mesh.position.lerpVectors(p.p1, p.p2, p.progress);
if(p.progress >= 1) {
globeGroup.remove(p.mesh);
packets.splice(i, 1);
}
}
renderer.render(scene, camera);
}
animate();
// Spawn packets occasionally
setInterval(spawnPacket, 800);
// --- 2. Application Logic (Orchestrator) ---
// State
const appState = {
policies: [
{ id: 1, name: 'GDPR Compliance', region: 'EU', encryption: 'AES-256', active: true, color: 'bg-green-500/20 text-green-400 border-green-500/30' },
{ id: 2, name: 'HIPAA Health Data', region: 'US', encryption: 'AES-256', active: true, color: 'bg-blue-500/20 text-blue-400 border-blue-500/30' },
{ id: 3, name: 'Legacy System APAC', region: 'APAC', encryption: 'AES-128', active: false, color: 'bg-gray-500/20 text-gray-400 border-gray-500/30' }
],
logs: [],
isSimulating: true
};
// DOM Elements
const policyListEl = document.getElementById('policy-list');
const policyFormEl = document.getElementById('policy-form');
const addPolicyBtn = document.getElementById('add-policy-btn');
const savePolicyBtn = document.getElementById('save-policy');
const cancelPolicyBtn = document.getElementById('cancel-policy');
const nameInput = document.getElementById('policy-name');
const regionInput = document.getElementById('policy-region');
const encInput = document.getElementById('policy-enc');
const logContainer = document.getElementById('log-container');
const scoreDisplay = document.getElementById('score-display');
const complianceBar = document.getElementById('compliance-bar');
const proofModal = document.getElementById('proof-modal');
const closeProofBtn = document.getElementById('close-proof');
const proofCard = document.getElementById('proof-card');
const toast = document.getElementById('toast');
// Helpers
const generateHash = () => {
return '0x' + Array.from({length: 64}, () => Math.floor(Math.random() * 16).toString(16)).join('');
};
const formatTime = () => {
const now = new Date();
return now.toISOString().split('T')[1].split('.')[0];
};
const showToast = (msg, type = 'success') => {
const toastMsg = document.getElementById('toast-message');
toastMsg.textContent = msg;
toast.classList.remove('translate-y-24', 'opacity-0');
setTimeout(() => {
toast.classList.add('translate-y-24', 'opacity-0');
}, 3000);
};
// Render Policies
function renderPolicies() {
policyListEl.innerHTML = '';
appState.policies.forEach(policy => {
const el = document.createElement('div');
el.className = `p-3 rounded-lg border ${policy.color} transition-all hover:scale-[1.02] bg-white/5 border-opacity-30 group relative cursor-pointer`;
el.innerHTML = `
<div class="flex justify-between items-start">
<div>
<div class="text-xs font-bold uppercase opacity-70 mb-1">${policy.region}</div>
<div class="font-semibold text-sm">${policy.name}</div>
<div class="text-[10px] font-mono mt-1 opacity-60">${policy.encryption}</div>
</div>
<div class="flex flex-col items-end gap-1">
<span class="text-[10px] px-2 py-0.5 rounded bg-black/30 border border-white/10">${policy.active ? 'ACTIVE' : 'DISABLED'}</span>
${policy.active ?
`<div class="w-2 h-2 rounded-full bg-brand-accent shadow-[0_0_8px_currentColor]" title="Enforcing"></div>` :
`<div class="w-2 h-2 rounded-full bg-gray-500"></div>`
}
</div>
</div>
`;
// Click to toggle active status (for demo purposes)
el.onclick = () => {
policy.active = !policy.active;
renderPolicies();
updateCompliance();
addLog(`Policy '${policy.name}' ${policy.active ? 'enabled' : 'disabled'}`, 'system');
};
policyListEl.appendChild(el);
});
}
// Add Log Entry
function addLog(message, type = 'info', proofData = null) {
const log = {
id: Math.random().toString(36).substr(2, 9),
time: formatTime(),
message,
type, // 'success', 'warning', 'error', 'system', 'policydata'
proofData
};
appState.logs.unshift(log);
if (appState.logs.length > 25) appState.logs.pop(); // Keep only recent
renderLogs();
updateCompliance();
}
// Render Logs
function renderLogs() {
logContainer.innerHTML = '';
appState.logs.forEach(log => {
const el = document.createElement('div');
let colorClass = 'text-gray-400';
let icon = '';
if (log.type === 'success') { colorClass = 'text-green-400'; icon = '<svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path></svg>'; }
else if (log.type === 'warning') { colorClass = 'text-yellow-400'; icon = '<svg class="w-3 h-3 inline mr-1" 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>'; }
else if (log.type === 'error') { colorClass = 'text-red-400'; icon = '<svg class="w-3 h-3 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>'; }
else if (log.type === 'policydata') { colorClass = 'text-brand-accent'; icon = '<svg class="w-3 h-3 inline mr-1" 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>'; }
el.className = `text-xs font-mono p-2 rounded bg-black/30 border-l-2 ${log.type === 'policydata' ? 'border-brand-accent cursor-pointer hover:bg-white/5' : 'border-transparent'}`;
el.innerHTML = `
<div class="flex justify-between items-center mb-1">
<span class="${colorClass} font-bold">[${log.time}]</span>
<span class="text-gray-600 text-[10px]">ID: ${log.id}</span>
</div>
<div class="flex items-center">
${icon}
<span class="${colorClass}">${log.message}</span>
</div>
`;
if (log.proofData) {
el.onclick = () => openProofModal(log.proofData);
}
logContainer.appendChild(el);
});
}
// Update Metrics
function updateCompliance() {
const activePolicies = appState.policies.filter(p => p.active).length;
const totalPolicies = appState.policies.length;
const score = activePolicies > 0 ? 100 : 0; // Simplified for demo
// Check simulated error logs to deduct score occasionally
const errors = appState.logs.filter(l => l.type === 'error').length;
const finalScore = Math.max(0, 100 - (errors * 5)); // Lose 5% per error
scoreDisplay.textContent = `${Math.floor(finalScore)}%`;
complianceBar.style.width = `${finalScore}%`;
if(finalScore < 100) {
scoreDisplay.className = "text-3xl font-mono font-bold text-yellow-400";
complianceBar.classList.remove('from-brand-accent', 'to-green-400');
complianceBar.classList.add('bg-yellow-500');
} else {
scoreDisplay.className = "text-3xl font-mono font-bold text-green-400";
complianceBar.classList.add('from-brand-accent', 'to-green-400');
complianceBar.classList.remove('bg-yellow-500');
}
}
// Policy Form Logic
addPolicyBtn.onclick = () => {
policyFormEl.classList.remove('hidden');
addPolicyBtn.classList.add('hidden');
// GSAP animation
gsap.fromTo(policyFormEl, {opacity: 0, y: 10}, {opacity: 1, y: 0, duration: 0.3});
};
cancelPolicyBtn.onclick = () => {
policyFormEl.classList.add('hidden');
addPolicyBtn.classList.remove('hidden');
nameInput.value = '';
};
savePolicyBtn.onclick = () => {
const name = nameInput.value.trim() || 'New Policy';
const region = regionInput.value;
const enc = encInput.value;
appState.policies.push({
id: Date.now(),
name,
region,
encryption: enc,
active: true,
color: 'bg-brand-accent/20 text-brand-accent border-brand-accent/30'
});
renderPolicies();
policyFormEl.classList.add('hidden');
addPolicyBtn.classList.remove('hidden');
nameInput.value = '';
addLog(`Policy deployed: ${name} for ${region}`, 'system');
showToast('Policy successfully deployed to all edge nodes.');
};
// Simulation Logic
function simulateDataEvent() {
const regions = ['EU', 'US', 'APAC', 'SA', 'AF'];
const dataTypes = ['User Profile', 'Payment Transaction', 'Health Record', 'Genomic Data', 'Video Stream'];
const originRegion = regions[Math.floor(Math.random() * regions.length)];
const dataType = dataTypes[Math.floor(Math.random() * dataTypes.length)];
const txId = 'tx_' + generateHash().substr(2, 10);
// Check Policy Compliance
const applicablePolicy = appState.policies.find(p => p.region === originRegion && p.active);
let success = true;
if (!applicablePolicy) {
success = false;
} else {
// Simulate occasional encryption failure (error)
if (Math.random() > 0.95) success = false;
}
if (success) {
addLog(`Ingress: ${dataType} from ${originRegion} validated.`, 'policydata');
// Generate Proof Artifact
const proofData = {
txId: txId,
timestamp: formatTime(),
policy: applicablePolicy ? applicablePolicy.name : 'None',
encryption: applicablePolicy ? applicablePolicy.encryption : 'N/A',
region: originRegion,
hash: generateHash(),
status: 'COMPLIANT'
};
addLog(`Proof generated [${txId}]. Click to view artifacts.`, 'success', proofData);
} else {
const policyName = applicablePolicy ? applicablePolicy.name : 'No Policy';
addLog(`Violation: ${dataType} from ${originRegion} (Enc: ${policyName}) rejected.`, 'error');
}
}
// Modal Logic
function openProofModal(data) {
document.getElementById('proof-txid').textContent = data.txId;
document.getElementById('proof-timestamp').textContent = data.timestamp;
document.getElementById('proof-policy').textContent = data.policy;
document.getElementById('proof-origin').textContent = data.region;
document.getElementById('proof-enc').textContent = data.encryption;
document.getElementById('proof-hash').textContent = data.hash;
proofModal.classList.remove('opacity-0', 'pointer-events-none');
proofCard.classList.remove('scale-95');
proofCard.classList.add('scale-100');
}
function closeProofModal() {
proofModal.classList.add('opacity-0', 'pointer-events-none');
proofCard.classList.remove('scale-100');
proofCard.classList.add('scale-95');
}
closeProofBtn.onclick = closeProofModal;
document.getElementById('proof-backdrop').onclick = closeProofModal;
// Force Check Button
document.getElementById('simulate-btn').onclick = () => {
simulateDataEvent();
};
// Initial Start
setTimeout(() => {
renderPolicies();
addLog('System initialized. Monitoring 4 cloud regions.', 'system');
// Initial simulation start "warm up"
for(let i=0; i<5; i++) {
setTimeout(simulateDataEvent, i * 1500);
}
}, 1000);
// Continuous Simulation Loop
setInterval(() => {
if(appState.isSimulating && Math.random() > 0.4) {
simulateDataEvent();
}
}, 4000);
</script>
</body>
</html>