Skip to content

omkarbhad/graphini

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

104 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Graphini

Graphini

AI-powered diagram editor where every diagram is code β€” describe it, render it, version it, self-host it.

Why Β· Features Β· Quick Start Β· Architecture Β· API Β· Roadmap

SvelteKit TypeScript Mermaid Vercel AI SDK Supabase Drizzle Tailwind v4 Docker License

Graphini interface

Generated microservices architecture


✨ Why Graphini?

Every AI diagramming tool hits the same wall: the output is a picture. You can't diff it, you can't version it, you can't regenerate it from the source of truth. Graphini is different because every diagram is a Mermaid / Structurizr text artifact β€” so it lives in git, diffs in PRs, and renders deterministically every time.

  • Diagrams-as-code, not canvas blobs. Output is Mermaid (flowchart, sequence, ER, state, class, gitgraph…) or Structurizr DSL β€” plain text you can check in.
  • Real multi-provider AI. Built on the Vercel AI SDK with OpenAI, Anthropic, OpenRouter, and Gemini. Swap providers without code changes.
  • Cloud architecture, done right. AWS icon pack is built into the bundle via a pre-build script, so your architecture diagrams use real service icons β€” not generic boxes.
  • Memory that sticks. User memories let Graphini learn your naming conventions, preferred diagram style, and domain vocabulary across sessions.
  • Self-hostable. Docker, Node adapter, static adapter, or Vercel β€” pick your deployment. No lock-in.

Unlike canvas-based AI tools like Excalidraw-plus-plugins or closed-format drag-drop editors, Graphini produces text-first diagrams you own, version, and re-render forever β€” with a workspace, file persistence, and a proper API on top.


πŸ“‘ Table of Contents

Click to expand

πŸ“ Purpose-Built for Diagrams-as-Code (vs Alternatives)

There are plenty of ways to make a diagram with AI. None of them do the job Graphini does, because each was built for a different workflow:

Tool What it answers Where Graphini differs
Mermaid Live Editor "I already wrote Mermaid, render it" No AI β€” you write the DSL by hand. Graphini generates and iterates it for you.
ChatGPT / Claude "make me a diagram" "One-shot, throwaway diagram" No persistence, no memories, no workspace, no files, no Structurizr, no AWS icons, no API.
Excalidraw + AI plugins "Sketch it out visually" Canvas-blob output β€” not text, not versionable, not regeneratable from source.
draw.io / Lucidchart "Drag-and-drop corporate diagrams" Manual, closed-format, no AI-native editing loop.
Eraser.io "Paid hosted AI diagrams" Closed-source, closed-format, single-provider. Graphini is open-source, self-hostable, multi-provider.
Structurizr Lite "C4 architecture diagrams from DSL" No AI authoring, no chat loop. Graphini speaks Structurizr and Mermaid in the same workspace.
Graphini (this project) "Describe what I want β†’ get versionable diagram code β†’ iterate it with AI β†’ ship it in git." Diagrams-as-code Β· multi-provider AI Β· memories Β· workspace Β· files Β· AWS icons Β· Structurizr Β· self-host

Why a generic "AI + Mermaid" wrapper would miss the point

You could glue GPT to Mermaid Live Editor in an afternoon. Graphini does seven things on top that a wrapper does not:

  1. Multi-DSL, not just Mermaid. The structurizr feature adds full C4 model support β€” so architects get real C1/C2/C3 diagrams, not just flowcharts with rounded corners.
  2. AWS icon pack baked into the build. scripts/build-aws-icon-pack.mjs runs on predev / prebuild and ships real AWS service icons into the bundle. Your "architecture" diagrams look like architecture.
  3. Persistent files, not ephemeral chats. Projects have real files (see add-files-persistence.sql), so a single diagram can grow across sessions instead of getting lost when a chat resets.
  4. User memories. The user_memories table lets the AI remember your naming conventions, preferred layout direction, and domain vocabulary β€” so you don't re-explain "we always use svc_* for services" every session.
  5. Workspace + admin panel. Multi-user workspace, admin settings, app settings β€” it's a product, not a demo. See src/routes/workspace and src/routes/admin.
  6. A real, documented API. api/openapi.yaml spec. Build your own integrations or drive Graphini from CI.
  7. Provider-agnostic via Vercel AI SDK. Swap OpenAI β†’ Anthropic β†’ OpenRouter β†’ Gemini in settings. No hard-coded provider, no vendor lock-in.

