🌳 Knowledge Tree (tree.loca.zone)

🧠 TL;DR

  • App: Vanilla JS + D3 frontend served by server.py on 127.0.0.1:51808. Canonical URL: https://tree.loca.zone.
  • Direct diagnostic URL: http://routa.loca.zone:51808/ (Knowledge Tree listener, not a separate Routa app).
  • Wiki: static Quartz content at https://wiki.tree.loca.zone.
  • Secrets: Map Groq/OpenRouter keys from .env. Never commit.
  • HTTP: Do not open index.html via file://.

📂 Key Facts & Paths

  • Root: /home/loca/dev/knowledge-tree
  • Wiki source: /home/loca/dev/wikis/tree/content
  • Wiki publish root: /home/loca/dev/wikis/tree/current
  • Obsolete code: quarantined in obsolete/
  • Logs: logs/debug-{today}.jsonl

🛠️ Run & Deploy

  • Local run: cd /home/loca/dev/knowledge-tree && cp .env.example .env && python3 server.py (or run ./start.command). Default port: 51808.
  • DNS: wildcard *.loca.zone already resolves to the loca host; no per-project record is required.
  • App proxy:
    server { server_name tree.loca.zone; location / { proxy_pass http://127.0.0.1:51808; } }
  • Wiki: Nginx serves /home/loca/dev/wikis/tree/current for wiki.tree.loca.zone.
  • Publish wiki: cd /home/loca/dev/wikis && ./build.sh tree.

🔍 Validation Checks

  • Server: python3 server.py binds 127.0.0.1:51808 by default.
  • Smoke check: curl -sf -o /dev/null -w "%{http_code}\n" http://127.0.0.1:51808/; repeat for /api/config and /src/scripts/main.js.
  • Config API: GET /api/config returns JSON without raw provider keys.
  • Public endpoints: both https://tree.loca.zone/ and https://wiki.tree.loca.zone/ return HTTP 200.
  • Wiki build: /home/loca/dev/wikis/build.sh tree --check-only, then /home/loca/dev/wikis/build.sh tree.


⚙️ Stack & Details

  • Technical stack:
    • runtime: vanilla JS ES modules, HTML5, CSS3
    • visualization: D3.js v7
    • exports: html2canvas, jsPDF
    • intelligence: OpenRouter Claude 3 Haiku API
    • status: production ready v0.3.0
    • layout: single entry index.html with Content Security Policy headers
  • Scripts:
    • main.js: controls application initialization, keyboard navigation, node folding, and exports
    • tree.js: DOM-safe D3 tree rendering
    • ui.js: UI panels, settings, and in-app debug log UI
    • api.js: OpenRouter client and schema response validator
    • settings.js: localStorage state manager for AI generation params
    • debugLog.js: trace log manager with PII scrubbing
    • utils.js: common helper primitives and event manager
    • config.js: gitignored API key config file
  • Styles:
    • main.css: layout variables and basic styling
    • themes.css: light/dark theme color schemas
    • components.css: specific rules for panels, nodes, and debug components
  • Security & math safety:
    • DOM generation: DOM API with escapeText sanitization, no raw innerHTML
    • event handlers: zero inline onclick attributes in markup
    • CSP headers: unsafe-eval (D3) and unsafe-inline (Google Fonts) required
    • math safety: coordinates filtered against NaN and Infinity