Inspiration

In 2021, a single container ship blocked the Suez Canal for six days, costing global trade $9.6 billion per day. That same year, a single AWS region failure brought down Netflix, Disney+, Slack, and thousands of businesses. The 2008 financial crisis? One bank's collapse triggered a global economic meltdown.

These weren't random failures they were cascade failures. Hidden dependencies between components created fragility that nobody could see until it was too late.

We asked ourselves: What if AI could visualize these hidden dependencies and simulate catastrophic failures BEFORE they happen?

That question led us to build CollapseMAP.

What it does

CollapseMAP is an AI-powered System Fragility Analyzer that transforms complex systems into interactive vulnerability maps. It doesn't just identify risks—it simulates how failures cascade through your entire system in real-time.

Core Capabilities: 🔍 AI System Decomposition

  • Enter any system name (supply chain, startup, infrastructure)
  • Gemini 3 Pro automatically identifies components, dependencies, and vulnerabilities
  • Real-world data grounding via Google Search

⚡ Cascade Failure Simulation

  • Select any component and trigger failure scenarios (failure, overload, disruption, attack)
  • Watch animated propagation through the dependency graph
  • See impact scores for every affected node in real-time

📊 Interactive Vulnerability Graph

  • Cyber-command-center aesthetic with glassmorphism UI
  • Color-coded fragility scores (green → red)
  • Custom pulse edge animations for cascade visualization
  • Zoom, pan, minimap, and full graph exploration

📋 Deep Research Reports

  • AI-generated resilience strategies
  • Prioritized recommendations with effort estimates
  • Grounded in real-world best practices

🔊 Audio Briefings

  • AI-generated spoken crisis briefings with SSML formatting
  • Multiple styles: urgent, calm, tactical, executive
  • Variable duration: 30s, 60s, or 90s summaries

🖼️ Multimodal Image Upload

  • Upload whiteboard photos or architecture diagrams
  • Gemini Vision extracts components automatically
  • Supports PNG, JPEG, WebP, and GIF formats

💬 AI Chat Assistant

  • Context-aware conversational AI integrated directly into the app
  • Understands your current graph, simulations, and reports
  • Right-click any text to get AI explanations via context menu
  • Maintains conversation history for continuous dialogue
  • Fast responses using Gemini Flash model

🧠 AI Thinking Terminal

  • Real-time visibility into Gemini's reasoning process
  • Watch the AI analyze, search, and conclude in real-time
  • Collapsible terminal with scanning line animation

💾 Session Management

  • Save and restore analysis sessions
  • Pre-built templates for common systems
  • Export graphs as PNG/SVG images

How we built it

Gemini Integration (7 Advanced Features)

  1. High Thinking Mode - 65,536 token budget for deep systemic analysis
  2. Google Search Grounding - Real-world data from infrastructure incidents, SLA patterns, and industry reports
  3. Thought Signature Protocol™ - Our novel approach to stateful reasoning across API calls
  4. Structured JSON Output - Reliable Zod schema-validated responses
  5. Vision API - Multimodal diagram extraction using Gemini 3 Pro Preview
  6. Audio Script Generation - SSML-formatted crisis briefings for TTS
  7. Conversational Chat - Context-aware AI assistant using Gemini 3 Pro Preview

The Thought Signature Protocol™ Unlike stateless LLM calls, we implemented reasoning continuity:

Decomposition → thoughtSignature generated (SHA-256 hash)
     ↓
Simulation → signature passed back, Gemini "remembers" topology  
     ↓
Report → cumulative reasoning produces deeper insights
     ↓
Chat → full context awareness of graph, simulation, and reports

This ensures Gemini maintains context about your system across the entire analysis workflow.

Tech Stack

  • Frontend: Next.js 16.1.6, React 18.3, @xyflow/react 12.4 (ReactFlow), Zustand 5.0, Framer Motion 11.15, Tailwind CSS 3.4, Lucide Icons
  • Backend: Express 4.21, TypeScript 5.5+, @google/genai SDK 1.0, Zod validation, Winston logging, Helmet security
  • AI Models: Gemini 3 Pro Preview for ALL features (decomposition, simulation, chat, vision, audio)
  • Infrastructure: Node.js 20+, VPS deployment with Nginx, PM2, Let's Encrypt SSL

Challenges we ran into

1. Gemini 3 Pro Authentication Complexity Gemini 3 Pro requires Vertex AI authentication, not simple API keys. We spent significant time understanding the OAuth2 flow with service accounts and combining it with API key authentication for the SDK.

Solution: Implemented dual authentication with vertexai: true flag and proper service account configuration in the @google/genai SDK.

2. Thinking Mode + Grounding Compatibility We discovered that Gemini 3's High Thinking Mode and Google Search Grounding cannot use responseSchema simultaneously they return 400 errors.

Solution: Switched to responseMimeType: 'text/plain' and implemented robust JSON parsing with regex extraction and multi-layer fallbacks.

3. Stateful Reasoning Across Requests LLMs are stateless by design, but cascade analysis requires remembering prior conclusions.

Solution: Created the Thought Signature Protocol a SHA-256 hashing mechanism that creates reasoning continuity tokens passed between API calls, cached in memory.

4. Real-Time Cascade Visualization Animating failure propagation along graph edges in real-time while maintaining smooth 60fps performance on both desktop and mobile.

Solution: Custom SVG pulse edge components with Framer Motion, optimized with React's useMemo and useCallback. Responsive viewport detection for mobile-friendly zoom levels.

5. Context-Aware Chat Integration Building a chat assistant that truly understands the current state of the analysis—not just answering generic questions.

Solution: Built a comprehensive context injection system that passes the current graph, simulation results, reports, selected text, and user activity to every chat request. Uses Gemini 3 Pro Preview for high-quality, context-aware responses.

Accomplishments that we're proud of

What we learned

  1. Gemini 3 Pro is incredibly powerful when you push beyond chat interfaces into structured reasoning tasks
  2. Google Search Grounding transforms outputs from generic to genuinely useful real-world recommendations
  3. Visual storytelling matters - Showing cascades animate tells a story that static reports never could
  4. Stateful AI requires creative solutions - The Thought Signature Protocol is our answer to stateless limitations
  5. Single model simplicity - Using Gemini 3 Pro Preview for everything ensures consistent quality across all features
  6. Mobile-first matters - Responsive design with viewport detection ensures the app works on any device

What's next for CollapseMAP

  • PDF Document Upload - Extract systems from architecture documents
  • Real-Time Monitoring Integration - Connect to live dashboards for continuous fragility assessment
  • Collaborative Editing - Multi-user graph editing with real-time sync
  • Enterprise API - Allow integration with ServiceNow, Jira, PagerDuty
  • Natural Language Commands - Use chat to control the app ("simulate TSMC failure", "generate report")

Built With

  • express.js-4.21
  • framer-motion-11
  • gemini-3-pro-preview
  • google-search-grounding
  • google/genai-sdk
  • helmet
  • high-thinking-mode
  • lucide-icons
  • next.js-16.1
  • node.js-20
  • react-18.3
  • tailwind-css-3.4
  • typescript-5.5
  • vertex-ai
  • winston
  • xyflow/react-(reactflow)
  • zod
  • zustand-5
Share this project:

Updates