A simple WebSocket server for collaborative drawing with Excalidraw
Warning
Current project major version is 0.x. It means that the project is still in development and may have breaking changes in the future.
This is an unofficial implementation of the Excalidraw collaboration server. It uses WebSockets to communicate between clients and broadcast the changes to all connected clients.
- Real-time collaboration with multiple users
- Authentication and validation with JWT
- Configurable storage (currently only supports in-memory storage)
The server uses .yaml configuration file to set up. You can find an example configuration file here.
apps:
rest:
port: 8080
validation:
jwt_header_name: "<YOUR_JWT_HEADER_NAME>"
jwt_validation_url: "<YOUR_JWT_VALIDATION_URL>"
board_validation_url: "<YOUR_BOARD_VALIDATION_URL>"
logging:
level: "DEBUG"
write_to_file: false
storage:
users:
type: "in-memory"
rooms:
type: "in-memory"
cache:
type: "in-memory"
ttl: 300Currently, the apps section contains the following configurations:
-
rest: The REST API configuration.port: The port of the REST API.validation: The JWT validation configuration.jwt_header_name: The name of the header, in whichExcaliroomwill set the JWT token from client.jwt_validation_url: The URL to validate the JWT token, which will be used to authenticate the user.board_validation_url: The URL to validate the access to the board with the JWT token.
-
logging: The log level of the server. It can be one of the following:DEBUG,INFO.
The storage section contains the following configurations:
users: The user storage configuration. It specifies where the server will store the user data.type: The type of the storage. Currently, onlyin-memoryis supported.
rooms: The room storage configuration. It specifies where the server will store the room data.type: The type of the storage. Currently, onlyin-memoryis supported.
The cache section contains the following configurations:
type: The type of the cache. Currently, onlyin-memoryis supported.ttl: Cache duration time. In seconds.
To authenticate the user and validate the access to the board, you need to provide the URLs in the configuration file.
The Excaliroom server requires 2 URLs:
-
jwt_validation_url: The URL to validate the JWT token. TheExcaliroomserver will send aGETrequest to this URL with the JWT token in the header. The server should return200 OKif the token is valid and the following JSON response:{ "id": "<USER_ID>" }The
idwill be used to identify the user. -
board_validation_url: The URL to validate the access to the board with the JWT token. TheExcaliroomserver will send aGETrequest to this URL with the JWT token in the header. The server should return200 OK.
Currently, the server only supports in-memory storage for users and rooms.
Warning
Currently, the Docker image from the Docker Hub is only available for linux/amd64 platform.
If you use another platform (e.g., linux/arm64), you can provide --platform flag to the docker pull command.
-
You can pull the Docker image from the Docker Hub:
docker pull icerzack/excaliroom:latest
Then, you can run the Docker container with the following command:
docker run -d -p 8080:8080 -v path/to/config.yaml:/config.yaml -e CONFIG_PATH="/config.yaml" icerzack/excaliroom:latest -
You can build the Docker image by yourself with the following command:
docker build -f build/Dockerfile -e CONFIG_PATH="path/to/config.yaml" -t excaliroom .
Then, you can run the Docker container with the following command:
docker run -d -p 8080:8080 -v path/to/config.yaml:/config.yaml -e CONFIG_PATH="/config.yaml" excaliroom
You can use Docker Compose to run the server with the following docker-compose.yml file:
services:
app:
image: icerzack/excaliroom:latest
environment:
- CONFIG_PATH=config.yaml
ports:
- "8080:8080"
volumes:
- ./config.yaml:/config.yamlThen, you can run the server with the following command:
docker-compose up -dSet the environment variable CONFIG_PATH to the path of the configuration file and build the binary:
export CONFIG_PATH="path/to/config.yaml"
go build -o excaliroom main.goThen, you can run the binary:
./excaliroomCheck the docs directory of this repo for the guides on how to use and integrate the Excaliroom server with your JavaScript application.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.