A real-time collaborative drawing application with integrated chat functionality, built using Next.js, TypeScript, WebSockets, and Prisma. This app allows multiple users to join drawing rooms, create and modify shapes on a shared canvas, and communicate through an integrated chat system.
-
Collaborative Drawing Tools:
- Shape Tools: Rectangle, Circle, Text
- Freehand Drawing: Pencil tool for free-form drawing
- Selection Tool: Select and move existing shapes
- Pan/Drag Tool: Navigate the canvas with pan and zoom functionality
- Color & Stroke Controls: Customize your drawing style
- Delete: Remove selected shapes
- Zoom Functionality: Ctrl+scroll when drag tool is selected
-
Real-time Collaboration:
- Instant Updates: All drawing actions broadcast to all users in real-time
- Integrated Chat: Toggle sidebar for text communication while drawing
- Connection Status: Visual indicator shows WebSocket connection state
- Persistent Storage: Drawing and chat history persisted to database
-
Responsive Design:
- Cross-Device Support: Works on desktop, tablet, and mobile devices
- Touch Support: Full drawing support via touch events on mobile/tablet
- Adaptive UI: Responsive toolbar, controls, and layout
- Mobile-Optimized: Bottom controls on mobile for better usability
-
User Management:
- Authentication: Secure sign-up and login with JWT
- Room Management: Create, join, and manage drawing rooms
- User Dashboard: Overview of available rooms
-
Frontend:
- Next.js 15: App Router for modern React architecture
- React 19: Latest React features
- TypeScript: Full type safety
- Tailwind CSS: Responsive styling
- HTML5 Canvas API: Custom drawing implementation
- Lucide React: UI icons
-
Backend:
- WebSocket Server: Real-time communication for drawing and chat
- Express REST API: Authentication and data persistence
- Prisma ORM: Type-safe database access
- PostgreSQL: Relational database storage
- JWT: Secure authentication
-
Infrastructure:
- Turborepo: Monorepo management
- pnpm: Fast, disk-efficient package manager
- Shared Packages: Types, config, and UI components
The project is organized as a Turborepo monorepo with the following components:
-
web
: Next.js frontend applicationapp
: Next.js App Router pagescomponents
: React components for UIdraw
: Canvas and drawing logiccontexts
: React context providers
-
ws-backend
: WebSocket server for real-time features- Handles drawing broadcasts
- Manages chat messaging
- Tracks room participation
-
http-backend
: Express REST API- Authentication endpoints
- Room management
- Chat history
database
: Prisma schema and clientshared_zod
: Shared validation schemasui
: Reusable UI components- Config packages for ESLint, TypeScript, and Tailwind
- Node.js (v18+)
- pnpm
- PostgreSQL database
-
Clone the repository:
git clone https://github.com/yourusername/draw-app-excalidraw.git cd draw-app-excalidraw
-
Install dependencies:
pnpm install
-
Configure environment variables: Create a
.env
file in the root directory:DATABASE_URL="postgresql://username:password@localhost:5432/excalidraw?schema=public" JWT_SECRET="your-secret-key" NEXT_PUBLIC_BACKEND_HTTP_URL="http://localhost:3001" NEXT_PUBLIC_BACKEND_WS_URL="ws://localhost:3002"
-
Set up the database:
cd packages/database pnpm prisma db push
-
Start the development servers:
pnpm dev
This will start:
- Frontend: http://localhost:3000
- HTTP Backend: http://localhost:3001
- WebSocket Backend: http://localhost:3002
- Register a new account or log in with existing credentials
- Access the dashboard after successful authentication
- Create a new drawing room or join an existing one by slug
- View a list of your rooms on the dashboard
- Select a Tool: Click on the tool icon in the toolbar
- Shapes: Click and drag to create rectangles and circles
- Pencil: Click and drag to draw freehand
- Text: Click to place text and type your content
- Selection: Click on shapes to select them, then drag to move
- Pan/Drag: Click and drag to move around the canvas
- Zoom: Hold Ctrl and scroll to zoom in/out (when drag tool is selected)
- Delete: Select a shape and click the delete button
- Toggle the chat sidebar using the chat button
- Type messages and communicate with others in the room
- Chat history is preserved along with drawings
- Use touch gestures for drawing and panning
- UI adapts automatically to smaller screens
- Controls positioned for easy thumb access on mobile
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature
- Commit your changes:
git commit -m 'Add some amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Excalidraw
- Built with Next.js and Turborepo
- Special thanks to all contributors and the open-source community