Overview
Every node in Intelligence Space can be expanded using Google Gemini AI to discover related interests. Click any sphere, and within seconds, 3-5 new concepts appear, connected to the parent node. This creates an ever-growing web of knowledge tailored to your exploration.Intelligence Space uses Gemini 2.5 Flash for fast, high-quality content generation.
How It Works
User Clicks a Node
When you click a sphere in the 3D graph, the A loading indicator appears above the node (three bouncing dots).
handleExpand function is triggered with the node’s label:Server Action Called
The This is a Next.js server action that runs securely on the backend with API key access.
generateSubInterests server action is invoked from src/app/actions.ts:7:AI Generates Related Concepts
Gemini AI receives a carefully crafted prompt and returns 3-5 related sub-interests as a JSON array.
The AI Prompt
Prompt Engineering
The prompt is designed to produce structured, consistent output while encouraging creative exploration:Why This Prompt Works
Why This Prompt Works
Key Design Decisions:
- Role Setting - “You are an AI that helps brainstorm…” establishes the AI’s purpose
- Clear Constraints - “3 to 5 highly relevant” prevents overwhelming or sparse results
- Format Specification - “Only provide a JSON array” ensures parseable output
- Markdown Prevention - Explicitly forbids ```json wrappers that would break parsing
- Example Provided - Shows exact format expected
Example Results
- Input: Quantum Physics
- Input: Minimalist Art
- Input: Renaissance Music
API Integration
Google GenAI Setup
The integration uses the official@google/genai SDK:
Making the Request
Response Parsing
The response undergoes careful cleaning before JSON parsing:The
.slice(0, 5) ensures that even if the AI returns more than 5 items, only the first 5 are used to prevent visual clutter.Fallback Handling
Graceful Degradation
Intelligence Space never fails - if the API is unavailable or returns invalid data, it falls back to mock data:- No API Key
- API Error
If Users can still explore the interface with generic but relevant sub-topics.
GEMINI_API_KEY is missing:Loading UX
Preventing Double-Clicks
The system prevents multiple simultaneous expansions:Visual Feedback
While AI generates content, a bouncing dots indicator appears above the node:Automatic Initial Expansion
First Node Behavior
When you enter your first interest, Intelligence Space automatically expands it to kickstart exploration:Performance Considerations
Response Time
Gemini 2.5 Flash typically responds in 1-3 seconds, providing near-instant expansion.
Cost Efficiency
Using the Flash model keeps API costs minimal while maintaining quality.
Error Recovery
Fallback mock data ensures the app never crashes from API failures.
Concurrent Safety
The
loadingNodeId state prevents race conditions from multiple clicks.3D Visualization
Learn how the 3D graph is rendered
Interactive Navigation
Discover navigation and interaction patterns