How ranchia/next-ai-draw-io works
Next AI Draw.io is a web and desktop-capable application for creating and editing draw.io diagrams through AI chat, with document/image inputs, diagram validation, history, templates, and an MCP server for agent clients. The main workflow is a user prompt or uploaded material in the chat workspace, streamed AI assistance, diagram operations in the editor, then validation and save/history. The graph combines sampled call evidence with README-documented capabilities; links for unsampled subsystems are marked dashed and unverified.
Main entry points: chat-panel.tsx Chat workspace · route.ts Chat orchestration · diagram-context.tsx Diagram context · ai-providers.ts AI providers
Components 22
Chat workspace
- Chat workspace
components/chat-panel.tsx - Prompt and uploads
components/chat-input.tsx - Chat messages
components/chat-message-display.tsx - File extraction
lib/use-file-processor.tsx
Diagram editing
- Diagram context
contexts/diagram-context.tsx - Diagram operations
hooks/use-diagram-tool-handlers.ts - Diagram validation
app/api/validate-diagram/route.ts - Validation display
components/chat/ValidationCard.tsx
AI services
- Chat orchestration
app/api/chat/route.ts - AI providers
lib/ai-providers.ts - Model configuration
lib/server-model-config.ts - Provider verification
app/api/validate-model/route.ts
State and integrations
- Session manager
hooks/use-session-manager.ts - Session history
lib/session-storage.ts - Prompt templates
components/chat/TemplatePanel.tsx - Template storage
lib/template-storage.ts - MCP server
packages/mcp-server/src/index.ts - MCP diagram tools
packages/mcp-server/src/diagram-operations.ts
Other components
- Diagram author
- draw.io editor
- LLM services
- MCP agent client
Connections 24
- Diagram author → Chat workspace: uses
README.md - Chat workspace → Prompt and uploads: renders
components/chat-panel.tsx - Chat workspace → Chat messages: renders
components/chat-panel.tsx - Prompt and uploads → File extraction: extracts files
- Chat workspace → Chat orchestration: sends prompts
- Chat orchestration → AI providers: selects model
app/api/chat/route.ts - Chat orchestration → Model configuration: looks up model
app/api/chat/route.ts - AI providers → LLM services: invokes model
- LLM services → Chat orchestration: streams response
- Chat workspace → Session manager: manages sessions
components/chat-panel.tsx - Session manager → Session history: loads and saves
hooks/use-session-manager.ts - Chat workspace → Prompt templates: offers templates
- Prompt templates → Template storage: stores templates
- Chat workspace → Diagram context: hosts editor state
app/[lang]/page.tsx - Diagram context → draw.io editor: loads and exports
contexts/diagram-context.tsx - Diagram operations → Diagram context: reads diagram XML
hooks/use-diagram-tool-handlers.ts - Diagram operations → Diagram validation: requests validation
- Diagram validation → AI providers: gets validation model
app/api/validate-diagram/route.ts - Chat messages → Validation display: shows results
- MCP agent client → MCP server: connects via MCP
README.md - MCP server → MCP diagram tools: exposes tools
- MCP diagram tools → draw.io editor: updates diagram
- Diagram author → Provider verification: tests provider
- Provider verification → LLM services: checks connectivity
app/api/validate-model/route.ts