Skip to content

About

ConnectDraw is a browser-based collaborative drawing and chat app. People pair in a private room, draw together on a shared canvas, see presence updates, and exchange messages. The React client is also a Progressive Web App (PWA) with install support and an offline app shell.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

ConnectDraw

Real-time collaborative drawing and chat
Draw together in private rooms, exchange messages, see who's online, and install as a PWA.

Node.js npm MongoDB TypeScript React Vite
License: AGPL v3 PWA Socket.IO


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.


Table of Contents


Features

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

Project Structure

.
├── 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.


Requirements

  • 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)

Quick Start — Local Development

# 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 dev

The 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.


Environment Variables

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

Available Scripts

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.js

Building for Production

npm run build

Build order:

  1. packages/shared-types — compiled type declarations
  2. apps/client — tsc -b + vite build → apps/client/dist
  3. apps/server — tsc → apps/server/dist

Then run the server with the required environment variables:

NODE_ENV=production node apps/server/dist/index.js

The 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.


Running with Docker Compose

# 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 --build

Open 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

Typechecking

npm run typecheck

Runs tsc --noEmit across shared types, server, and client. Run before committing to catch type errors early.


Testing

npm test

Runs 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/).


PWA Behavior

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.


Documentation

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

Current Limitations

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.


License

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.

About

ConnectDraw is a browser-based collaborative drawing and chat app. People pair in a private room, draw together on a shared canvas, see presence updates, and exchange messages. The React client is also a Progressive Web App (PWA) with install support and an offline app shell.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages