Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

drptms/phaint_be

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

48 Commits

Repository files navigation

Phaint Backend

A real-time collaborative drawing application backend built with Go, Firebase, and WebSockets.

Overview

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.

Features

🎨 Real-time Collaboration

  • 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 Management

  • User registration and authentication via Firebase Auth
  • Email/password authentication
  • User profile management

πŸ“ Project Management

  • Create and manage drawing projects
  • Project collaboration with invite system
  • Canvas-based project organization
  • Persistent project data storage

🎯 Vector Graphics Support

  • Multiple drawing tools (paths, rectangles, circles)
  • Customizable stroke properties and fills
  • Interactive elements with action support
  • Canvas background customization

Architecture

Core Components

  • 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

Data Models

  • 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

Configuration

Environment Setup

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"

Firebase Setup

  1. Create a Firebase project
  2. Enable Firestore Database
  3. Enable Authentication with Email/Password
  4. Download service account credentials
  5. Place credentials in config/secrets/firebase-credentials.json

Collections Structure

users

{
 "UID": "string",
 "mail": "string", 
 "username": "string"
}

projects

{
 "UID": "string",
 "PID": "string",
 "ProjectName": "string",
 "CreationDate": "string",
 "Collaborators": ["string"],
 "CanvasesData": [Canvas]
}

invitations

{
 "CreatorUID": "string",
 "Link": "string",
 "ProjectID": "string",
 "Used": boolean
}

Installation & Setup

Prerequisites

  • Go 1.19+
  • Firebase project with Firestore enabled
  • Firebase service account credentials

Installation

  1. Clone the repository:
git clone <repository-url>
cd phaint_be
  1. Install dependencies:
go mod tidy
  1. Set up configuration files (see Configuration section)

  2. Run the application:

go run main.go

The server will start on port 8080.

Development

Project Structure

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

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Implement changes with tests
  4. Submit a pull request

Support

For issues and questions, please open an issue on the repository or contact the development team.

About

Backend for:

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /