Merlin is an intelligent diagram generation tool that combines the power of Large Language Models (LLMs) with Mermaid.js to create beautiful, interactive diagrams from natural language descriptions.
- AI-Powered Generation: Describe your diagram in plain English and let AI generate the Mermaid code
- Real-time Preview: See your diagrams rendered instantly as you type
- Direct Code Editing: Edit Mermaid syntax directly with syntax highlighting
- Multiple Diagram Types: Support for flowcharts, sequence diagrams, class diagrams, and more
- Example Templates: Quick-start with pre-built diagram examples
- Modern UI: Clean, dark-themed interface with responsive design
- Fast Performance: Built with Next.js 15 and Turbopack for lightning-fast development
- Software Architecture: Create system diagrams, flowcharts, and process flows
- Documentation: Generate visual documentation for your projects
- Education: Create learning materials with clear visual representations
- Business Process: Map out workflows and decision trees
- Project Planning: Visualize project structures and dependencies
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- npm, yarn, pnpm, or bun
- Ollama (for AI diagram generation)
- Install Ollama from ollama.com
- Pull the required model:
ollama pull gemma3:4b
- Start the Ollama service:
ollama serve
-
Clone the repository:
git clone https://github.com/nani-samireddy/merlin.git cd merlin -
Install dependencies:
npm install # or yarn install # or pnpm install
-
Start the development server:
npm run dev # or yarn dev # or pnpm dev
-
Open http://localhost:3000 in your browser
Natural Language Input:
Create a user registration process flowchart
Generated Mermaid Code:
flowchart TD
A[User Visits Registration] --> B[Fill Registration Form]
B --> C{Valid Information?}
C -->|Yes| D[Create Account]
C -->|No| E[Show Error Message]
D --> F[Send Confirmation Email]
E --> B
F --> G[Registration Complete]
Natural Language Input:
Show a microservices architecture with API gateway, user service, and database
Generated Output:
flowchart LR
A[Client] --> B[API Gateway]
B --> C[User Service]
B --> D[Order Service]
B --> E[Payment Service]
C --> F[User Database]
D --> G[Order Database]
E --> H[Payment Database]
You can also write Mermaid code directly:
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Action 1]
B -->|No| D[Action 2]
C --> E[End]
D --> E
The application currently supports Ollama as the LLM provider. You can configure it in:
// app/api/generate/route.ts
const {
prompt,
provider = "ollama",
options = { model: "gemma3:4b" },
} = await req.json();gemma3:4b(default) - Balanced performance and qualityllama3.2- Alternative model optioncodellama- Optimized for code generation
Create a .env.local file for custom configurations:
# Ollama Configuration
OLLAMA_BASE_URL=http://localhost:11434
DEFAULT_MODEL=gemma3:4bmerlin/
βββ app/ # Next.js app directory
β βββ api/generate/ # API endpoint for LLM generation
β βββ layout.tsx # Root layout
β βββ page.tsx # Main application page
βββ lib/ # Utility libraries
β βββ llm/ # LLM provider implementations
β βββ index.ts # Provider factory
β βββ ollama.ts # Ollama implementation
β βββ types.ts # TypeScript interfaces
βββ public/ # Static assets
βββ package.json # Project dependencies
- Next.js 15 - React framework with App Router
- TypeScript - Type-safe JavaScript
- Tailwind CSS 4 - Utility-first CSS framework
- Mermaid.js - Diagram rendering library
- Ollama - Local LLM provider
npm run build
npm startnpm run lintGenerate Mermaid diagram code from natural language description.
Request Body:
{
"prompt": "Create a login flow diagram",
"provider": "ollama",
"options": {
"model": "gemma3:4b"
}
}Response:
{
"code": "flowchart TD\n A[Login Page] --> B[Enter Credentials]\n B --> C{Valid?}\n C -->|Yes| D[Dashboard]\n C -->|No| E[Error Message]"
}We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow the existing code style (ESLint configuration)
- Write clear commit messages
- Add tests for new features
- Update documentation as needed
To add a new LLM provider:
- Create a new file in
lib/llm/ - Implement the
LLMProviderinterface - Add the provider to the factory in
lib/llm/index.ts
// lib/llm/newprovider.ts
import { LLMProvider } from "./types";
export class NewProvider implements LLMProvider {
async generate(prompt: string): Promise<string> {
// Implementation
}
}This project is licensed under the MIT License - see the LICENSE file for details.
- Mermaid.js - For the amazing diagram rendering
- Ollama - For local LLM capabilities
- Next.js - For the excellent React framework
- Tailwind CSS - For the utility-first CSS framework
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Join our community discussions
Made with β€οΈ by the Merlin team
