Skip to content

mouxangithub/drawdb

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

drawdb logo

drawDB

Free, simple, and intuitive database schema editor and SQL generator.

demo

πŸ“ Project Introduction

DrawDB is a powerful and user-friendly database entity relationship (DBER) editor that runs directly in your browser. Build database diagrams with a few clicks, export SQL scripts, customize your editor, and more without creating an account.

This project is based on drawdb-io/drawdb with enhancements including a backend server, SQLite database integration, and more features.

Development Note: This project was developed with the assistance of AI, using the Cursor editor for code generation and adaptation. The AI helped rewrite and enhance the original codebase, adding the backend server integration and other extended features.

πŸ“‹ What's Added

Compared to the original project, this fork adds several key features:

  • Full Backend Server: Added a server component for persistent data storage
  • SQLite Database: Integrated SQLite for diagram storage and management
  • Multi-Diagram Management: Support for creating and managing multiple diagrams
  • Internationalization: Added support for multiple languages (English/Chinese)
  • Docker Deployment: Complete Docker support for easy deployment
  • Automated Backups: Built-in database backup functionality
  • Enhanced Preview: Interactive diagram preview with zoom and pan capabilities
  • Optimized UI: Refined user interface with control panel centered at bottom and floating info panel
  • Creation Time Display: Added creation time display in both grid and table view modes
  • Advanced Filtering System: Comprehensive filtering by database type, creation time, and update time
  • Real-time Collaboration: WebSocket-based collaborative editing with user presence indicators, cursor tracking, and conflict resolution
  • Collaboration Controls: User interface components showing online collaborators, connection status, and collaborative actions
  • Offline Recovery: Pending operations queue for recovering from temporary disconnections
  • User Identity Management: Consistent user identification across sessions with color-coded avatars

✨ Core Features

  • Multi-Diagram Management: Create and manage multiple database diagrams with grid and table view modes
  • Interactive Preview: Diagram thumbnails and full-featured preview mode with drag and zoom capabilities
  • Diagram Sharing: Generate sharing links to collaborate with team members or clients
  • Collaborative Editing: Support for concurrent diagram editing with version conflict resolution
  • Real-time Presence: See who's currently viewing and editing the diagram with user avatars and status indicators
  • User Activity Detection: Automatically detect and manage inactive users in collaborative sessions
  • Operation Synchronization: All changes are instantly synchronized between all connected users
  • Internationalization: Support for multiple languages, including English and Chinese interfaces
  • Advanced Filtering: Filter diagrams by name, database type, creation date, and modification date
  • JSON Editor: Real-time JSON editing for tables, relationships, subject areas, and notes
  • Free to Use: All features completely free, no account registration required

πŸš€ Quick Start

Using Docker (Recommended)

# Pull the latest image
docker pull ghcr.io/mouxangithub/drawdb:latest

# Create necessary directories
mkdir -p server/database backups

# Run the container
docker run -d --name drawdb \
  -p 3000:3000 \
  -v $(pwd)/server/database:/app/server/database \
  -v $(pwd)/backups:/app/backups \
  ghcr.io/mouxangithub/drawdb:latest

Using Docker Compose:

services:
  drawdb:
    image: ghcr.io/mouxangithub/drawdb:latest
    container_name: drawdb
    restart: unless-stopped
    ports:
      - 3000:3000
    volumes:
      - ./server/database:/app/server/database
      - ./backups:/app/backups

Using Startup Scripts

Windows

# Run locally (without Docker, start both frontend and backend)
start.bat local

# Start development environment (using Docker)
start.bat dev

# Start production environment (using Docker)
start.bat prod

Linux/macOS

# Add execution permission
chmod +x start.sh

# Run locally (without Docker, start both frontend and backend)
./start.sh local

# Start development environment (using Docker)
./start.sh dev

# Start production environment (using Docker)
./start.sh prod

Local Development

# Clone the repository
git clone https://github.com/mouxangithub/drawdb
cd drawdb

# Install all dependencies
npm run install:all

# Start both frontend and backend development servers
npm start

πŸ—οΈ Project Structure

The project is divided into frontend and backend parts:

