Browser-based CAD-like 2D editor for designing parametric glass shapes.
It combines a React + Three.js frontend with a Node.js backend, supports snapping and constraints, and exports shape JSON to both local file and database workflows.
This repository contains two applications:
gsap-editor- frontend editor built with React, Vite, and Three.jsserver- backend API built with Express + MySQL, with optional Redis/BullMQ integration
The frontend communicates with the backend through /api/* (proxied by Vite in development).
The backend stores and serves shape definitions, and supports downstream processing queue integration.
- Draw lines (including chained segments), arcs, rectangles, and circles
- Select and move existing geometry
- Trim and offset edges
- Real-time visual rendering in an orthographic Three.js scene
- Snapping modes: endpoint, midpoint, center, intersection, perpendicular, tangent, angle increment, grid
- Constraint tools: horizontal/vertical, fixed dimensions/angles/radius, parallel relationships
- Command history with undo/redo
- Parameter mode for closed shapes
- Edge tagging (
E1,E2, ...), point tagging, expression-based point coordinates - Dependency-safe expression evaluation (topological ordering)
- Distance/angle/delta inspection
- Dimension line annotations
- Export generated shape JSON
- Save to MySQL via backend API
- Optional direct JSON download from UI modal
- User feedback via toasts and status modals
Three js - 2D Shape Editor/
|- README.md
|- package.json # Root dev orchestration (concurrently)
|- gsap-editor/ # React + Vite frontend
| |- src/
| | |- components/
| | |- tools/
| | |- constraints/
| | |- snap/
| | |- export/
| | |- api/
| | `- three/
| `- package.json
`- server/ # Express API + MySQL (+ optional Redis/BullMQ)
|- config/
|- db/
|- routes/
|- services/
`- package.json
Additional docs:
gsap-editor/PROJECT-DOCUMENTATION.mdgsap-editor/TOOL-GUIDE.md
- Frontend: React 19, Three.js, Vite
- Backend: Node.js, Express, MySQL (
mysql2) - Queue/async support: Redis + BullMQ (used by backend services)
- Tooling: ESLint, nodemon, concurrently
Note: GSAP remains in naming for legacy reasons, but animation tooling is not the core of this project.
- Node.js 18+ recommended
- npm
- MySQL 8+ running locally or remotely
- Redis (optional, for queue-based processing features)
From repo root:
npm install
cd server && npm install
cd ../gsap-editor && npm install
cd ..Create server/.env and set at least database credentials:
NODE_ENV=development
PORT=3001
CORS_ORIGIN=http://localhost:5173
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_password_here
DB_NAME=gsap_editor
DB_POOL_LIMIT=10
# Optional auth/claims
AUTH_DISABLED=true
JWT_SECRET=
JWT_CLAIM_USER_ID=sub
JWT_CLAIM_ORG_ID=organization_id
JWT_CLAIM_PROJECT_ID=project_id
# Optional queue settings
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_URL=redis://127.0.0.1:6379
SHAPE_JOB_LIST_KEY=gsap:shape-processing:jobs
BULLMQ_ENABLE_ACK_WORKER=true
BULLMQ_SHAPE_QUEUE=shape-processing- Create database
gsap_editorif it does not exist - Run SQL in
server/setup.sqlif you are starting from scratch - On startup, the backend also runs migration/bootstrap logic for required tables
npm run devThis starts:
- Backend API on
http://localhost:3001 - Frontend app on
http://localhost:5173
Backend:
cd server
npm run devFrontend:
cd gsap-editor
npm run devnpm run dev- run frontend + backend togethernpm run dev:server- run backend onlynpm run dev:frontend- run frontend only
npm run dev- start Vite dev servernpm run build- production buildnpm run preview- preview buildnpm run lint- run ESLint
npm run dev- run with nodemonnpm start- run with Node.jsnpm test- run Jest tests
Typical export flow from the editor:
- User creates geometry on canvas
- App generates normalized JSON payload
- Frontend
POSTs payload to/api/shapes - Backend validates and writes shape data to MySQL
- UI shows success/failure toast and export modal
- User can optionally download JSON locally
If backend is unavailable, local JSON download still supports offline workflow.
- Vite dev proxy forwards
/apitohttp://localhost:3001 - Backend startup checks and initializes database prerequisites
- In production mode, set
JWT_SECRETunless auth is explicitly disabled - If API port conflicts, change
PORTinserver/.env
- Frontend cannot reach API: verify backend is running and
PORTmatches Vite proxy target - Database connection fails: verify
DB_*env values and MySQL server status - Port already in use: change
PORTinserver/.env, restart server - CORS issues: confirm
CORS_ORIGINincludes your frontend URL
- Additional CAD operations (fillet/chamfer/boolean tools)
- Richer parametric expression authoring UI
- Batch export and shape templates
- Improved collaboration/versioning workflow
MIT