<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interstellar Graph Database - WASM Demo</title>
<script src="https://d3js.org/d3.v7.min.js"></script>
<style>
:root {
--bg-color: #0f0f0f;
--card-bg: #1a1a1a;
--card-border: #2a2a2a;
--text-color: #e5e5e5;
--text-muted: #888;
--primary: #3b82f6;
--primary-hover: #2563eb;
--success: #22c55e;
--warning: #eab308;
--error: #ef4444;
--code-bg: #141414;
--code-border: #262626;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
background: var(--bg-color);
color: var(--text-color);
height: 100vh;
display: flex;
flex-direction: column;
overflow: hidden;
}
header {
flex-shrink: 0;
background: var(--card-bg);
border-bottom: 1px solid var(--card-border);
padding: 12px 20px;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 12px;
z-index: 100;
}
.header-left {
display: flex;
align-items: center;
gap: 20px;
}
h1 {
font-size: 1.5rem;
font-weight: 700;
color: #fff;
}
h1 span {
color: var(--primary);
}
.status {
display: inline-flex;
align-items: center;
padding: 4px 12px;
border-radius: 16px;
font-size: 0.75rem;
font-weight: 500;
}
.status.loading {
background: rgba(234, 179, 8, 0.15);
color: var(--warning);
border: 1px solid rgba(234, 179, 8, 0.3);
}
.status.ready {
background: rgba(34, 197, 94, 0.15);
color: var(--success);
border: 1px solid rgba(34, 197, 94, 0.3);
}
.status.error {
background: rgba(239, 68, 68, 0.15);
color: var(--error);
border: 1px solid rgba(239, 68, 68, 0.3);
}
.header-right {
display: flex;
align-items: center;
gap: 16px;
}
.stats {
display: flex;
gap: 16px;
align-items: center;
}
.stat {
display: flex;
align-items: center;
gap: 6px;
font-size: 0.875rem;
}
.stat-value {
font-weight: 700;
color: var(--primary);
font-variant-numeric: tabular-nums;
}
.stat-label {
color: var(--text-muted);
}
button {
background: var(--primary);
color: white;
border: none;
padding: 8px 16px;
border-radius: 6px;
cursor: pointer;
font-size: 0.8125rem;
font-weight: 500;
transition: all 0.2s ease;
}
button:hover {
background: var(--primary-hover);
}
button:disabled {
opacity: 0.4;
cursor: not-allowed;
}
button.secondary {
background: var(--card-border);
}
button.secondary:hover {
background: #3a3a3a;
}
.loading-spinner {
display: inline-block;
width: 12px;
height: 12px;
border: 2px solid currentColor;
border-radius: 50%;
border-top-color: transparent;
animation: spin 0.8s linear infinite;
margin-right: 6px;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.tabs {
flex-shrink: 0;
display: flex;
background: var(--card-bg);
border-bottom: 1px solid var(--card-border);
z-index: 100;
}
.tab {
padding: 12px 24px;
background: none;
border: none;
border-radius: 0;
color: var(--text-muted);
cursor: pointer;
font-size: 0.875rem;
font-weight: 500;
position: relative;
transition: color 0.2s;
}
.tab:hover {
color: var(--text-color);
background: none;
}
.tab.active {
color: var(--primary);
}
.tab.active::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
right: 0;
height: 2px;
background: var(--primary);
}
.tab-content {
flex: 1;
display: none;
overflow: hidden;
}
.tab-content.active {
display: flex;
flex-direction: column;
}
#console-tab {
padding: 0;
gap: 0;
background: var(--code-bg);
overflow: hidden;
}
.repl-container {
flex: 1;
display: flex;
flex-direction: column;
font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
font-size: 0.8125rem;
line-height: 1.5;
min-height: 0;
}
#consoleOutput {
flex: 1;
padding: 12px 16px;
overflow-y: auto;
white-space: pre-wrap;
word-wrap: break-word;
min-height: 0;
}
.output-entry {
margin-bottom: 8px;
}
.output-query {
color: var(--text-muted);
}
.output-query::before {
content: '> ';
color: var(--primary);
}
.output-query code {
color: #93c5fd;
}
.output-result {
color: var(--success);
padding-left: 18px;
margin-top: 2px;
}
.output-result.error {
color: var(--error);
}
.output-result.info {
color: var(--text-muted);
}
.output-time {
color: #525252;
font-size: 0.6875rem;
padding-left: 18px;
}
.repl-input-area {
flex-shrink: 0;
border-top: 1px solid var(--code-border);
background: var(--card-bg);
padding: 10px 16px;
display: flex;
flex-direction: column;
gap: 8px;
}
.repl-input-row {
display: flex;
align-items: flex-start;
gap: 8px;
}
.repl-prompt {
color: var(--primary);
font-weight: 600;
padding-top: 6px;
user-select: none;
}
#queryInput {
flex: 1;
background: var(--code-bg);
color: var(--text-color);
border: 1px solid var(--code-border);
border-radius: 4px;
padding: 6px 10px;
font-family: inherit;
font-size: inherit;
line-height: 1.5;
resize: none;
min-height: 32px;
max-height: 150px;
overflow-y: auto;
}
#queryInput:focus {
outline: none;
border-color: var(--primary);
}
#queryInput::placeholder {
color: #555;
}
.repl-actions {
display: flex;
gap: 8px;
align-items: center;
padding-left: 18px;
}
.repl-actions select {
background: var(--code-bg);
color: var(--text-color);
border: 1px solid var(--code-border);
padding: 4px 8px;
border-radius: 4px;
font-size: 0.75rem;
}
.repl-actions select:focus {
outline: none;
border-color: var(--primary);
}
.repl-hint {
font-size: 0.6875rem;
color: var(--text-muted);
margin-left: auto;
}
kbd {
background: var(--code-bg);
border: 1px solid var(--code-border);
border-radius: 3px;
padding: 1px 4px;
font-family: inherit;
font-size: 0.625rem;
}
#visualization-tab {
position: relative;
}
.viz-toolbar {
position: absolute;
top: 12px;
left: 12px;
display: flex;
gap: 8px;
z-index: 10;
}
.viz-toolbar button {
padding: 6px 12px;
font-size: 0.75rem;
}
#graphCanvas {
width: 100%;
height: 100%;
background: var(--bg-color);
}
#graphCanvas .node {
cursor: pointer;
}
#graphCanvas .node circle {
stroke: #fff;
stroke-width: 1.5px;
}
#graphCanvas .node text {
font-size: 11px;
fill: var(--text-color);
pointer-events: none;
}
#graphCanvas .link {
stroke: #555;
stroke-opacity: 0.6;
}
#graphCanvas .link-label {
font-size: 9px;
fill: var(--text-muted);
}
.properties-panel {
position: absolute;
top: 12px;
right: 12px;
width: 280px;
background: var(--card-bg);
border: 1px solid var(--card-border);
border-radius: 8px;
padding: 16px;
z-index: 10;
display: none;
}
.properties-panel.visible {
display: block;
}
.properties-panel h3 {
font-size: 0.875rem;
margin-bottom: 12px;
display: flex;
justify-content: space-between;
align-items: center;
}
.properties-panel .close-btn {
background: none;
border: none;
color: var(--text-muted);
cursor: pointer;
padding: 4px;
font-size: 1rem;
}
.properties-panel .close-btn:hover {
color: var(--text-color);
background: none;
}
.property-row {
display: flex;
justify-content: space-between;
padding: 6px 0;
border-bottom: 1px solid var(--code-border);
font-size: 0.8125rem;
}
.property-row:last-child {
border-bottom: none;
}
.property-key {
color: var(--text-muted);
}
.property-value {
color: var(--text-color);
font-family: 'SF Mono', monospace;
font-size: 0.75rem;
}
.properties-panel .actions {
margin-top: 12px;
display: flex;
gap: 8px;
}
.properties-panel button {
flex: 1;
padding: 6px 12px;
font-size: 0.75rem;
}
.properties-panel button.danger {
background: var(--error);
}
.properties-panel button.danger:hover {
background: #dc2626;
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
color: var(--text-muted);
gap: 12px;
}
.empty-state svg {
width: 48px;
height: 48px;
opacity: 0.5;
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--code-bg);
}
::-webkit-scrollbar-thumb {
background: #333;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #444;
}
.node-person { fill: #3b82f6; }
.node-product { fill: #22c55e; }
.node-company { fill: #f59e0b; }
.node-default { fill: #8b5cf6; }
.edge-knows { stroke: #6b7280; }
.edge-purchased { stroke: #f59e0b; }
.edge-works_at { stroke: #ec4899; }
.edge-default { stroke: #6b7280; }
.node.selected circle {
stroke: var(--primary);
stroke-width: 3px;
}
.link.selected {
stroke: var(--primary) !important;
stroke-width: 3px;
}
.legend {
position: absolute;
bottom: 12px;
left: 12px;
background: var(--card-bg);
border: 1px solid var(--card-border);
border-radius: 8px;
padding: 12px;
font-size: 0.75rem;
z-index: 10;
}
.legend-title {
color: var(--text-muted);
margin-bottom: 8px;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.legend-item {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 4px;
}
.legend-color {
width: 12px;
height: 12px;
border-radius: 50%;
}
</style>
</head>
<body>
<header>
<div class="header-left">
<h1><span>Interstellar</span> Graph</h1>
<span id="status" class="status loading">
<span class="loading-spinner"></span>Loading...
</span>
</div>
<div class="header-right">
<div class="stats">
<div class="stat">
<span class="stat-value" id="vertexCount">0</span>
<span class="stat-label">vertices</span>
</div>
<div class="stat">
<span class="stat-value" id="edgeCount">0</span>
<span class="stat-label">edges</span>
</div>
</div>
<button id="btnCreateSample" disabled>Create Sample Graph</button>
<button id="btnClearGraph" class="secondary" disabled>Clear</button>
</div>
</header>
<div class="tabs">
<button class="tab active" data-tab="console">Console</button>
<button class="tab" data-tab="visualization">Graph Visualization</button>
</div>
<div id="console-tab" class="tab-content active">
<div class="repl-container">
<div id="consoleOutput">
<div class="output-entry">
<div class="output-result info">Interstellar Graph Console</div>
<div class="output-result info">Type queries below or select an example. Press Enter to run.</div>
</div>
</div>
<div class="repl-input-area">
<div class="repl-input-row">
<span class="repl-prompt">></span>
<textarea id="queryInput" rows="1" placeholder="graph.V().toList()"></textarea>
</div>
<div class="repl-actions">
<select id="queryExamples">
<option value="">Examples...</option>
<optgroup label="Read">
<option value="graph.V().toList()">All vertices</option>
<option value="graph.V().toCount()">Count vertices</option>
<option value="graph.V().hasLabel('person').values('name').toList()">Person names</option>
<option value="graph.V().hasLabel('person').elementMap().toList()">Person details</option>
<option value="graph.V().hasLabel('person').hasWhere('age', P.gte(25)).values('name').toList()">Age >= 25</option>
<option value="graph.V().hasLabel('person').outLabels(['knows']).values('name').toList()">Friends</option>
<option value="graph.V().hasLabel('person').values('name').fold().first()">Fold names</option>
<option value="graph.V().hasLabel('person').values('age').sum().first()">Sum ages</option>
</optgroup>
<optgroup label="Mutate">
<option value="graph.V().addV('person').property('name', 'NewPerson').property('age', 28).toList()">Add person</option>
<option value="graph.V().addV('product').property('name', 'Widget').property('price', 99).toList()">Add product</option>
<option value="graph.V().hasLabel('person').hasValue('name', 'NewPerson').drop().iterate()">Delete NewPerson</option>
</optgroup>
</select>
<button id="btnRunQuery" disabled>Run</button>
<button id="btnClearOutput" class="secondary">Clear</button>
<span class="repl-hint"><kbd>Enter</kbd> run · <kbd>Shift+Enter</kbd> newline</span>
</div>
</div>
</div>
</div>
<div id="visualization-tab" class="tab-content">
<div class="viz-toolbar">
<button id="btnZoomIn">Zoom In</button>
<button id="btnZoomOut">Zoom Out</button>
<button id="btnFitGraph">Fit to Screen</button>
<button id="btnResetLayout">Reset Layout</button>
</div>
<svg id="graphCanvas"></svg>
<div class="legend">
<div class="legend-title">Node Types</div>
<div class="legend-item">
<div class="legend-color" style="background: #3b82f6;"></div>
<span>Person</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: #22c55e;"></div>
<span>Product</span>
</div>
<div class="legend-item">
<div class="legend-color" style="background: #f59e0b;"></div>
<span>Company</span>
</div>
</div>
<div id="propertiesPanel" class="properties-panel">
<h3>
<span id="propTitle">Properties</span>
<button class="close-btn" id="btnCloseProps">×</button>
</h3>
<div id="propContent"></div>
<div class="actions">
<button id="btnDeleteSelected" class="danger">Delete</button>
</div>
</div>
</div>
<script type="module" src="app.js"></script>
</body>
</html>