A collaborative whiteboard application built with Next.js and Go, featuring real-time drawing capabilities and user authentication.
- 🎨 Real-time Drawing: Collaborative whiteboard with multiple drawing tools
- 👤 User Authentication: Secure JWT-based authentication system
- 📊 Board Management: Create, view, update, and delete boards
- 🔒 Cross-User Security: Users can only access their own boards
- 🌐 Modern UI: Built with Next.js 16 and Tailwind CSS
- 🎯 Type Safety: Full TypeScript support on the frontend
- 🧪 Comprehensive Testing: Integration test suite for backend API
- Next.js 16 - React framework with App Router
- TypeScript - Type-safe JavaScript
- Tailwind CSS - Utility-first CSS framework
- React Konva - Canvas library for drawing
- Zustand - State management
- Axios - HTTP client
- Go 1.24 - Backend programming language
- Gin - HTTP web framework
- MongoDB - NoSQL database
- JWT - JSON Web Token authentication
- Gorilla CORS - Cross-Origin Resource Sharing
BoardSar/
├── backend/ # Go backend API
│ ├── main.go # Application entry point
│ ├── controllers/ # API controllers
│ │ ├── auth.go # Authentication logic
│ │ └── board.controller.go # Board operations
│ ├── models/ # Data models
│ │ ├── user.go # User model
│ │ └── board.model.go # Board model
│ ├── routes/ # API routes
│ │ ├── mainRoutes.go # Route definitions
│ │ └── board.routes.go # Board-specific routes
│ ├── database/ # Database connection
│ │ └── mongo.go # MongoDB setup
│ ├── libs/ # Utility libraries
│ │ ├── auth.go # JWT utilities
│ │ └── middleware.go # Authentication middleware
│ ├── test/ # Test files
│ ├── .env.example # Environment variables template
│ ├── go.mod # Go module definition
│ └── README_TEST.md # Test documentation
├── client/ # Next.js frontend
│ ├── app/ # App Router pages
│ ├── components/ # React components
│ ├── lib/ # Utility functions
│ ├── public/ # Static assets
│ ├── .env.local.example # Environment variables template
│ ├── next.config.ts # Next.js configuration
│ ├── tsconfig.json # TypeScript configuration
│ └── package.json # Dependencies
└── README.md # This file
Before you begin, ensure you have installed:
- Node.js (v18 or higher)
- Go (v1.24 or higher)
- MongoDB (local or cloud instance)
- Git
git clone https://github.com/sarwanazhar/boardsar.git
cd boardsarcd backend
go mod downloadcp .env.example .envEdit the .env file with your configuration:
PORT=8080
MONGODB_URI=mongodb://localhost:27017/boardsar
JWT_SECRET=your-super-secret-jwt-key-herecd ../client
pnpm installcp .env.local.example .env.localEdit the .env.local file:
NEXT_PUBLIC_API_URL=http://localhost:8080Ensure MongoDB is running locally or update the connection string in your .env file.
cd backend
go run main.goThe backend will start on http://localhost:8080
cd ../client
pnpm devThe frontend will start on http://localhost:3000
POST /auth/register- User registrationPOST /auth/login- User loginGET /me- Get current user profile
GET /api/boards- List all user's boardsPOST /api/boards- Create a new boardGET /api/boards/:id- Get specific boardPUT /api/boards/:id- Update boardDELETE /api/boards/:id- Delete board
The backend includes a comprehensive integration test suite:
cd backend
# Run with virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 TestIntegrationBackend.py
# Or with pytest
python3 -m pytest TestIntegrationBackend.py -v- User Authentication (11 tests) - Registration, login, JWT validation
- Board CRUD Operations (13 tests) - Create, read, update, delete boards
- Security & Edge Cases (6 tests) - Cross-user access prevention, CORS, validation
# Required Python packages
pip install requests pymongo python-dotenv
# Environment variables for testing
export TEST_BASE_URL=http://localhost:8080
export MONGODB_URI=mongodb://localhost:27017/boardsar_test
export JWT_SECRET=your-jwt-secret-keyPORT=8080 # Server port
MONGODB_URI=mongodb://localhost:27017/boardsar # MongoDB connection string
JWT_SECRET=your-secret-key # JWT signing secretNEXT_PUBLIC_API_URL=http://localhost:8080 # Backend API URL- Go: Follow standard Go conventions
- TypeScript: Strict mode enabled
- Tailwind: Use utility classes for styling
- Create database models in
backend/models/ - Implement controllers in
backend/controllers/ - Add routes in
backend/routes/ - Create React components in
client/components/ - Update API calls in
client/lib/
# Build and run with Docker Compose
docker-compose up -d- Build the frontend:
cd client && pnpm build - Deploy backend:
cd backend && go build -o boardsar - Set environment variables for production
- Run the compiled binary
The frontend is optimized for Vercel deployment:
cd client
vercel- Use environment variables for secrets
- Enable HTTPS in production
- Set up proper CORS configuration
- Monitor application performance
- Implement proper error handling
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes
- Run tests:
cd backend && python3 TestIntegrationBackend.py - Commit your changes:
git commit -m 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
- Ensure all tests pass
- Follow existing code style
- Add appropriate comments for complex logic
- Update documentation for new features
- Tokens are signed with HMAC using the JWT_SECRET
- Tokens expire after 24 hours
- All protected routes require valid JWT tokens sent via
Authorization: Bearer <token>header
- Input validation on all API endpoints
- Password strength requirements
- Email format validation
- Configured for localhost development
- Update for production domains
# Check if MongoDB is running
sudo systemctl status mongod
# Start MongoDB
sudo systemctl start mongod# Check if ports are in use
lsof -i :8080
lsof -i :3000
# Kill processes using ports
kill -9 <PID># Backend
cd backend
go mod tidy
# Frontend
cd client
pnpm install --force- Check the Issues section
- Review the test suite for expected behavior
- Check console logs for error details
- Repository: https://github.com/sarwanazhar/boardsar
- Issues: GitHub Issues
- Next.js for the excellent React framework
- Gin for the fast Go web framework
- React Konva for the canvas drawing capabilities
- MongoDB for the database
BoardSar - Collaborative whiteboarding made simple. 🎨