惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tailwind CSS Blog
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
The Cloudflare Blog
博客园 - 聂微东
博客园 - 司徒正美
量子位
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
Apple Machine Learning Research
Apple Machine Learning Research
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
Y
Y Combinator Blog
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
Google DeepMind News
Google DeepMind News
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
A
About on SuperTechFans

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
NexusGraph — Transform Any Text into a Stunning AI Knowle...
Saquib Shahi · 2026-05-10 · via DEV Community

What I Built

NexusGraph is an AI-powered knowledge graph explorer that transforms any text into a stunning, interactive force-directed graph visualization.

Paste an article, research paper, meeting notes, or any content — and watch as Gemma 4 extracts entities, discovers relationships, and builds a beautiful animated knowledge graph in real-time.

✨ Key Features

  • 🧠 AI-Powered Entity Extraction — Gemma 4 identifies people, organizations, concepts, technologies, events, and places from any text
  • 🔗 Relationship Discovery — Automatically maps how entities connect with descriptive relationship labels
  • 🎬 Real-Time Streaming — Nodes and edges appear one-by-one via Server-Sent Events, creating a mesmerizing build animation
  • 🖱️ Interactive Graph — Click, drag, zoom, and pan. Hover over nodes to highlight connections. Click any node to see its details and relationships
  • 🔍 Explore Deeper — Select any node and ask Gemma 4 to expand it with additional sub-entities and connections
  • 💬 Ask Gemma 4 — Ask natural language questions about the graph and get contextual AI-powered answers
  • 📊 Category Visualization — Nodes are color-coded by type (person, concept, technology, organization, etc.) with glowing effects
  • 📥 Export — Download your knowledge graph as a PNG image
  • 🌍 Multilingual — Works with text in 35+ languages thanks to Gemma 4's multilingual training

The Stack

  • Backend: Node.js + Express
  • AI: Gemma 4 31B Dense via OpenRouter
  • Visualization: D3.js force-directed graph
  • Streaming: Server-Sent Events (SSE)
  • Frontend: Vanilla HTML/CSS/JS — zero frameworks, zero bloat

Demo

🔗 Live Demo → https://nexusgraph-production.up.railway.app

Try clicking one of the built-in examples ("AI & Machine Learning", "History of the Internet", or "The Solar System") to see it in action instantly!

How It Looks

The app analyzes the "AI & Machine Learning" example and extracts 21 entities and 22 relationships, building this interactive graph:

Code

How I Used Gemma 4

Why Gemma 4 31B Dense?

I chose the Gemma 4 31B Dense model because knowledge graph extraction requires deep reasoning that smaller models can't match:

  1. Complex entity extraction — Identifying that "Dartmouth Conference" is an event, "Geoffrey Hinton" is a person, and "Transformer Architecture" is a technology requires nuanced understanding
  2. Relationship reasoning — Generating specific relationship labels like "pioneered" or "defeated" (not generic "related to") demands strong language comprehension
  3. Structured JSON output — Reliably producing valid JSON with nested objects and consistent IDs requires instruction-following capability that the 31B model handles excellently
  4. Long context — The 256K context window handles lengthy articles and papers without truncation

Three Intentional Integration Points

NexusGraph uses Gemma 4 in three distinct, purpose-built ways — not just a chat wrapper:

1. Analyze (/api/analyze) — The core pipeline. Gemma 4 receives carefully engineered prompts that instruct it to:

  • Extract 10-25 entities with categories, descriptions, and importance scores (1-10)
  • Map relationships with descriptive labels and strength scores
  • Output strict JSON schema for programmatic parsing
// Structured prompt engineering for reliable graph extraction
const ANALYZE_PROMPT = `You are an expert knowledge graph builder...
OUTPUT FORMAT — respond with ONLY this JSON:
{
  "nodes": [{"id": "snake_case_id", "label": "...", "category": "person|concept|...", "importance": 8}],
  "edges": [{"source": "node_id_1", "target": "node_id_2", "label": "relationship verb", "strength": 7}]
}
RULES:
- Extract 10-25 nodes for optimal visualization
- Every node MUST connect to at least one other node
- Use specific relationship labels — never "related to"`;

Enter fullscreen mode Exit fullscreen mode

2. Explore (/api/explore) — When a user clicks "Explore Deeper" on any node, Gemma 4 generates a sub-graph with 5-10 additional entities specifically related to that concept, while being aware of existing nodes to avoid duplicates.

3. Ask (/api/ask) — Context-aware Q&A. Gemma 4 receives both the original text AND the extracted graph structure, enabling it to answer questions like "What's the connection between Geoffrey Hinton and modern LLMs?" with graph-aware reasoning.

The SSE Streaming Architecture

Instead of waiting for the full response and rendering everything at once, I stream the graph to life:

User Input → Gemma 4 (extract JSON) → Parse → SSE Stream nodes one-by-one → SSE Stream edges → Done

Enter fullscreen mode Exit fullscreen mode

Each node arrives as an individual SSE event with a 120ms delay, triggering a D3.js elastic spring animation. The result is a mesmerizing "graph building itself" effect that makes the AI feel alive.

// Stream nodes one by one for animation effect
for (const node of graph.nodes) {
  await delay(120);
  sseWrite(res, { type: 'node', data: node });
}

Enter fullscreen mode Exit fullscreen mode

This isn't just eye candy — it gives users real-time feedback during the 10-30 second analysis, turning wait time into an engaging experience.

What I Learned

  • Gemma 4's instruction-following for structured JSON is remarkably reliable — I rarely needed to retry for parse errors
  • The 31B Dense model strikes the perfect balance between quality and speed for this use case
  • Prompt engineering matters more than model size — specific examples and strict format rules dramatically improved extraction quality.