Honest trade-offs

Graphini is not a free-form whiteboard. If you want pixel-perfect hand-drawn canvases with stickies and arrows-that-bend-where-you-want, use Excalidraw. If you want a corporate visio-style drag-drop environment with a thousand stencils, use Lucidchart or draw.io. If you just need to render Mermaid you already wrote, use Mermaid Live Editor.

Use Graphini when you want your diagrams to live in git β€” versionable, diffable, AI-editable, and rebuildable β€” with real cloud icons, real C4 support, and a real API around them.


πŸ”­ Features

πŸ—£ Natural Language β†’ Diagrams

  • Plain-English prompts turn into Mermaid or Structurizr DSL
  • AI-powered editing β€” modify, expand, restyle, or refactor with chat commands
  • Real-time preview β€” diagram updates as the code streams

πŸ“ Diagrams as Code

  • Mermaid β€” flowcharts, sequence, class, state, ER, gitgraph, C4, mindmap, timeline, and more
  • Structurizr DSL β€” full C4 model support for software architecture
  • Text-first output β€” every diagram is a plain-text artifact you can version-control

☁️ Cloud Architecture

🧠 User Memories

  • Per-user memory table so the AI remembers your conventions across sessions
  • Naming patterns, preferred direction, domain vocabulary β€” learned once, reused forever

πŸ“ Files & Workspaces

  • Persistent files β€” multi-file projects, not single-diagram toys
  • Workspace with dashboard, edit, and view modes
  • Admin panel β€” user management, app settings, provider config

πŸ”Œ Multi-Provider AI

  • Built on the Vercel AI SDK (ai, @ai-sdk/anthropic, @ai-sdk/openai)
  • Supports OpenAI Β· Anthropic Β· OpenRouter Β· Gemini
  • Swap providers in settings β€” no code change, no redeploy

πŸ” Auth & Storage

  • Supabase Authentication
  • Drizzle ORM with PostgreSQL β€” typed migrations, checked-in schemas
  • Performance indexes SQL shipped in database/

🌐 API & Self-Hosting

  • Documented API via api/openapi.yaml
  • Docker + docker-compose self-hosting
  • Node adapter, static adapter, or Vercel adapter β€” pick your deployment
  • Nginx reverse-proxy config included

πŸ§ͺ Testing

  • Vitest for unit tests
  • Playwright for E2E
  • Coverage via @vitest/coverage-v8

🧰 Tech Stack

