A modern full-stack web application for real-time collaborative drawing. Built with Next.js, TypeScript, WebSockets, and PostgreSQL.
- Features
- Tech Stack
- Project Structure
- Quick Start
- Development
- Scripts
- Docker Deployment
- Database
- Architecture
- Contributing
- π― Real-time Collaborative Drawing - Multiple users can draw simultaneously with WebSocket synchronization
- π User Authentication - Secure JWT-based authentication with password hashing
- πΎ Persistent Storage - Save drawings to PostgreSQL database
- π± Responsive UI - Modern Next.js 15 frontend with Tailwind CSS
- π Monorepo Architecture - Organized with pnpm workspaces and Turbo
- π³ Docker Ready - Containerized services with docker-compose
- π Type Safe - 100% TypeScript codebase
- β‘ Fast Builds - Optimized with Turbo caching
- Next.js 15.5 - React framework with SSR
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS - Styling
- Socket.io Client - WebSocket communication
- Node.js 20 - Runtime
- Express.js - REST API framework
- WebSocket (ws) - Real-time communication
- JWT - Authentication
- bcrypt - Password hashing
- PostgreSQL 16 - Primary database
- Prisma - ORM and migrations
- Docker & Docker Compose - Containerization
- pnpm - Package manager
- Turbo - Monorepo build system
- TypeScript - Static typing
Excalidraw/
βββ apps/
β βββ excelidraw-frontend/ # Next.js 15 React app
β β βββ app/ # App directory structure
β β βββ Components/ # React components
β β βββ public/ # Static assets
β β βββ package.json
β βββ http-backend/ # Express REST API
β β βββ src/
β β β βββ index.ts # Server entry point
β β β βββ middleware.ts # Custom middleware
β β βββ package.json
β βββ ws-backend/ # WebSocket server
β βββ src/
β β βββ index.ts # WS server entry
β βββ package.json
βββ packages/
β βββ db/ # Prisma ORM & migrations
β β βββ prisma/
β β β βββ schema.prisma # Database schema
β β β βββ migrations/ # DB migrations
β β βββ package.json
β βββ common/ # Shared TypeScript types
β βββ backend-common/ # Backend utilities
β βββ ui/ # Shared React components
β βββ typescript-config/ # Shared tsconfig
β βββ eslint-config/ # Shared ESLint config
βββ docker-compose.yml # Service orchestration
βββ pnpm-workspace.yaml # Workspace config
βββ turbo.json # Build configuration
βββ package.json # Root package
βββ README.md # This file
- Node.js 18+ (Download)
- pnpm 9.0+
npm install -g pnpm@9.0.0
- PostgreSQL 16+ (for local development)
- Docker & Docker Compose (for containerized setup)
-
Clone and setup
git clone <repo-url> cd Excalidraw pnpm install
-
Configure environment
# Create .env in root echo "DATABASE_URL=postgresql://postgres:postgres@localhost:5432/excalidraw" > .env echo "JWT_SECRET=your-secret-key" >> .env
-
Setup database
cd packages/db npx prisma migrate dev npx prisma generate cd ../..
-
Start development
pnpm dev
Services will start:
- Frontend: http://localhost:3000
- HTTP API: http://localhost:3001
- WebSocket: ws://localhost:8080
git clone <repo-url>
cd Excalidraw
docker compose up -d --buildAccess at http://localhost:3000
See README.docker.md for detailed Docker guide.
pnpm installpnpm devpnpm buildpnpm check-typespnpm lint # Run ESLint
pnpm format # Format with Prettierpnpm dev --filter=excelidraw-frontend
pnpm dev --filter=http-backend
pnpm dev --filter=ws-backendAll scripts run via pnpm in the root directory:
| Script | Purpose |
|---|---|
pnpm dev |
Start all services in dev mode |
pnpm build |
Build all apps & packages for production |
pnpm lint |
Run ESLint on all code |
pnpm format |
Format code with Prettier |
pnpm check-types |
TypeScript type checking |
Database scripts (from packages/db):
npx prisma migrate dev # Create & apply migrations
npx prisma generate # Generate Prisma client
npx prisma studio # Open database GUIQuick start with Docker:
docker compose up -d --buildServices:
- Frontend: http://localhost:3000
- API: http://localhost:3001
- WebSocket: ws://localhost:8080
- Database: localhost:5432
Useful Docker Commands:
# View logs
docker compose logs -f http-backend
docker compose logs -f ws-backend
# Stop services
docker compose down
# Rebuild specific service
docker compose up -d --build http-backendSee README.docker.md for complete Docker documentation.
The database includes tables for:
- Users - User accounts with hashed passwords
- Drawings - Persisted drawing data
- Sessions - User session management
Migrations are in packages/db/prisma/migrations/. To create a new migration:
cd packages/db
npx prisma migrate dev --name your_migration_nameLocal PostgreSQL:
psql postgresql://postgres:postgres@localhost:5432/excalidrawDocker:
docker compose exec db psql -U postgres -d excalidraw- Uses pnpm workspaces for dependency management
- Uses Turbo for intelligent build caching
- Shared packages reduce code duplication
βββββββββββββββββββββββββββββββββββββββ
β Next.js Frontend (3000) β
β - User Interface β
β - Drawing Canvas β
β - Real-time Sync via WebSocket β
ββββββββββββββββ¬βββββββββββββββββββββββ
β
βββββββββββ΄ββββββββββ
β β
ββββββΌβββββββββ ββββββΌβββββββββ
β HTTP API β β WebSocket β
β (3001) β β (8080) β
β - Auth β β - Real-time β
β - CRUD β β - Drawing β
β - JWT β β - Sync β
ββββββ¬βββββββββ ββββββ¬βββββββββ
β β
βββββββββββ¬ββββββββββ
β
ββββββββΌβββββββ
β PostgreSQL β
β (5432) β
β - Users β
β - Drawings β
ββββββββββββββββ
-
Create a feature branch
git checkout -b feature/amazing-feature
-
Make your changes and commit
git add . git commit -m "Add amazing feature"
-
Run checks before pushing
pnpm lint pnpm format pnpm check-types pnpm build
-
Push and create pull request
git push origin feature/amazing-feature
MIT License - feel free to use this project for personal or commercial purposes.
Port Already in Use?
# Kill process on port 3000
lsof -i :3000 | grep LISTEN | awk '{print $2}' | xargs kill -9Database Connection Issues?
# Verify PostgreSQL is running
psql --version
psql postgresql://postgres:postgres@localhost:5432/excalidrawNode Modules Issues?
# Clean install
pnpm store prune
rm -rf node_modules packages/*/node_modules
pnpm installFor more help, see README.docker.md for Docker-specific issues.
Happy Drawing! π¨