A powerful, feature-rich web-based ERD (Entity Relationship Diagram) editor built with Next.js, React Flow, and modern web technologies. Designed for database architects and developers to visualize, design, and export database schemas with comprehensive SQL support.
- Interactive Canvas with zoom, pan, and minimap navigation
- Drag-and-drop table and column management
- Real-time validation with visual indicators
- Dark/Light theme support with smooth transitions
- Responsive design for desktop and tablet use
- Complete CRUD operations for tables and columns
- Advanced column properties: data types, constraints, defaults, comments
- Index management (UNIQUE, FULLTEXT, SPATIAL)
- Table properties: engine, collation, comments
- Foreign key relationships with visual edge connections
- SQL Import: Upload
.sqlfiles to automatically generate ERDs - Multi-dialect support: PostgreSQL, MySQL, SQLite
- SQL Export: Generate clean, production-ready SQL scripts
- Forward engineering: Convert diagrams to database schemas
- Schema validation with intelligent suggestions
- Lazy rendering for large schemas (100+ tables)
- Viewport culling for optimal performance
- Table grouping and clustering
- Background layout processing
- Real-time performance monitoring
- Multiple formats: PNG, SVG, PDF, Markdown
- High-resolution exports with customizable quality
- Schema documentation with detailed table information
- Selective exports (selected tables only)
- Professional-quality output for presentations
- Undo/Redo functionality with full history stack
- Auto-save to localStorage every 30 seconds
- Version snapshots with visual management
- Import/Export diagram state as JSON
- Keyboard shortcuts for power users
- Comprehensive validation engine for schema quality
- Real-time linting with visual feedback
- Intelligent suggestions for optimization
- Naming convention checks
- Performance recommendations
- Frontend: Next.js 16.1.2 with App Router
- Language: TypeScript 5
- Styling: Tailwind CSS 4
- State Management: Zustand 5.0.10
- Diagram Engine: React Flow 11.11.4
- Layout Algorithm: Dagre.js 0.8.5
- SQL Parsing: sql-parser-cst 0.38.2
- UI Components: Radix UI, Lucide React
- Data Fetching: TanStack React Query 5.90.17
- Export: html2canvas 1.4.1, jsPDF 4.0.0
- Theme: next-themes 0.4.6
- Node.js 18+
- npm, yarn, pnpm, or bun
docker build -t erd-editor .
docker run -p 3000:3000 erd-editor- Clone the repository:
git clone <repository-url>
cd erd-editor- Install dependencies:
npm install
# or
yarn install
# or
pnpm install
# or
bun install- Run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev-
Open your browser and navigate to http://localhost:3000
-
Start designing your database schema!
- Add Tables: Click "Add Table" in the toolbar or right-click on the canvas
- Edit Columns: Click on a table to open the property panel and add columns
- Create Relationships: Drag from a column to another table to create foreign keys
- Set Properties: Use the property panel to configure advanced settings
- Validate: Enable validation to check for schema issues
- Export: Use the export panel to generate SQL or documentation
- Click "Import SQL" in the toolbar
- Upload a
.sqlfile or drag-and-drop it onto the import panel - Review the parsed schema and detected relationships
- Click "Generate ERD" to create the diagram
- Continue editing as needed
Ctrl+Z: UndoCtrl+Y/Ctrl+Shift+Z: RedoCtrl+S: Save to localStorageCtrl+O: Load from localStorageCtrl+A: Select all nodesDelete/Backspace: Delete selected nodesEscape: Clear selection
src/
βββ app/ # Next.js App Router
β βββ layout.tsx # Root layout with providers
β βββ globals.css # Global styles
β βββ favicon.ico # App icon
βββ components/
β βββ editor/ # ERD editor components
β β βββ canvas.tsx # Main diagram canvas
β β βββ toolbar.tsx # Editor toolbar
β β βββ unified-toolbar.tsx # Enhanced toolbar with controls
β β βββ bottom-toolbar.tsx # Bottom action toolbar
β β βββ layout-controls.tsx # Layout management
β β βββ context-menu.tsx # Right-click context menu
β β βββ export-button.tsx # Quick export functionality
β β βββ nodes/ # Custom node components
β β β βββ table-node.tsx # Table node component
β β β βββ group-node.tsx # Table grouping node
β β βββ edges/ # Custom edge components
β β β βββ database-relationship-edge.tsx # Relationship edges
β β βββ property-panel.tsx # Sidebar property editor
β β βββ validation-panel.tsx # Validation interface
β β βββ sql-export-panel.tsx # SQL export interface
β β βββ sql-import-panel.tsx # SQL import interface
β β βββ export-panel.tsx # Export options panel
β β βββ history-panel.tsx # Version history management
β β βββ performance-panel.tsx # Performance monitoring
β β βββ suggestions-panel.tsx # AI suggestions
β β βββ reactflow-enhancements.css # Custom React Flow styles
β βββ providers.tsx # Global React providers
β βββ ui/ # Reusable UI components
βββ lib/
β βββ layout-engine.ts # Dagre layout integration
β βββ performance-engine.ts # Performance optimization
β βββ export-engine.ts # Export functionality
β βββ store/
β βββ use-diagram-store.ts # Zustand state management
The ERD editor includes advanced performance features for handling large schemas:
- Lazy Rendering: Only renders visible tables in the viewport
- Table Grouping: Automatically clusters related tables
- Background Processing: Non-blocking layout calculations
- Memory Management: Efficient state management and cleanup
Comprehensive schema validation with real-time feedback:
- Schema Validation: Missing primary keys, data type issues
- Naming Validation: Duplicate names, convention violations
- Integrity Validation: Circular dependencies, orphaned foreign keys
- Performance Validation: Unindexed foreign keys, optimization suggestions
- Normalization: Redundancy detection and decomposition suggestions
The parser supports multiple SQL dialects with automatic detection:
- PostgreSQL: Advanced data types, constraints, and extensions
- MySQL: Engine types, character sets, and MySQL-specific features
- SQLite: Lightweight database with standard SQL features
- PNG: High-resolution raster images with customizable quality
- SVG: Vector graphics with editable layers
- PDF: Professional documents with automatic layout
- Markdown: Structured documentation with table details
- PDF: Formatted documentation with headers and styling
- SQL Scripts: Production-ready database schemas
- Include/exclude edge labels and column details
- Customizable background colors
- Selective table exports
- Quality and scale controls
We welcome contributions! Here's how to get started:
- Fork the repository and create your feature branch
- Set up your development environment (see Getting Started)
- Make your changes following our code style guidelines
- Test thoroughly:
npm run lint # Check code quality npm run build # Ensure production build works
- Commit your changes using conventional commits:
git commit -m 'feat: add amazing feature' - Push to your fork and open a Pull Request
- TypeScript for type safety and better DX
- ESLint with Next.js configuration for code quality
- Tailwind CSS for consistent styling
- Conventional Commits for clear commit messages
- Component-first architecture with clear separation of concerns
- π¨ UI/UX improvements and new components
- π§ Performance optimizations for large schemas
- π Additional export formats and integrations
- π Enhanced validation rules and suggestions
- π Internationalization support
- π± Mobile responsiveness improvements
npm run dev # Start development server (http://localhost:3000)
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintThe project uses modern tooling for optimal development experience:
- Babel React Compiler: Experimental React compiler for performance
- ESLint with Next.js Config: Code quality and consistency
- Tailwind CSS v4: Latest utility-first CSS framework
- TypeScript: Type safety and better developer experience
- TypeScript for type safety
- ESLint for code quality
- Tailwind CSS for styling
- Conventional commits for messages
Made with β€οΈ by the database community
Star β this repo if it helped you design better databases!
