This is a real-time drawing application built using Node.js, Express.js, and Socket.IO. The application allows users to collaborate on a shared canvas, with the ability to draw, change colors, and adjust stroke width.
- Real-time Drawing: Users can collaborate on a shared canvas, with their drawings being displayed in real-time to all connected clients.
- Drawing Tools: Users can choose the color and adjust the stroke width of their drawings.
- Drawings Saving and Loading: The application stores the drawing data in the database, allowing users to see the previous drawings when they reconnect.
- Drawing Limit: The application imposes a limit on the number of drawing events per minute, preventing spam or abuse.
- Admin panel to view all drawings, delete drawings, and ban/unban users
Client: HTML, CSS, JavaScript
Server: Node.js, Express.js, Socket.io
Database SQLite for local development and MySQL for production. The MySQL database is set up using Docker.
Session Management Redis
- Node.js: Required for running the application
- Redis: Required for session management
- Docker and Docker Compose: Optional, only needed if you want to use MySQL in a container instead of SQLite
- Clone the repo
git clone https://github.com/IsaacDC/drawing_canvas.git- Navigate to the project directory:
cd drawing_canvas- Install the necessary packages:
npm installTo run this project, you will need to add the following environment variables to your .env file
SERVER_HOST=
SERVER_PORT=
DB_HOST=
DB_PORT=
DB_USER=
DB_PASSWORD=
DB_NAME=
REDIS_HOST=
REDIS_PORT=
REDIS_SECRET=
ADMIN_USERNAME=
ADMIN_PASSWORD=
NODE_ENV=-
Setup environment variables
-
Navigate to root directory
cd drawing_canvas- Run this command:
node index.js- Ensure you have docker and docker-compose installed on your system.
- Navigate to the project directory and run the following command to start the MYSQL Docker container:
docker compose up -dThis will create the necessary MySQL database container and set up the application.
To start the docker if it's not running, run the following command:
docker start CONTAINER_NAME- Users can draw on the canvas using their mouse or touch device.
- The "Trash" button clears the user's drawings.
- The "Download" button allows the user to download their drawing as a PNG file.
- The admin panel allows you to view all drawings, delete drawings, and ban/unban users.