drawdb/
β”œβ”€ src/                   # Frontend source code
β”‚  β”œβ”€ animations/         # Animation components
β”‚  β”œβ”€ assets/             # Static resources
β”‚  β”œβ”€ components/         # Reusable components
β”‚  β”‚  β”œβ”€ common/          # Common UI components
β”‚  β”‚  β”‚  β”œβ”€ DiagramPreviewCard/  # Interactive diagram preview cards
β”‚  β”‚  β”‚  β”œβ”€ DiagramViewModal/    # Full diagram preview modal
β”‚  β”‚  β”‚  β”œβ”€ ShareModal/          # Diagram sharing modal
β”‚  β”‚  β”‚  β”œβ”€ DiagramThumbnail.jsx # Diagram thumbnail component
β”‚  β”‚  β”‚  β”œβ”€ ZoomControl.jsx      # Zoom control component
β”‚  β”‚  β”‚  β”œβ”€ ConfirmationPrompt.jsx  # Confirmation dialog component
β”‚  β”‚  β”‚  └─ ThemeLanguageSwitcher/ # Theme and language switcher component
β”‚  β”‚  β”œβ”€ CollaborationStatus.jsx  # WebSocket connection status component
β”‚  β”‚  β”œβ”€ CollaboratorsList.jsx    # Online collaborators list component
β”‚  β”‚  β”œβ”€ UserActivityIndicator.jsx # User activity indicator component
β”‚  β”‚  β”œβ”€ WebSocketLoadingOverlay.jsx # WebSocket loading overlay
β”‚  β”‚  β”œβ”€ EditorCanvas/    # Canvas editor components
β”‚  β”‚  β”œβ”€ EditorHeader/    # Editor header components
β”‚  β”‚  β”œβ”€ EditorSidePanel/ # Editor side panel components
β”‚  β”‚  β”œβ”€ JsonEditor/      # JSON editor component
β”‚  β”‚  └─ LexicalEditor/   # Rich text editor components
β”‚  β”œβ”€ context/            # React contexts
β”‚  β”‚  β”œβ”€ WebSocketContext.jsx  # WebSocket connection context management
β”‚  β”‚  β”œβ”€ CollaborationContext.jsx  # Collaboration features and user activity management
β”‚  β”‚  └─ ...              # Other context components
β”‚  β”œβ”€ data/               # Static data and constants
β”‚  β”œβ”€ hooks/              # Custom React hooks
β”‚  β”‚  β”œβ”€ useWebSocket.js  # WebSocket connection hook
β”‚  β”‚  β”œβ”€ useCollaboration.js  # Collaboration feature hook
β”‚  β”‚  β”œβ”€ useUserActivity.js  # User activity monitoring hook
β”‚  β”‚  β”œβ”€ useJsonEditor.js  # JSON editor state hook
β”‚  β”‚  └─ ...              # Other hooks
β”‚  β”œβ”€ i18n/               # Internationalization configuration
β”‚  β”‚  β”œβ”€ locales/         # Translation files for different languages
β”‚  β”‚  β”‚  β”œβ”€ en.js         # English translations
β”‚  β”‚  β”‚  β”œβ”€ zh.js         # Chinese translations
β”‚  β”‚  β”‚  β”œβ”€ es.js         # Spanish translations
β”‚  β”‚  β”‚  β”œβ”€ fr.js         # French translations
β”‚  β”‚  β”‚  β”œβ”€ de.js         # German translations
β”‚  β”‚  β”‚  β”œβ”€ jp.js         # Japanese translations
β”‚  β”‚  β”‚  └─ ...           # Other language translations
β”‚  β”‚  β”œβ”€ utils/           # i18n utility functions
β”‚  β”‚  └─ i18n.js          # i18n configuration and initialization
β”‚  β”œβ”€ icons/              # Icon components
β”‚  β”œβ”€ pages/              # Page components
β”‚  β”œβ”€ services/           # APIs and services
β”‚  β”‚  β”œβ”€ websocket.js     # WebSocket client service
β”‚  β”‚  β”œβ”€ diagramWebSocketService.js  # Diagram WebSocket service
β”‚  β”‚  └─ ...              # Other services
β”‚  β”œβ”€ styles/             # CSS styles
β”‚  β”‚  β”œβ”€ components/      # Component styles
β”‚  β”‚  β”œβ”€ pages/           # Page styles
β”‚  β”‚  └─ global/          # Global styles
β”‚  β”œβ”€ utils/              # Utility functions
β”‚  β”œβ”€ App.jsx             # Main application component
β”‚  └─ main.jsx            # Application entry point
β”œβ”€ server/                # Backend server
β”‚  β”œβ”€ database/           # SQLite database files
β”‚  └─ src/                # Server source code
β”‚     β”œβ”€ websocket/       # WebSocket server implementation
β”‚     └─ ...              # Other server code

