|
| 1 | +# Nuxt AI Draw.io |
| 2 | + |
| 3 | +[](https://ui.nuxt.com) |
| 4 | + |
| 5 | +AI-powered diagram editor that lets you create and edit draw.io diagrams using natural language. Built with [Nuxt 4](https://nuxt.com), [Nuxt UI 4](https://ui.nuxt.com), and [AI SDK v5](https://sdk.vercel.ai). |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- **AI-Powered Diagram Generation** - Create flowcharts, system architectures, ER diagrams, mind maps, and more using natural language |
| 10 | +- **Embedded Draw.io Editor** - Full-featured diagram editor with real-time preview |
| 11 | +- **Multiple AI Providers** - Support for OpenAI, Anthropic, Google AI, Azure, AWS Bedrock, OpenRouter, DeepSeek, and SiliconFlow |
| 12 | +- **Prompt Caching** - AWS Bedrock prompt caching for Claude models to reduce costs |
| 13 | +- **Reasoning Models** - Support for thinking/reasoning models (Claude, Gemini, OpenAI o1/o3) |
| 14 | +- **Dark/Light Mode** - Automatic theme detection with manual toggle |
| 15 | +- **Close Protection** - Prevent accidental page close with unsaved diagrams |
| 16 | +- **Export Options** - Save as PNG, XML (.drawio), or Mermaid format |
| 17 | +- **Token Usage Display** - See input/output token counts for each request |
| 18 | +- **Access Code Protection** - Optional access code authentication |
| 19 | + |
| 20 | +## Tech Stack |
| 21 | + |
| 22 | +| Category | Technology | |
| 23 | +|----------|------------| |
| 24 | +| Framework | Nuxt 4 + Vue 3 | |
| 25 | +| UI | Nuxt UI 4 (Tailwind CSS) | |
| 26 | +| AI SDK | Vercel AI SDK v5 | |
| 27 | +| Diagram Engine | Draw.io (embedded iframe) | |
| 28 | +| State Management | Vue composables | |
| 29 | +| Icons | Lucide | |
| 30 | + |
| 31 | +## Quick Start |
| 32 | + |
| 33 | +### 1. Install Dependencies |
| 34 | + |
| 35 | +```bash |
| 36 | +pnpm install |
| 37 | +``` |
| 38 | + |
| 39 | +### 2. Configure Environment |
| 40 | + |
| 41 | +Copy `.env.example` to `.env` and configure your AI provider: |
| 42 | + |
| 43 | +```env |
| 44 | +# AI Provider (openai, anthropic, google, bedrock, azure, openrouter, deepseek, siliconflow) |
| 45 | +AI_PROVIDER=openai |
| 46 | +
|
| 47 | +# Model ID |
| 48 | +AI_MODEL=gpt-4o |
| 49 | +
|
| 50 | +# API Key (based on provider) |
| 51 | +OPENAI_API_KEY=sk-... |
| 52 | +``` |
| 53 | + |
| 54 | +See `.env.example` for all available configuration options. |
| 55 | + |
| 56 | +### 3. Start Development Server |
| 57 | + |
| 58 | +```bash |
| 59 | +pnpm dev |
| 60 | +``` |
| 61 | + |
| 62 | +Open [http://localhost:3000](http://localhost:3000) in your browser. |
| 63 | + |
| 64 | +## Supported AI Providers |
| 65 | + |
| 66 | +| Provider | Environment Variables | Notes | |
| 67 | +|----------|----------------------|-------| |
| 68 | +| OpenAI | `OPENAI_API_KEY` | GPT-4o, o1, o3 models | |
| 69 | +| Anthropic | `ANTHROPIC_API_KEY` | Claude 3.5/4 models | |
| 70 | +| Google | `GOOGLE_GENERATIVE_AI_API_KEY` | Gemini 2.5/3 models | |
| 71 | +| AWS Bedrock | `AWS_REGION`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` | Claude with prompt caching | |
| 72 | +| Azure OpenAI | `AZURE_API_KEY`, `AZURE_RESOURCE_NAME` | Azure-hosted models | |
| 73 | +| OpenRouter | `OPENROUTER_API_KEY` | Multi-provider routing | |
| 74 | +| DeepSeek | `DEEPSEEK_API_KEY` | DeepSeek models | |
| 75 | +| SiliconFlow | `SILICONFLOW_API_KEY` | SiliconFlow models | |
| 76 | + |
| 77 | +## Project Structure |
| 78 | + |
| 79 | +``` |
| 80 | +nuxt-ai-drawio/ |
| 81 | +├── app/ |
| 82 | +│ ├── components/ |
| 83 | +│ │ ├── ChatPanel.vue # Chat interface |
| 84 | +│ │ ├── DrawioEditor.vue # Draw.io iframe wrapper |
| 85 | +│ │ └── ... |
| 86 | +│ ├── composables/ |
| 87 | +│ │ └── useDiagram.ts # Diagram state management |
| 88 | +│ ├── utils/ |
| 89 | +│ │ └── mermaid-converter.ts # XML to Mermaid conversion |
| 90 | +│ └── pages/ |
| 91 | +│ └── index.vue # Main page (editor + chat) |
| 92 | +├── server/ |
| 93 | +│ ├── api/ |
| 94 | +│ │ ├── chat.post.ts # AI chat endpoint |
| 95 | +│ │ └── verify-access-code.post.ts |
| 96 | +│ └── utils/ |
| 97 | +│ ├── ai-providers.ts # AI provider configuration |
| 98 | +│ ├── cached-responses.ts # Response caching |
| 99 | +│ ├── diagram-tools.ts # AI tools for diagrams |
| 100 | +│ └── system-prompts.ts # System prompts |
| 101 | +└── nuxt.config.ts |
| 102 | +``` |
| 103 | + |
| 104 | +## AI Tools |
| 105 | + |
| 106 | +The AI assistant has access to three tools for diagram manipulation: |
| 107 | + |
| 108 | +1. **display_diagram** - Create a new diagram from scratch |
| 109 | +2. **edit_diagram** - Make targeted edits to existing diagrams |
| 110 | +3. **append_diagram** - Continue generating truncated output |
| 111 | + |
| 112 | +## Development |
| 113 | + |
| 114 | +```bash |
| 115 | +# Start dev server |
| 116 | +pnpm dev |
| 117 | + |
| 118 | +# Build for production |
| 119 | +pnpm build |
| 120 | + |
| 121 | +# Preview production build |
| 122 | +pnpm preview |
| 123 | + |
| 124 | +# Lint code |
| 125 | +pnpm lint |
| 126 | + |
| 127 | +# Type check |
| 128 | +pnpm typecheck |
| 129 | +``` |
| 130 | + |
| 131 | +## Credits |
| 132 | + |
| 133 | +Inspired by [Nuxt UI Chat Template](https://github.com/nuxt-ui-templates/chat) and [Next AI Draw.io](https://github.com/anthropics/next-ai-draw-io). |
| 134 | + |
| 135 | +## License |
| 136 | + |
| 137 | +MIT |
0 commit comments