Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 36 additions & 27 deletions .github/workflows/run_eslint.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
name: Linting client code
name: CI

on:
pull_request:
branches:
- main
- development
branches: [master]
push:
branches:
- main
- development
branches: [master]

jobs:
run-linters:
name: Run linters
client:
name: Client (lint + build)
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./client
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
cache-dependency-path: client/pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
- run: pnpm run lint
- run: pnpm run build

- name: Set up Node.js
uses: actions/setup-node@v1
server:
name: Server (build)
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./server
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
node-version: 18

- uses: pnpm/action-setup@v2
version: 8
- uses: actions/setup-node@v4
with:
version: 8
run_install: |
- recursive: true
args: [--frozen-lockfile, --strict-peer-dependencies]
- args: [--global, gulp, prettier, typescript]

# ESLint and Prettier must be in `package.json`
- name: Run linters
working-directory: ./client
run : npm run lint
node-version: 20
cache: pnpm
cache-dependency-path: server/pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
- run: pnpm run build
72 changes: 71 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,71 @@
# CollabLab
# CollabLab

A real-time collaborative whiteboard. Start a board, share the link, and draw together: shapes, freehand ink,
text and live cursors sync instantly between everyone on the board.

## Features

- **Live sync**: every create, move, resize, rotate, restyle and delete is broadcast to the board over Socket.IO.
- **Presence**: named, colored cursors and avatars for everyone on the board.
- **Tools**: select, pen, eraser, rectangle, ellipse, triangle, line and text, with colors, stroke widths and fills.
- **Shareable boards**: each board lives at `/board/<id>`; late joiners receive the current drawing.
- **Export**: download the board as a PNG cropped to its content.
- **Optional accounts**: email/password sign-up and sign-in (bcrypt + JWT, stored in Postgres). Without a database,
everyone joins as a named guest.

Keyboard shortcuts: `1`–`8` pick tools, `Del`/`Backspace` deletes the selection, `Esc` returns to select.

## Project layout

```
client/ React + Vite + fabric.js front end
server/ Express + Socket.IO server (boards in memory, accounts in Postgres)
```

## Running locally

Requires Node 18+ and [pnpm](https://pnpm.io) 8 (`npx pnpm@8 ...` works too).

```bash
# terminal 1: server on http://localhost:5000
cd server
pnpm install
pnpm dev

# terminal 2: client on http://localhost:5173
cd client
pnpm install
pnpm dev
```

Open http://localhost:5173, click **Start a new board**, and open the same board link in a second window to see it sync.

## Configuration

**Client** (`client/.env.local`, see `client/.env.example`)

| Variable | Default | Purpose |
| --- | --- | --- |
| `VITE_SERVER_URL` | `http://localhost:5000` | Where the API and Socket.IO server live |

**Server** (`server/.env`, see `server/.env.example`)

| Variable | Default | Purpose |
| --- | --- | --- |
| `PORT` | `5000` | HTTP/WebSocket port |
| `CLIENT_ORIGIN` | any origin | Comma-separated list of allowed browser origins |
| `POSTGRES_URL` | unset | Postgres connection used for accounts |
| `SECRET_KEY` | unset | JWT signing secret; accounts are enabled only when this and `POSTGRES_URL` are set |
| `DATABASE_URL` | unset | Used by `pnpm migrate up` (node-pg-migrate) to create the `users` table |

To enable accounts: create a Postgres database, set the three variables above in `server/.env`, then run
`pnpm migrate up` in `server/`.

## Notes

Boards are stored in server memory and discarded six hours after the last person leaves. A server restart
clears them, though a client that reconnects with a drawing still open re-uploads it.

## License

MIT
2 changes: 2 additions & 0 deletions client/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# URL of the CollabLab server (API + Socket.IO). Defaults to http://localhost:5000.
VITE_SERVER_URL=http://localhost:5000
2 changes: 1 addition & 1 deletion client/.prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules/
dist/
.prettierrc.js
pnpm-lock.yaml
4 changes: 4 additions & 0 deletions client/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"printWidth": 120,
"endOfLine": "auto"
}
30 changes: 0 additions & 30 deletions client/README.md

This file was deleted.

9 changes: 7 additions & 2 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<meta
name="description"
content="CollabLab is a real-time collaborative whiteboard. Start a board, share the link, and draw together."
/>
<meta name="theme-color" content="#4f46e5" />
<title>CollabLab · Real-time collaborative whiteboard</title>
</head>
<body>
<div id="root"></div>
Expand Down
8 changes: 5 additions & 3 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
"preview": "vite preview",
"format": "prettier --write ."
},
"engines": {
"node": ">=20"
},
"dependencies": {
"fabric": "^5.3.0",
"fabricjs-react": "^1.2.1",
"keycloak-js": "^23.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.21.1"
"react-router-dom": "^6.21.1",
"socket.io-client": "^4"
},
"devDependencies": {
"@types/fabric": "^5.3.6",
Expand Down
Loading
Loading