🌐 Internationalization (i18n)

The project supports multiple languages through its i18n system:

  • Supported Languages: The application currently supports English, Chinese (Simplified and Traditional), Spanish, French, German, Japanese, and many others.
  • Translation Files: Each language has its own translation file located in src/i18n/locales/.
  • Language Structure: Each language file follows the same structure, with translations for all UI elements, messages, and tooltips.
  • Language Switching: Users can switch languages dynamically using the language dropdown in the UI.
  • Latest Updates: Translation files have been updated to include new terms for collaboration features, diagram management, and user interface elements.

To add a new language or update existing translations:

  1. Navigate to the src/i18n/locales/ directory
  2. Create a new file or modify an existing one based on the English (en.js) template
  3. Update the i18n.js file to register the new language
  4. Add the language to the language list in the UI

πŸ“‹ Environment Variables

The project uses a .env file to configure both frontend and backend environment variables:

# Server configuration
PORT=3000
NODE_ENV=development

# Frontend configuration
VITE_WS_PORT=3000  # WebSocket port for real-time collaboration

# Database configuration
DB_STORAGE=server/database/drawdb.sqlite

πŸ”„ Data Backup

The SQLite database used by the system is mounted to the host system via Docker volumes and can be backed up using:

# Using startup script for backup
./start.sh backup  # Linux/macOS
start.bat backup   # Windows

# Or manual backup
cp server/database/drawdb.sqlite backups/drawdb_$(date +%Y%m%d_%H%M%S).sqlite

πŸ”§ Troubleshooting

If you encounter issues, please check:

  1. Static files not accessible: Ensure the following:

    • Check if the STATIC_FILES_DIR environment variable is set correctly
    • Check if the /app/server/public directory exists and contains static files in the Docker container
    • If using a custom Docker build, ensure npm run build has been executed successfully and the build results are copied to /app/server/public
    • Run docker exec -it drawdb sh to enter the container and check the /app/server/public directory
  2. Docker container won't start: Check if the port is already in use or if directory permissions are correct

  3. WebSocket collaboration error fixes:

    • Fixed the handleCollaborationOperation function defined multiple times in Workspace.jsx, renamed to handleCollaborationEvent
    • Fixed the issue where diagramData variable was undefined during drag operations
    • Optimized WebSocket message handling logic to ensure compatibility with different formats of event data
    • Strengthened error handling and data validation to improve system stability

🀝 Contributing

Contributions are welcome, whether it's code contributions, bug reports, or feature suggestions. Please see the contribution guidelines.

πŸ‘ Acknowledgements

This project is based on drawdb-io/drawdb. We would like to express our sincere gratitude to the original project's creators and all contributors who made it possible.

πŸ“„ License

This project is released under the AGPL-3.0 License, the same license as the original drawdb-io/drawdb project. The AGPL-3.0 license requires that:

  • Source code must be made available when distributing the software
  • Modifications must be released under the same license when distributing the software
  • Changes made to the code must be documented
  • If you run a modified program on a server and let users communicate with it, you must also provide them with the source code

πŸ”„ Collaboration Features

The project supports real-time collaborative editing, allowing multiple users to edit the same diagram simultaneously. Key features include:

Real-time Collaboration

  • No login required - Automatically identify users using a unique device identifier (based on IP address or a client-generated unique ID)
  • Real-time cursors - Display the cursor position of other users
  • Editing indicators - Show which components are being edited by other users
  • Version conflict resolution - Automatically handle version conflicts when multiple users edit simultaneously

Collaboration Components

  • Collaboration status bar - Displays the current connection status and the number of online users
  • User list - Shows all currently online users
  • Editing indicators - Display who is currently editing on components
  • Remote cursors - Show the cursor position of other users

Technical Implementation

  • Implemented WebSocket service using the ws library
  • Used Sequelize to operate the SQLite database
  • The client uses the native WebSocket API in the browser

Looking for the Chinese version of this document? See README.zh.md.

About

Free, simple, and intuitive online database diagram editor and SQL generator.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • JavaScript 96.7%
  • CSS 2.1%
  • Other 1.2%