Watch
1
0
Fork
You've already forked smart-memory-graph
0
mirror of https://github.com/smart-memory/smart-memory-graph.git synced 2026-08-21 15:43:33 +00:00
Find a file
smartmem-dev b34a01fb35 chore: untrack .DS_Store and ignore it
Two .DS_Store files were committed to the repo and kept showing up as dirty
working-tree noise on every session. Removes them from tracking (the files
themselves are Finder metadata, never useful to a checkout) and adds the ignore
rule so they cannot come back.
b34a01fb35 · 2026-08-13 14:16:29 +08:00
73 commits
2026-07-12 14:32:09 +08:00

@smartmemory/graph

Version: 0.2.3

Shared graph visualization package for SmartMemory. Provides Cytoscape.js-powered graph components, hooks, and adapters that can be consumed by any React app.

Usage

import { GraphExplorer, createFetchAdapter } from '@smartmemory/graph';
import '@smartmemory/graph/src/graph.css';

const adapter = createFetchAdapter({
  apiUrl: 'http://localhost:9001',
  getToken: () => localStorage.getItem('token'),
  getTeamId: () => localStorage.getItem('team_id'),
});

function App() {
  return <GraphExplorer adapter={adapter} wsUrl="ws://localhost:9001/ws/insights" />;
}

Architecture

src/
├── components/       # 11 React components (GraphExplorer, DetailPanel, etc.)
├── hooks/            # 8 React hooks (useGraphData, useGraphStream, etc.)
├── adapters/         # Transport abstraction (fetchAdapter, sdkAdapter)
├── core/             # Pure functions (colors, constants, normalize, coalesce)
├── internal/         # Cytoscape internals (NOT exported)
├── index.js          # Barrel export
└── graph.css         # Graph-specific styles

Key Concepts

  • GraphNode/GraphEdge: Canonical domain types ({ id, label, type, category }). Components work with these.
  • Cytoscape elements: Internal rendering format. Conversion happens only inside GraphExplorer.
  • Adapter pattern: GraphAPIAdapter interface (14 methods). fetchAdapter for standalone apps, sdkAdapter for JS SDK consumers.
  • Controlled/uncontrolled: Pass data prop for controlled mode, or let GraphExplorer fetch via adapter.

Exports

Components

GraphExplorer, DetailPanel, FilterPanel, SearchBar, Toolbar, OperationsBar, CytoscapeCanvas, NodeTooltip, WikipediaOverlay, ReplayButton, TimeTravelSlider

Hooks

useGraphData, useGraphFilters, useGraphStream, useGraphInteraction, useDripFeed, useUrlState, useConnectionStatus, useEntityCorrections

Adapters

createFetchAdapter, createSDKAdapter

Core Utilities

getNodeColor, getNodeSize, MEMORY_COLORS, ENTITY_COLORS, SPECIAL_COLORS, NODE_SIZES, ALL_MEMORY_TYPES, ALL_ENTITY_TYPES, MEMORY_TYPE_SET, ENTITY_TYPES, LAYOUT_OPTIONS, RECIPROCAL_PAIRS, normalizeAPIResponse, normalizeExtractionResults, coalesceGraphData, classifyEvent, eventToGraphNode, eventToGraphEdge, searchWikipedia, exportPNG, exportSVG, saveRecording, getLastRecording, clearRecordings

Scripts

Command Description
npm test Run tests (vitest)
npm run test:watch Watch mode

Consumers

  • smart-memory-viewer — Standalone graph viewer (uses fetchAdapter)
  • smart-memory-web — Main web app (planned, will use sdkAdapter)
  • smart-memory-studio — Pipeline lab (planned)

Documentation

Full SmartMemory documentation: https://docs.smartmemory.ai