Real-time collaborative drawing and chat
Draw together in private rooms, exchange messages, see who's online, and install as a PWA.
ConnectDraw is a browser-based collaborative drawing and chat application. Users pair in private rooms, draw together on a shared canvas, see live presence updates, and exchange messages in real time. The React client is also a Progressive Web App (PWA) with install support and an offline app shell.
In production, the Express server serves the built client, HTTP API, and Socket.IO from a single origin.
- Features
- Project Structure
- Requirements
- Quick Start — Local Development
- Environment Variables
- Available Scripts
- Building for Production
- Running with Docker Compose
- Typechecking
- Testing
- PWA Behavior
- Documentation
- Current Limitations
- License
| Area | Capability |
|---|---|
| Authentication | Registration, login, token refresh, logout, profile read/update |
| Rooms | Private rooms, unique connection codes, request/accept/decline/cancel, room list/disconnect |
| Collaboration | Shared canvas drawing, real-time presence, room chat, typing indicators |
| Client | React + Vite, Tailwind CSS, Zustand state management, React Query, Socket.IO client |
| Server | Express, Socket.IO, MongoDB/Mongoose, JWT auth, rate limiting, Helmet security |
| PWA | Web app manifest, service worker, offline page, install prompts, app-shell caching |
.
├── apps/
│ ├── client/ React + Vite frontend, canvas, chat UI, PWA assets
│ │ ├── public/ Manifest, service worker, offline page, icons
│ │ └── src/
│ │ ├── canvas/ Shared drawing canvas and coordinate tests
│ │ ├── components/ Reusable UI, including PWA install controls
│ │ ├── services/ HTTP client (Axios)
│ │ └── stores/ Client session state (Zustand)
│ └── server/ Express API + Socket.IO server
│ └── src/
│ ├── config/ Environment configuration
│ ├── middleware/ Authentication middleware
│ ├── models/ MongoDB / Mongoose models
│ ├── routes/ HTTP API routes
│ └── sockets/ Realtime collaboration events
├── packages/
│ └── shared-types/ TypeScript types shared by client and server
├── docs/
│ ├── ARCHITECTURE.md
│ ├── API.md
│ ├── DATABASE.md
│ ├── DEPLOYMENT.md
│ ├── PWA.md
│ ├── SOCKET_EVENTS.md
│ └── TESTING.md
├── Dockerfile Production image (web app + server)
├── docker-compose.yml Server + MongoDB stack
├── .env.example Environment variable template
├── LICENSE GNU Affero General Public License v3.0
└── package.json Root workspace scripts
The client and server are npm workspaces. Shared types are compiled once and consumed by both.
- Node.js 22 or newer and npm 10 or newer
- MongoDB 7 or newer — either installed locally, or via Docker Compose
- Docker + Docker Compose (optional, for containerized development/deployment)
# 1. Clone the repository and install all workspace dependencies
npm install
# 2. Create your local environment file
cp .env.example .env
# Then open .env and replace the example JWT secrets with strong random values.
# 3. Start MongoDB, then launch the server and Vite dev client together
npm run devThe dev script runs both workspaces concurrently:
- Server (Express + Socket.IO) →
http://localhost:4000 - Client (Vite dev server) →
http://localhost:5173
Vite proxies /api and /socket.io to the Express server.
Open your browser at http://localhost:5173.
Copy .env.example to .env for local development. Set production secrets through your deployment environment — never commit real secrets.
| Variable | Purpose | Default |
|---|---|---|
NODE_ENV |
Runtime mode: development, test, or production |
development |
PORT |
Express / Socket.IO listening port | 4000 |
CLIENT_ORIGIN |
Browser origin allowed by CORS and Socket.IO | — |
DOCKER_CLIENT_ORIGIN |
Docker Compose override for the public browser origin | — |
MONGODB_URI |
MongoDB connection string | — |
JWT_ACCESS_SECRET |
Secret used to sign short-lived access tokens | — |
JWT_REFRESH_SECRET |
Reserved refresh-token signing secret (refresh tokens are opaque hashes) | — |
COOKIE_SECURE |
Set to true when serving over HTTPS |
— |
VITE_API_URL |
Client API base path | /api |
Run all scripts from the repository root unless noted.
| Script | Purpose |
|---|---|
npm run dev |
Start server and client concurrently in development |
npm run build |
Build shared types, client, and server (in order) |
npm run typecheck |
TypeScript type-check across all workspaces |
npm test |
Run server and client test suites |
npm run format |
Format all files with Prettier |
npm run format:check |
Check formatting without changing files |
Workspace-scoped examples:
# Client only
npm run dev -w apps/client
npm run build -w apps/client
npm run preview -w apps/client # serves apps/client/dist on :4173
# Server only
npm run dev -w apps/server
npm run start -w apps/server # runs apps/server/dist/index.jsnpm run buildBuild order:
packages/shared-types— compiled type declarationsapps/client—tsc -b+vite build→apps/client/distapps/server—tsc→apps/server/dist
Then run the server with the required environment variables:
NODE_ENV=production node apps/server/dist/index.jsThe server serves the client from apps/client/dist and listens on PORT (default 4000).
Production note: Deploy behind HTTPS. Secure refresh cookies and PWA service workers require a secure origin.
# 1. Configure environment
cp .env.example .env
# Set strong JWT secrets and DOCKER_CLIENT_ORIGIN to your public origin
# (e.g., http://localhost:8080 for local Compose testing)
# 2. Build and start the stack
docker compose up --buildOpen http://localhost:8080. Compose runs MongoDB and a single Express service. MongoDB data persists in the mongo_data volume.
- Stop services:
docker compose down - Stop and remove the database volume:
docker compose down -v
npm run typecheckRuns tsc --noEmit across shared types, server, and client. Run before committing to catch type errors early.
npm testRuns the server suite (vitest run in apps/server) and the client suite (vitest run in apps/client). Server tests require MongoDB to be running.
See docs/TESTING.md for the full QA checklist, including PWA acceptance checks (manifest parsing, icon retrieval, service-worker scope, offline fallback, install behavior, and cache exclusions for /api/ and /socket.io/).
The PWA manifest, root-scoped service worker, offline page, and install icons live in apps/client/public. The service worker caches the app shell and static assets — not authenticated API data or Socket.IO traffic. Drawing, chat, authentication, and room data require a network connection.
Browser install prompts vary: Chromium may show an in-app install prompt, while Safari and other browsers use their own install or "Add to Home Screen" menu.
See docs/PWA.md for install and service-worker details.
| Document | Description |
|---|---|
docs/ARCHITECTURE.md |
System architecture and design |
docs/API.md |
HTTP API reference |
docs/DATABASE.md |
MongoDB schema and data model |
docs/DEPLOYMENT.md |
Deployment guide |
docs/PWA.md |
PWA install and service worker details |
docs/SOCKET_EVENTS.md |
Socket.IO event reference |
docs/TESTING.md |
QA and testing checklist |
ConnectDraw provides account registration/login, profile settings, private rooms, real-time presence, collaborative drawing, room chat, and a PWA shell. It is not a production-certified release. The following are not yet implemented:
- Advanced collaborative undo / rebase
- Drawing-log compaction
- Attachments
- Read receipts
- Push notifications
- Full two-browser end-to-end test suite
- Offline auth, local room persistence, or queued write replay (offline support is limited to the static app shell)
Verify the collaboration workflow and deployment on your actual target browsers before relying on ConnectDraw in production.
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) — a copyleft license for network server software.
See the full license text in LICENSE.
Note: Because this is AGPL-licensed, if you run a modified version of ConnectDraw on a network server, you must make the corresponding source available to your users.