π Create, edit, and share beautiful Mermaid diagrams in real-time!
A powerful, modern web application that transforms your ideas into stunning diagrams with live preview and instant sharing capabilities.
- β‘ Live Preview: See your diagrams update instantly as you type
- π± Responsive Split View: Adjustable panels that work perfectly on all devices
- π¨ Syntax Highlighting: Monaco Editor with intelligent code completion
- π Fast Rendering: Debounced updates for smooth performance
- π€ Quick Sharing: Generate shareable links with URL encoding
- π Dark/Light Theme: Beautiful themes that adapt to your preference
- π Zoom & Pan: Interactive diagram navigation with mouse and touch
- πΎ Auto-Save: Your work is automatically saved in browser storage
- π One-Click Copy: Copy diagrams as SVG or share links instantly
- π Real-time Validation: Immediate feedback on syntax errors
- π± Mobile Optimized: Perfect experience on phones and tablets
- β¨οΈ Keyboard Shortcuts: Power user shortcuts for faster workflow
Before you begin, ensure you have the following installed:
- Node.js (v18.17.0 or higher)
- Bun (recommended) or npm/yarn/pnpm
- Git for version control
-
Clone the repository
git clone https://github.com/sametcn99/mermaid-viewer.git cd mermaid-viewer
-
Install dependencies
# Using Bun (recommended for fastest installation) bun install # Or using npm npm install # Or using yarn yarn install # Or using pnpm pnpm install
-
Start the development server
# Using Bun bun dev # Or using npm npm run dev # Or using yarn yarn dev # Or using pnpm pnpm dev
-
Open your browser
Navigate to http://localhost:3000 and start creating diagrams! π
graph TD
A[Start] --> B{Is it working?}
B -->|Yes| C[Great!]
B -->|No| D[Debug]
D --> B
C --> E[End]
sequenceDiagram
participant User
participant Frontend
participant API
participant Database
User->>Frontend: Create diagram
Frontend->>API: Validate syntax
API->>Database: Save diagram
Database-->>API: Success
API-->>Frontend: Confirmation
Frontend-->>User: Show result
classDiagram
class DiagramEditor {
+String content
+Boolean isValid
+updateContent(content)
+validateSyntax()
+exportSVG()
}
class DiagramViewer {
+Element svg
+render(content)
+zoom(level)
+pan(x, y)
}
DiagramEditor --> DiagramViewer : renders
Command | Description |
---|---|
bun dev |
π₯ Start development server with Turbopack |
bun build |
ποΈ Build the application for production |
bun start |
π Start the production server |
bun lint |
π Run ESLint to check code quality |
bun format |
β¨ Format code with Prettier |
graph LR
A[π Monaco Editor] --> B[β‘ Debounced Updates]
B --> C[π§ββοΈ Mermaid Parser]
C --> D[π SVG Renderer]
D --> E[π Zoom & Pan Viewer]
F[πΎ Local Storage] --> A
A --> F
G[π URL Encoding] --> A
E --> H[π€ Share Function]
H --> G
- π Editor Panel: Monaco Editor with TypeScript and Mermaid syntax highlighting
- π Diagram Panel: Real-time SVG rendering with interactive zoom and pan
- π Debounced Updates: Optimized performance with 300ms debounce
- π± Responsive Layout:
react-split
for adjustable panels on all devices - πΎ Auto-Save: Browser localStorage for persistent diagram storage
- π URL Sharing: Compressed diagram data in shareable URLs
The application supports both light and dark themes using Material-UI's theming system. Themes automatically adapt to system preferences.
Monaco Editor is configured with:
- Mermaid syntax highlighting
- Auto-completion
- Error detection
- Bracket matching
- Code folding
- Mobile: < 768px (stacked layout)
- Tablet: 768px - 1024px (adjustable split)
- Desktop: > 1024px (side-by-side split)
- β‘ Turbopack: Lightning-fast development builds
- π Debounced Rendering: Optimized diagram updates
- πΎ Efficient Storage: Compressed URL encoding with Pako
- π± Mobile Optimized: Touch-friendly interface
- π SSR Ready: Server-side rendering support
We welcome contributions from the community! Here's how you can help:
-
π΄ Fork the Project
# Click the Fork button on GitHub
-
πΏ Create your Feature Branch
git checkout -b feature/AmazingFeature
-
π» Make your Changes
# Make your awesome changes bun dev # Test locally
-
β Run Tests & Linting
bun lint bun format
-
π Commit your Changes
git commit -m 'Add some AmazingFeature'
-
π Push to the Branch
git push origin feature/AmazingFeature
-
π Open a Pull Request
- π Bug Fixes: Help us squash bugs
- β¨ New Features: Add exciting new functionality
- π Documentation: Improve our docs
- π¨ UI/UX: Enhance user experience
- β‘ Performance: Optimize for speed
- π§ͺ Testing: Add test coverage
- Follow existing code style (Prettier + ESLint)
- Write meaningful commit messages
- Add tests for new features
- Update documentation as needed
- Test on multiple browsers/devices
- Mermaid.js - For the amazing diagram rendering engine
- Monaco Editor - For the powerful code editor
- Next.js - For the excellent React framework
- Material-UI - For the beautiful component library
- Vercel - For seamless deployment and hosting
β Star this repo if you found it helpful! β