A real-time collaborative drawing application backend built with Go, Firebase, and WebSockets.
Phaint is a collaborative digital canvas platform that allows multiple users to create, edit, and share drawing projects in real-time. This backend handles user authentication, project management, real-time collaboration through WebSockets, and persistent storage using Firebase.
- Multi-user canvas editing with live cursor tracking
- Real-time synchronization of drawing operations
- User presence indicators with color-coded cursors
- WebSocket-based communication for low-latency updates
- User registration and authentication via Firebase Auth
- Email/password authentication
- User profile management
- Create and manage drawing projects
- Project collaboration with invite system
- Canvas-based project organization
- Persistent project data storage
- Multiple drawing tools (paths, rectangles, circles)
- Customizable stroke properties and fills
- Interactive elements with action support
- Canvas background customization
- WebSocket Handler: Manages real-time connections and broadcasts
- Canvas Service: Thread-safe canvas and vector element management
- Firebase Integration: Authentication and data persistence
- Project System: Multi-canvas project organization
- Invitation System: Secure project sharing
- Canvas: Individual drawing surfaces with vector data
- VectorElements: Paths, rectangles, and circles with properties
- Projects: Collections of canvases with metadata
- Users: Authentication and profile information
Create config/secrets/config.yaml:
firebase:
database_url: "your-firebase-database-url"
credential_path: "\\config\\secrets\\firebase-credentials.json"
web_api_key: "your-firebase-web-api-key"- Create a Firebase project
- Enable Firestore Database
- Enable Authentication with Email/Password
- Download service account credentials
- Place credentials in
config/secrets/firebase-credentials.json
{
"UID": "string",
"mail": "string",
"username": "string"
}{
"UID": "string",
"PID": "string",
"ProjectName": "string",
"CreationDate": "string",
"Collaborators": ["string"],
"CanvasesData": [Canvas]
}{
"CreatorUID": "string",
"Link": "string",
"ProjectID": "string",
"Used": boolean
}- Go 1.19+
- Firebase project with Firestore enabled
- Firebase service account credentials
- Clone the repository:
git clone <repository-url>
cd phaint_be- Install dependencies:
go mod tidy-
Set up configuration files (see Configuration section)
-
Run the application:
go run main.goThe server will start on port 8080.
phaint_be/
├── config/ # Configuration management
├── internal/
│ ├── handlers/ # HTTP and WebSocket handlers
│ ├── services/ # Business logic services
│ └── utils/ # Utility functions
├── models/ # Data models
└── main.go # Application entry point
- Fork the repository
- Create a feature branch
- Implement changes with tests
- Submit a pull request
For issues and questions, please open an issue on the repository or contact the development team.