A full-stack collaborative whiteboard application inspired by Excalidraw, built with modern web technologies.
This is a monorepo containing three main applications:
apps/
βββ backend/ # Express.js REST API server
βββ frontend/ # Next.js web application
βββ ws-backend/ # WebSocket server for real-time collaboration
packages/
βββ db/ # Shared Prisma database package
- Framework: Next.js 14+ with App Router
- Language: TypeScript
- Styling: CSS (globals.css)
- State Management: Custom StoreProvider
- Real-time: WebSocket client
- Runtime: Bun
- API Server: Express.js (REST API)
- WebSocket Server: Custom WebSocket implementation
- Database: Prisma ORM
- Language: TypeScript
- ORM: Prisma
- Shared: Used by both backend services
- Bun v1.0 or higher
- Node.js v18+ (for compatibility)
- Database (PostgreSQL/MySQL/SQLite - based on your Prisma config)
-
Clone the repository
git clone <your-repo-url> cd exaildraw
-
Install dependencies
# Install all dependencies across the monorepo bun install -
Set up environment variables
Create
.envfiles in each application:Backend (
apps/backend/.env)PORT=3001 DATABASE_URL="your-database-url" CORS_ORIGIN=http://localhost:3000
Frontend (
apps/frontend/.env)NEXT_PUBLIC_API_URL=http://localhost:3001 NEXT_PUBLIC_WS_URL=ws://localhost:3002
WebSocket Backend (
apps/ws-backend/.env)PORT=3002 DATABASE_URL="your-database-url"
Database Package (
apps/ws-backend/packages/db/.env)DATABASE_URL="your-database-url"
-
Set up the database
cd apps/ws-backend/packages/db bun run prisma generate bun run prisma migrate dev cd ../../../../
You can run all services simultaneously or individually:
Option 1: Run all services together
# From the root directory
bun run devOption 2: Run services individually
In separate terminal windows:
# Terminal 1 - Frontend
cd apps/frontend
bun run dev
# Terminal 2 - Backend API
cd apps/backend
bun run dev
# Terminal 3 - WebSocket Server
cd apps/ws-backend
bun run dev# Build all applications
bun run build
# Start all services
bun run startexaildraw/
βββ apps/
β βββ backend/
β β βββ src/
β β β βββ controller/ # Route handlers
β β β βββ middleware/ # Express middleware
β β β βββ routes/ # API routes
β β β βββ types/ # TypeScript types
β β β βββ index.ts # Entry point
β β βββ .env
β β βββ .gitignore
β β βββ package.json
β β βββ README.md
β β βββ tsconfig.json
β β
β βββ frontend/
β β βββ .next/ # Next.js build output
β β βββ actions/ # Server actions
β β βββ app/
β β β βββ (auth)/ # Auth routes group
β β β βββ canvas/ # Canvas page
β β β βββ create-room/ # Room creation
β β β βββ home/ # Home page
β β β βββ favicon.ico
β β β βββ globals.css
β β β βββ layout.tsx
β β β βββ page.tsx
β β β βββ StoreProvider.tsx
β β βββ components/ # React components
β β βββ lib/ # Utilities
β β βββ public/ # Static assets
β β βββ types/ # TypeScript types
β β βββ .env
β β βββ .gitignore
β β βββ next.config.js
β β βββ package.json
β β βββ tsconfig.json
β β
β βββ ws-backend/
β
β βββ src/
β β βββ index.ts # WebSocket server
β β βββ types.ts
β βββ .env
β βββ .gitignore
β βββ package.json
β βββ README.md
β βββ tsconfig.json
packages/
β βββ db/
β βββ prisma/
β β βββ schema.prisma
β βββ generated/ # Prisma client
β βββ src/
β βββ .env
β βββ package.json
β βββ prisma.config.ts
β
βββ node_modules/
βββ .gitignore
βββ package.json
βββ README.md
βββ bun.lockb
bun install # Install all dependencies
bun run dev # Run all apps in development mode
bun run build # Build all applications
bun run start # Start all applications in productionbun run dev # Start Next.js dev server
bun run build # Build for production
bun run start # Start production server
bun run lint # Run ESLintbun run dev # Start Express server with hot reload
bun run build # Build TypeScript
bun run start # Start production serverbun run dev # Start WebSocket server with hot reload
bun run build # Build TypeScript
bun run start # Start production serverbun run prisma:generate # Generate Prisma client
bun run prisma:migrate # Run database migrations
bun run prisma:studio # Open Prisma Studio
bun run prisma:push # Push schema changes to databaseGET /api/health # Health check
POST /api/auth/register # User registration
POST /api/auth/login # User login
GET /api/rooms # Get all rooms
POST /api/rooms # Create a new room
GET /api/rooms/:id # Get room details
PUT /api/rooms/:id # Update room
DELETE /api/rooms/:id # Delete room
Events:
- connection # Client connects
- join-room # Join a drawing room
- draw # Send drawing data
- cursor-move # Update cursor position
- disconnect # Client disconnects
- β Real-time collaborative drawing
- β Multiple drawing tools (pen, shapes, text)
- β User authentication
- β Room-based collaboration
- β Cursor tracking
- β Responsive design
- β TypeScript for type safety
- β Bun for fast development and builds
The database schema is defined in apps/ws-backend/packages/db/prisma/schema.prisma. Key models include:
- User: User authentication and profiles
- Room: Drawing rooms/canvases
- Drawing: Saved drawing data
- (Add more based on your actual schema)
The application uses authentication for securing routes and identifying users. Auth routes are grouped under (auth) in the frontend.
Deploy to Vercel, Netlify, or any platform supporting Next.js:
cd apps/frontend
bun run buildDeploy to any Node.js hosting platform (Railway, Render, DigitalOcean):
# Backend
cd apps/backend
bun run build
# WebSocket
cd apps/ws-backend
bun run buildMake sure to set all environment variables in your deployment platform.
- 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
- Follow TypeScript best practices
- Use ESLint and Prettier for code formatting
- Write meaningful commit messages
- Test your changes before submitting PRs
- Update documentation for new features
Port already in use
# Kill the process using the port
lsof -ti:3001 | xargs kill -9 # Backend
lsof -ti:3000 | xargs kill -9 # Frontend
lsof -ti:3002 | xargs kill -9 # WebSocketDatabase connection issues
# Reset the database
cd apps/ws-backend/packages/db
bun run prisma migrate reset
bun run prisma generateDependencies issues
# Clear cache and reinstall
rm -rf node_modules bun.lockb
bun installThis project is licensed under the MIT License - see the LICENSE file for details.
- Your Name - Initial work
- Inspired by Excalidraw
- Built with Bun
- Powered by Next.js
For support, email your-email@example.com or open an issue in the repository.
Built with β€οΈ using Bun and modern web technologies