Layer Technology
Framework SvelteKit 2 Β· Vite Β· TypeScript 5
Styling Tailwind CSS v4 Β· bits-ui Β· @tailwindcss/typography
Icons Lucide Β· Iconify Β· Material Symbols Β· MDI Β· AWS icon pack
Diagram Engines Mermaid.js Β· Structurizr DSL
AI Gateway Vercel AI SDK β€” OpenAI Β· Anthropic Β· OpenRouter Β· Gemini
Auth Supabase Authentication
Database PostgreSQL via Drizzle ORM
Testing Vitest Β· Playwright
Linting ESLint 9 Β· Prettier Β· eslint-plugin-svelte Β· eslint-plugin-tailwindcss
Deployment Vercel Β· Node adapter Β· Static adapter Β· Docker Β· Netlify Β· Nginx

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SvelteKit (Vite + TS + Tailwind v4)                        β”‚
β”‚                                                              β”‚
β”‚   Routes:  dashboard Β· workspace Β· edit Β· view Β· canvas     β”‚
β”‚            admin Β· api                                       β”‚
β”‚                                                              β”‚
β”‚   Features:                                                  β”‚
β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚
β”‚     β”‚  chat  β”‚ β”‚diagram β”‚ β”‚ structurizr β”‚ β”‚ editor  β”‚       β”‚
β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SvelteKit API routes  (server hooks, OpenAPI spec)         β”‚
β”‚                                                              β”‚
β”‚   β”œβ”€β”€ Vercel AI SDK  ──▢  OpenAI Β· Anthropic Β· OR Β· Gemini  β”‚
β”‚   β”œβ”€β”€ Drizzle ORM    ──▢  PostgreSQL                        β”‚
β”‚   β”‚                          β€’ users Β· files Β· memories     β”‚
β”‚   β”‚                          β€’ app_settings Β· admin_settingsβ”‚
β”‚   └── Supabase Auth  ◀──  session + RLS                     β”‚
β”‚                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key design decisions

  • πŸ“ Text artifacts, not canvas blobs. Diagrams are Mermaid/Structurizr strings end-to-end β€” they round-trip through git cleanly.
  • 🧱 Feature-scoped modules. src/lib/features/{chat,diagram,editor,structurizr,history,icons} β€” each feature owns its stores, components, and types.
  • 🎨 Design tokens in code. src/lib/design-tokens.ts and src/lib/themes/ β€” swappable at runtime.
  • πŸ”Œ Vercel AI SDK as the single LLM surface. Provider swap = settings change, not refactor.
  • πŸ§ͺ Serious test posture. Vitest for units, Playwright for E2E, coverage gates in CI.
  • 🐳 Multi-adapter deployment. Node for self-hosters, static for CDN, Vercel for zero-config, Docker for everything else.

πŸš€ Quick Start

Prerequisites

  • Node.js 20+
  • pnpm 9+
  • PostgreSQL database (local or hosted)
  • (optional) Supabase project for auth

Install

git clone https://github.com/omkarbhad/graphini.git
cd graphini
pnpm install

Run

pnpm dev            # Vite dev server
pnpm dev:node       # With Node adapter (self-host preview)
pnpm build          # Production build
pnpm preview        # Preview production build

Open http://localhost:3000.

Database

Apply schema and migrations from database/:

psql "$DATABASE_URL" -f database/schema.sql
psql "$DATABASE_URL" -f database/v2-schema.sql
psql "$DATABASE_URL" -f database/add-app-settings.sql
psql "$DATABASE_URL" -f database/add-admin-settings.sql
psql "$DATABASE_URL" -f database/add-files-persistence.sql
psql "$DATABASE_URL" -f database/add-files-support.sql
psql "$DATABASE_URL" -f database/add-user-memories.sql
psql "$DATABASE_URL" -f database/add-gemini-provider.sql
psql "$DATABASE_URL" -f database/performance-indexes.sql

🐳 Docker

docker-compose up --build

A Dockerfile, docker-compose.yml, and nginx.conf are shipped in the repo β€” self-host on any VPS in under five minutes.


πŸ”‘ Configuration

LLM providers and database credentials can be configured via the in-app Settings panel or environment variables. Typical .env:

# Database
DATABASE_URL=postgresql://user:pass@localhost:5432/graphini

# Supabase (auth)
PUBLIC_SUPABASE_URL=https://your-project.supabase.co
PUBLIC_SUPABASE_ANON_KEY=eyJ...
SUPABASE_SERVICE_ROLE_KEY=eyJ...

# AI providers β€” set whichever you use
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
OPENROUTER_API_KEY=sk-or-...
GEMINI_API_KEY=...

🌐 API Reference

Graphini ships an OpenAPI 3 spec at api/openapi.yaml. Import it into Postman, Insomnia, or any OpenAPI client to drive Graphini from your own tools or CI.


πŸ“ Project Structure

