OpenSketch is a high-performance, open-source real-time collaboration tool designed to mimic the freedom of a physical whiteboard. Built with a Monorepo architecture, it leverages the latest web technologies to provide a seamless drawing experience.
It utilizes a unique Hybrid Architecture (Node.js + PHP) to enable real-time WebSocket capabilities even on standard Shared Hosting (cPanel) environments.
Seamlessly sync drawings, cursors, and object modifications across multiple users with sub-millisecond latency using WebSockets.
Includes a comprehensive suite of tools: Rectangle, Circle, Triangle, Rhombus, Arrow, Line, Freehand Pencil, Text, and Eraser.
Powered by Fabric.js v6 for hardware-accelerated rendering, supporting thousands of objects on an infinite canvas without lag. Optimized for mobile touch gestures.
Fully responsive interface with native Dark Mode, customizable Grid systems (Dots/Lines), and mobile-first gesture support. Toolbar hides automatically on small screens.
- Node.js: Handles live streams.
- PHP/MySQL: Handles room persistence and host validation.
- Export: Save work as PNG, PDF, or SVG.
| Category | Technologies Used |
|---|---|
| Frontend | Next.js 15, React 18, Tailwind CSS, Lucide Icons |
| State Management | Zustand (Global Store), LocalStorage |
| Canvas Engine | Fabric.js (v6), Rough.js (Hand-drawn style) |
| Real-time Server | Node.js, Express, Socket.io |
| Data API | PHP 8.x (Native), MySQL/MariaDB |
| Deployment | cPanel (Shared Hosting), Docker (Local Dev) |
Follow this guide to deploy your app to your domain (e.g., https://art.haniipp.space).
Before uploading, we must "cook" the code into production-ready files.
-
Configure Environment:
- Open
apps/web/.env. - Set the production URL:
NEXT_PUBLIC_WS_URL=https://art.haniipp.space
- Open
-
Build the Server (Node.js): Open your terminal in
apps/serverand run:npm install npm run build
β Check: Ensure a
distfolder is created. -
Build the Frontend (Web): Open terminal in the root folder and run:
npm run build:web:static
β Check: Ensure
apps/web/outfolder is created.
-
Upload Files:
- In cPanel File Manager, create a folder outside
public_htmlnamedopensketch-server. - Upload these exact items from
apps/server:package.jsonapp.js(The bridge file)dist(The folder containing compiled code)
- In cPanel File Manager, create a folder outside
-
Start the App:
- Go to Setup Node.js App in cPanel.
- Create Application:
- Node Version: 18.x or 20.x.
- App Root:
opensketch-server. - Startup File:
app.js.
- Click Create.
- Click Run NPM Install.
- Ensure status says Started.
-
π CRITICAL: Find the Port:
- Go back to File Manager ->
opensketch-server. - Look for a file named
port.txt. - Open it and copy the number (e.g.,
54321). - Keep this number safe!
- Go back to File Manager ->
-
Create Database:
- Go to MySQL Database Wizard.
- Create a database (e.g.,
haniipp_sketch). - Create a user and give it All Privileges.
-
Setup Table:
- Go to phpMyAdmin.
- Select your database -> Import.
- Upload
php-backend/database.sql.
-
Upload API:
- In File Manager, go to your subdomain folder (
public_htmlorart.haniipp.space). - Create a folder named
api. - Upload
db.php,create-room.php, andcheck-room.phpinto thisapifolder. - Edit
db.php: Update with your new Database User and Password.
- In File Manager, go to your subdomain folder (
- Upload Static Files:
- Go to your subdomain folder (
art.haniipp.space). - Upload ALL contents from your local
apps/web/outfolder. - (You should see
index.html,404.html, and_nextfolder).
- Go to your subdomain folder (
This connects everything together.
- Create or Edit
.htaccessin your subdomain folder. - Paste this code (Replace
YOUR_PORT_NUMBERwith the number from Phase 2):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# 1. Force HTTPS π
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# 2. PHP API Routing (Let Apache handle this) π
RewriteCond %{REQUEST_URI} ^/api/.*\.php$ [NC]
RewriteRule ^ - [L]
# 3. WebSocket Proxy (To Node.js) β‘
# REPLACE 12345 WITH YOUR PORT NUMBER!
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule ^socket.io/(.*) ws://127.0.0.1:12345/socket.io/$1 [P,L]
RewriteCond %{REQUEST_URI} ^/socket.io/ [NC]
RewriteRule ^socket.io/(.*) http://127.0.0.1:12345/socket.io/$1 [P,L]
# 4. React App Routing βοΈ
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>Distributed under the MIT License. See LICENSE for more information.