Diagram as Code

Create diagrams as code

Flowcharts, sequence diagrams, ER models, C4 architecture — all defined as Mermaid & PlantUML code. AI generates the code from plain English. Version controlled, diff-friendly, and embeddable anywhere.

What is diagram as code?

Diagram as code means defining diagrams using text-based syntax — Mermaid, PlantUML, or similar formats — rather than graphical drag-and-drop tools. You write a few lines of structured text, and a renderer converts it into a visual diagram. The text source is what you store, version, and share.

This approach is popular among software engineers because it integrates naturally into existing workflows: store diagram code in Git, review changes in pull requests, render in CI/CD pipelines, and embed directly in Markdown documentation. GitHub and GitLab render Mermaid blocks natively in Markdown files.

Cybewave Studio takes this further with AI-powered generation. Instead of memorizing Mermaid or PlantUML syntax, describe your diagram in plain English and the AI generates correct, well-structured diagram code. Use the built-in editor to refine, then export the code to your architecture repository.

Diagram types you can create as code

From simple flowcharts to complex C4 architecture models.

Flowcharts

Decision trees, process flows, and state machines. Mermaid graph syntax with conditional branching and subgraphs.

Mermaid

Sequence diagrams

API call flows, authentication handshakes, and distributed transactions. Lifelines, activations, and async messages.

Mermaid / PlantUML

Entity-Relationship

Database schema design with tables, columns, foreign keys, and cardinality. Generate ERDs from schema descriptions.

Mermaid

C4 model diagrams

Context, Container, Component, and Code views. Structured architecture at multiple levels of abstraction.

Mermaid / PlantUML

Class diagrams

Object-oriented design with classes, interfaces, inheritance, and associations. UML-compliant notation.

Mermaid / PlantUML

Component diagrams

Service boundaries, modules, packages, and dependency relationships. PlantUML component notation.

PlantUML

Deployment diagrams

Infrastructure topology: servers, containers, load balancers, and cloud regions. Map physical and virtual environments.

PlantUML

Activity diagrams

Business processes, CI/CD pipelines, and workflow automation. Parallel branches, decision nodes, and swimlanes.

PlantUML

How AI generates diagram code

No syntax memorization needed. Describe, generate, refine, export.

01

Describe what you need

Tell the AI what diagram you need in plain English — a sequence flow, architecture overview, ER model, or class diagram. Be specific about components and relationships.

02

AI generates the code

Get syntactically correct Mermaid or PlantUML source code. Not a screenshot — actual code you can edit, version, and commit.

03

Edit and refine

Use the built-in editor with live preview, or ask the AI to make changes in natural language. Add nodes, fix relationships, change styling.

04

Export anywhere

Copy the code into your repo, render as PNG/SVG, or download a project scaffold. Works with GitHub, GitLab, Notion, and any Markdown renderer.

Diagram code examples

Real syntax that renders into professional diagrams.

Mermaid — Sequence Diagram

API authentication flow

sequenceDiagram
  Client->>API Gateway: POST /login
  API Gateway->>Auth Service: Validate credentials
  Auth Service->>Database: Query user
  Database-->>Auth Service: User record
  Auth Service-->>API Gateway: JWT token
  API Gateway-->>Client: 200 OK + token

PlantUML — Component Diagram

Microservice architecture

@startuml
package "API Layer" {
  [API Gateway]
  [Auth Service]
}
package "Business Logic" {
  [Order Service]
  [Payment Service]
}
database "PostgreSQL" as db
[API Gateway] --> [Auth Service]
[API Gateway] --> [Order Service]
[Order Service] --> [Payment Service]
[Order Service] --> db
@enduml

Diagram as code vs drawing tools

Diagram creationDrag boxes, draw arrows, align manuallyWrite or generate text, render automatically
Version controlExport image, hope someone saves itCommit to Git, full history and blame
ConsistencyEvery person draws differentlySame code = same diagram, every time
SpeedMinutes to hours positioning elementsSeconds to generate, instant rendering
CollaborationShare links, hope sync worksGit branches, pull request reviews
DocumentationDiagrams separate from docsEmbed directly in Markdown, auto-render

Frequently asked questions

What is the easiest diagram-as-code tool?

Cybewave Studio lets you skip learning syntax entirely. Describe your diagram in plain English and AI generates Mermaid or PlantUML code. For manual editing, Mermaid has a gentler learning curve than PlantUML.

Can I embed diagram code in my README?

Yes. GitHub and GitLab render Mermaid code blocks natively in Markdown files. Wrap your code in ```mermaid fences and it renders as a diagram in your README, wiki, or any .md file.

Which format should I choose — Mermaid or PlantUML?

Use Mermaid for GitHub/GitLab projects, simpler diagrams, and Markdown embedding. Use PlantUML for complex UML (deployment, component, activity diagrams) and enterprise documentation.

Can I convert between Mermaid and PlantUML?

Cybewave supports both formats. You can ask the AI to regenerate a diagram in the other format, or edit the source directly in the built-in editor.

Is diagram as code free?

Mermaid and PlantUML are open-source formats. Cybewave Studio offers a free tier with 50 AI credits per month for AI-powered generation. No credit card required.

Start creating diagrams as code

Free to start. 50 AI credits/month. No credit card required.

Get started for free →

Or explore pricing plans for teams and professionals.