๐ŸŒณ Knowledge Tree v0.3.0

๐Ÿ’ก AI-powered interactive D3 topic visualizer (Production-Ready)

๐Ÿ› ๏ธ Stack: Vanilla JS (ESM), D3.js v7, Python dev server (server.py) with LLM proxy, html2canvas, jsPDF, Groq / OpenRouter. No build step.


๐Ÿ“‚ Layout:

  • index.html โ€” Entry point & CSP
  • start.command โ€” Quick launch script
  • server.py โ€” Python dev server & LLM proxy (port 51808)
  • src/scripts/: main.js (Init/Nav), tree.js (D3), ui.js (Panels), api.js (LLM), settings.js (LocalStorage), debugLog.js (Logs), utils.js (Helpers)
  • src/styles/: main.css (Core), themes.css (Themes), components.css (UI styles)

๐Ÿš€ Quick Start:

  1. Copy .env.example to .env in the root: cp .env.example .env
  2. Set API keys (API_KEY_GROQ, API_KEY_OPENROUTER) in .env.
  3. Start the dev server: python3 server.py (or double-click ./start.command on macOS).
  4. Visit http://localhost:51808.

โœ… Features:

  • ๐ŸŒณ D3 Tree: Interactive zoom/pan, folding memory, and NaN/Infinity bounds safety.
  • ๐Ÿ’ฌ AI Panels: Preset generations (Creative/Balanced/Precise/Factual), LLM metrics, and redacted observability logs.
  • ๐Ÿ’พ State & I/O: LocalStorage config, drag-and-drop JSON import (merge/replace), and PNG/PDF/JSON/MD exports.
  • โŒจ๏ธ UX & Accessibility: Undo/Redo (โŒ˜Z/โŒ˜โ‡งZ), keyboard nav, DOM-safe escaping, event listeners (no inline onclick), and dark mode.
  • โ™ฟ A11y & Focus: Unified focus-trap model (Escape closes, loops focus, restores on close) for Node, Confirm, Debug, and Import panels. Normalised WCAG 2.2 SC 2.5.8 compliant target sizes (24x24px with spacing, 44x44px for coarse pointers).
  • ๐ŸŽ๏ธ Perf-UX: Reduced-motion fallback animation support; prevented transform shifts on mobile debug drawer; skeleton loader states during async AI generation.

๐Ÿšจ Security:

  • ๐Ÿ”’ DOM Safety: DOM API + escapeText() formatting only. No inline handlers.
  • ๐Ÿ›ก๏ธ CSP: Requires unsafe-eval (D3) & unsafe-inline (Google Fonts).
  • ๐Ÿ—ƒ๏ธ Secrets Protection: Keys live only in .env (never committed or exposed).

๐ŸŽฏ Done:

  • P1: Focus-trap architecture for modals/drawers (Node, Confirm, Debug, Import) ๐Ÿงฏ
  • P2: Export menu keyboard navigation and ARIA semantics ๐Ÿ“„
  • P3: Collapsible settings intent groups and Reset-to-Defaults โš™๏ธ
  • P4: Screen-reader helpers, contrast checks, and tab-order validation โ™ฟ
  • P5: Skeleton states and redraw optimization for frequent debug updates ๐ŸŽ๏ธ

๐Ÿ”ฎ Roadmap:

  • ๐Ÿงช Unit tests for API/settings modules.
  • ๐Ÿ” Real-time node search and filter panel.
  • โšก Virtualized D3 tree layout for massive datasets.
  • ๐Ÿ“ฆ Offline PWA support with local cache.

โŒจ๏ธ Shortcuts:

ScopeKeyAction
GlobalโŒ˜Z / โŒ˜โ‡งZ (or โŒ˜Y)Undo / Redo
โŒ˜E / โŒ˜OExport / Import dialog
โŒ˜, / EscSettings panel / Close panels
Nodeโ†‘ / โ†“Navigate tree levels
โ† / โ†’Navigate siblings
Tab / โ‡งTabGo to first child / Go to parent
Enter / โ‡งEnterFold/unfold (or extend) / Force extend
Space / โŒ˜NOpen node panel / Extend children
โŒ˜H / โŒ˜I / โŒ˜โŒซToggle visibility / Generate insights / Delete

โš™๏ธ Config Notes:

  • ๐Ÿ”‘ API keys live in .env at the project root (API_KEY_GROQ, API_KEY_OPENROUTER). The retired config.js is deprecated and moved to obsolete/.
  • ๐ŸŒ The Python server (server.py) defaults to port 51808 to proxy LLM requests and load ES modules.
  • ๐Ÿ’พ Settings persist in localStorage with XOR validation and range clamping.
  • ๐Ÿ“Š Debug logs are written to the serverโ€™s filesystem under logs/debug-{today}.jsonl.

๐ŸŒ Hosting & DNS:

  • App URL: https://tree.loca.zone (reverse proxies to loopback port 51808)
  • Wiki URL: https://wiki.tree.loca.zone (static Quartz site)
  • Direct diagnostic URL: http://routa.loca.zone:51808/ (Knowledge Tree listener, not a separate Routa app)
  • Reverse Proxy (Nginx):
    server_name tree.loca.zone;
    location / {
        proxy_pass http://127.0.0.1:51808;
    }
  • Smoke Checks:
    curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:51808/
    curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:51808/api/config
    curl -s -o /dev/null -w "%{http_code}\n" http://127.0.0.1:51808/src/scripts/main.js
    (Expect 200 on all checks)