Skip to content

GH-on-Web/GH-Web-App

Repository files navigation

GH-Web-App

AECTech 2025 - Grasshopper on the Web - lets gooo

A web-based visual programming interface inspired by Grasshopper 3D, with real-time multiplayer collaboration powered by Liveblocks. Multiple users can work on the same Grasshopper script simultaneously in the browser.

Features

  • ๐ŸŽจ Visual Node Editor - Drag-and-drop node-based programming
  • ๐Ÿค Real-Time Collaboration - Multiple users can edit simultaneously
  • ๐Ÿ‘ฅ User Presence - See who's online and working
  • ๐Ÿ”— Shareable Workspaces - Share workspace IDs to collaborate
  • ๐Ÿงฎ Geometry Computation - Python/Flask backend for geometry processing
  • ๐ŸŽฏ 3D Visualization - Three.js viewer for geometry preview
  • ๐Ÿ”ท Node Parser Component - Reusable graph visualization system with 2,868+ Grasshopper components

Tech Stack

Frontend

  • React (Create React App)
  • React Flow - Node graph editor
  • Material-UI (MUI) - UI components
  • Zustand - State management
  • Liveblocks - Real-time collaboration
  • Three.js - 3D visualization

Backend

  • Python 3.x
  • Flask - Web framework
  • rhino3dm - Geometry computation

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • Python 3.x
  • pip

Setup Instructions

1. Clone the Repository

git clone <repository-url>
cd GH-Web-App

2. Frontend Setup

cd frontend
npm install

3. Get Liveblocks API Key

  1. Sign up for a free account at https://liveblocks.io
  2. Go to your dashboard and copy your Public API Key (starts with pk_)
  3. Create a .env file in the frontend directory:
cd frontend

Create .env file with:

REACT_APP_LIVEBLOCKS_PUBLIC_KEY=pk_your_public_api_key_here
REACT_APP_API_URL=http://localhost:5000

Important:

  • Replace pk_your_public_api_key_here with your actual public API key
  • No quotes around the value
  • No spaces around the = sign
  • The key should start with pk_

4. Backend Setup (Optional - for compute functionality)

cd backend

# Create virtual environment (recommended)
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Running the Application

Start Frontend

The app will open at [http://localhost:3000](http://localhost:3000)

### Start Backend (Optional - for compute)

```bash
cd backend
python app.py

Backend runs on http://localhost:5000

Testing Multiplayer Collaboration

Single User Test

  1. Open http://localhost:3000
  2. Click "Create Workspace"
  3. Add nodes from the sidebar
  4. Connect nodes together
  5. Check connection status (should show "Connected")

Multiplayer Test (2+ Users)

Option 1: Same Computer

  • Open two browser windows
  • Create workspace in window 1
  • Copy workspace ID from window 1
  • Join workspace in window 2 using the workspace ID
  • Make changes in one window โ†’ See them appear in the other!

Option 2: Different Computers

  1. User 1: Create a workspace and copy the workspace ID (click the workspace ID chip to copy)
  2. User 2:
    • Open the app on their computer
    • Click "Join Workspace"
    • Paste the workspace ID
    • Start collaborating!

What to Test

  • โœ… Add nodes in one window โ†’ Appears in other windows
  • โœ… Move nodes โ†’ Syncs in real-time
  • โœ… Connect nodes โ†’ Edges appear everywhere
  • โœ… Update node parameters โ†’ Updates sync
  • โœ… User presence โ†’ See who's online
  • โœ… Connection status โ†’ Shows "Connected"

Node Parser Component

The reusable NodeParser component provides visual node-based graph editing:

Features:

  • Search and add from 2,868+ Grasshopper components
  • Create/delete connections between nodes
  • Import/Export graph data as JSON
  • Drag to reposition with auto-save
  • Keyboard shortcuts (Delete, Ctrl+drag)

Quick Start:

import { NodeParser } from './components/NodeParser';

<NodeParser
  graphData={graphData}
  onConnectionsChange={handleConnectionsChange}
  onNodesChange={handleNodesChange}
  componentsDatabase={components}
/>

๐Ÿ“– Full Documentation
๐Ÿ’ก Example Usage

Project Structure

GH-Web-App/
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Canvas/          # React Flow canvas
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Collaboration/   # User presence, status
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Layout/          # App layout
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ nodes/          # Custom node components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Sidebar/        # Component library
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ Viewer3D/       # Three.js viewer
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ NodeParser/      # Reusable node parser component
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ NodeParser.js    # Main canvas component
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ GrasshopperNode.js
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ ComponentSearch.js
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ examples/        # Usage examples
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ README.md        # Full documentation
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ index.js         # Easy imports
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/              # Custom React hooks
โ”‚   โ”‚   โ”œโ”€โ”€ pages/              # Page components
โ”‚   โ”‚   โ”œโ”€โ”€ services/           # API services
โ”‚   โ”‚   โ”œโ”€โ”€ utils/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ nodeParser.js        # Parsing utilities
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ connectionManager.js # Connection management
โ”‚   โ”‚   โ””โ”€โ”€ store/              # Zustand stores
โ”‚   โ”œโ”€โ”€ .env                    # Environment variables (create this!)
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app.py                  # Flask server
โ”‚   โ”œโ”€โ”€ compute/                # Geometry computation
โ”‚   โ””โ”€โ”€ requirements.txt
โ””โ”€โ”€ README.md

Troubleshooting

"LiveblocksProvider is missing" Error

  • Make sure you've added the API key to frontend/.env
  • Restart the dev server after creating/updating .env

"Invalid Liveblocks client options" Error

  • Check that your API key is correct in .env
  • Verify the key starts with pk_
  • Make sure there are no quotes or spaces in .env file
  • Restart the dev server

Changes Not Syncing

  • Verify both users are using the same workspace ID
  • Check connection status (should show "Connected")
  • Refresh both windows if needed

Backend Not Connecting

  • Make sure backend is running on port 5000
  • Check REACT_APP_API_URL in .env matches your backend URL

Development Notes

  • Environment variables are loaded at server startup - restart after changing .env
  • Liveblocks public API key is safe to share (it's public!)
  • Workspace IDs are shareable - use them to collaborate
  • Free tier supports up to 20,000 monthly active users
  • NodeParser component is self-contained in frontend/src/components/NodeParser/
  • All dependencies are clearly documented with integration examples

Contributing

This is a hackathon project for AECTech 2025. Feel free to contribute!

License

[Add your license here]


Happy Collaborating! ๐Ÿš€

Releases

No releases published

Packages

No packages published

Contributors 5