graphini/
β”œβ”€β”€ api/
β”‚   └── openapi.yaml                # Public OpenAPI spec
β”œβ”€β”€ database/                       # SQL schema + migrations
β”‚   β”œβ”€β”€ schema.sql
β”‚   β”œβ”€β”€ v2-schema.sql
β”‚   β”œβ”€β”€ add-files-persistence.sql
β”‚   β”œβ”€β”€ add-user-memories.sql
β”‚   β”œβ”€β”€ add-gemini-provider.sql
β”‚   β”œβ”€β”€ add-admin-settings.sql
β”‚   β”œβ”€β”€ add-app-settings.sql
β”‚   └── performance-indexes.sql
β”œβ”€β”€ docs/                           # Additional docs
β”œβ”€β”€ scripts/
β”‚   └── build-aws-icon-pack.mjs     # Pre-build AWS icon bundling
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app.css Β· app.html Β· hooks.server.ts
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ components/             # UI components
β”‚   β”‚   β”œβ”€β”€ features/
β”‚   β”‚   β”‚   β”œβ”€β”€ chat/               # AI chat loop
β”‚   β”‚   β”‚   β”œβ”€β”€ diagram/             # Mermaid rendering + store
β”‚   β”‚   β”‚   β”œβ”€β”€ editor/              # Code editor surface
β”‚   β”‚   β”‚   β”œβ”€β”€ structurizr/         # C4 model / Structurizr DSL
β”‚   β”‚   β”‚   β”œβ”€β”€ history/             # Per-file history
β”‚   β”‚   β”‚   └── icons/               # Icon pack loaders
β”‚   β”‚   β”œβ”€β”€ server/                  # Server-only utilities
β”‚   β”‚   β”œβ”€β”€ stores/                  # Svelte stores
β”‚   β”‚   β”œβ”€β”€ themes/                  # Theming
β”‚   β”‚   β”œβ”€β”€ design-tokens.ts
β”‚   β”‚   β”œβ”€β”€ constants.ts
β”‚   β”‚   └── util/
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ dashboard/
β”‚   β”‚   β”œβ”€β”€ workspace/
β”‚   β”‚   β”œβ”€β”€ edit/
β”‚   β”‚   β”œβ”€β”€ view/
β”‚   β”‚   β”œβ”€β”€ canvas/
β”‚   β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   └── api/                     # SvelteKit API endpoints
β”‚   └── types/
β”œβ”€β”€ static/                          # Logo, demo images, favicons, brand, AWS icons
β”œβ”€β”€ tests/                           # E2E test suites
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ netlify.toml
β”œβ”€β”€ nginx.conf
β”œβ”€β”€ svelte.config.js
β”œβ”€β”€ vite.config.js
β”œβ”€β”€ drizzle.config.ts
β”œβ”€β”€ playwright.config.ts
└── tailwind.config.js

πŸ§ͺ Testing

pnpm test              # Unit + E2E
pnpm test:unit         # Vitest
pnpm test:unit:ui      # Vitest UI
pnpm test:unit:coverage
pnpm test:e2e          # Playwright
pnpm test:e2e:ui       # Playwright UI
pnpm test:e2e:debug    # Playwright debug

πŸ—Ί Roadmap

  • Mermaid diagram generation from natural language
  • Structurizr DSL / C4 model support
  • AWS icon pack
  • Multi-provider AI (OpenAI Β· Anthropic Β· OpenRouter Β· Gemini)
  • User memories across sessions
  • File persistence + workspace
  • Admin panel
  • Public OpenAPI spec
  • Docker self-host
  • Realtime multi-user collaboration on a single diagram
  • Azure + GCP icon packs
  • Export to PNG / SVG / PDF with one click
  • VS Code extension
  • Diagram diffing in PRs (GitHub App)
  • Template gallery (system design, onboarding, infra, CI/CD)

Got an idea? Open an issue or start a discussion.


🀝 Contributing

Contributions are what make open source amazing. Any contribution you make is greatly appreciated.

  1. Fork the project
  2. Create your feature branch β€” git checkout -b feature/amazing-feature
  3. Commit your changes β€” git commit -m 'Add amazing feature'
  4. Push to the branch β€” git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ‘‰ New here? Look for good first issue labels.


πŸ“œ License

MIT Β© Omkar Bhad


πŸ™ Acknowledgments


Built with ❀️ for anyone who believes diagrams belong in git.