StarSync is a realtime collaboration workspace for chat, direct messages, shared coding rooms, whiteboard sessions, and contest-style problem solving. It uses a React/Vite frontend, an Express/TypeScript backend, native WebSockets, Prisma, PostgreSQL, Redis-backed sessions, Monaco, tldraw, Liveblocks, and a local Piston runner for code execution.
- HttpOnly cookie authentication with Redis sessions
- Realtime group rooms and direct messages over native
ws - Persistent chat history, unread states, typing indicators, and online presence
- Collaborative code editor with autosave and active collaborator presence
- Whiteboard collaboration through tldraw and Liveblocks
- Competing rooms with assigned problem-bank questions
- Run Code execution against visible/sample testcases only
- Piston-backed code runner for JavaScript, TypeScript, Python, C, and C++
- Responsive dark workspace UI for dashboard, chat, editor, and contest rooms
| Area | Stack |
|---|---|
| Frontend | React, TypeScript, Vite, Tailwind CSS, Monaco, tldraw |
| Backend | Node.js, Express, TypeScript, native ws |
| Database | PostgreSQL with Prisma |
| Sessions | Redis + HttpOnly sid cookie |
| Code runner | Piston Docker API |
| Whiteboard auth | Liveblocks server token endpoint |
StarSync/
|- Starsync_backend/
| |- prisma/
| |- src/
| | |- config/
| | |- controllers/
| | |- middleware/
| | |- routes/
| | |- services/
| | |- types/
| | |- validations/
| | `- websocket/
| `- CODE_RUNNER.md
|- Starsync_frontend/
| |- public/
| `- src/
| |- components/
| |- context/
| |- hooks/
| |- layouts/
| |- pages/
| |- services/
| |- types/
| `- utils/
|- deploy/
`- docker-compose.piston.ymlflowchart LR
User[Browser] --> Frontend[React Frontend]
Frontend -->|HTTP + sid cookie| API[Express API]
Frontend -->|WebSocket + sid cookie| WS[Native WS Server]
API --> Session[Redis Sessions]
WS --> Session
API --> DB[(PostgreSQL)]
WS --> DB
API --> Piston[Piston Runner]
API --> Liveblocks[Liveblocks Auth]
flowchart TD
A[Sign up or log in] --> B[Dashboard]
B --> C[Join room]
B --> D[Create collaborative room]
B --> E[Create competing room]
C --> F[Chat workspace]
D --> F
F --> G[Chat]
F --> H[Editor]
F --> I[Whiteboard]
E --> J[Competing workspace]
J --> K[Assigned DB problems]
K --> L[Run visible testcases]
J --> M[Submission history]
- Node.js and npm
- PostgreSQL database, Neon works well
- Redis for session storage, local or hosted
- Docker Desktop for the optional local Piston code runner
- Liveblocks secret key for the whiteboard tab
Start Redis before running authenticated routes. A local Redis instance should match REDIS_URL=redis://localhost:6379.
cd Starsync_backend
npm install
copy .env.example .envUpdate Starsync_backend/.env:
PORT=3001
CLIENT_ORIGIN=http://localhost:5173
FRONTEND_URL=http://localhost:5173
DATABASE_URL="postgresql://USER:[email protected]/DATABASE?sslmode=require"
REDIS_URL=redis://localhost:6379
SESSION_COOKIE_NAME=sid
SESSION_TTL_SECONDS=604800
CODE_RUNNER_URL=http://localhost:2000/api/v2
LIVEBLOCKS_SECRET_KEY=your_liveblocks_secret_keyApply Prisma setup:
npx prisma generate
npx prisma migrate deploy
npx prisma db seedRun the backend:
npm run devBackend URL:
http://localhost:3001cd Starsync_frontend
npm install
copy .env.example .envUpdate Starsync_frontend/.env if needed:
VITE_API_URL=http://localhost:3001/api/v1
VITE_WS_URL=ws://localhost:3001/wsRun the frontend:
npm run devFrontend URL:
http://localhost:5173StarSync sends code execution requests to a Piston-compatible API. Start the local runner from the repository root:
docker compose -f docker-compose.piston.yml up -dCheck installed runtimes:
Invoke-RestMethod http://localhost:2000/api/v2/runtimesStop the runner:
docker compose -f docker-compose.piston.yml downMore details are in Starsync_backend/CODE_RUNNER.md.
Chat, direct messages, room presence, typing, timers, editor sync, and contest events use the app WebSocket server. The whiteboard uses Liveblocks because canvas synchronization is a separate high-frequency collaboration problem.
Whiteboard access still follows StarSync room membership rules:
- Frontend requests
POST /api/v1/liveblocks/auth. - Backend verifies the
sidsession cookie. - Backend checks room membership.
- Backend returns a Liveblocks token scoped to the room.
Competing rooms use the problem bank stored in PostgreSQL:
- Room creation stores difficulty/topic preferences.
- The backend assigns four available problems to the room.
- The frontend loads P1/P2/P3/P4 from
GET /api/v1/rooms/:roomId/problems. - Run Code calls
POST /api/v1/rooms/:roomId/problems/run. - Only visible/sample testcases are executed and returned.
- Hidden testcases stay private and are not returned to the frontend.
- Submit and leaderboard behavior are intentionally separate from Run Code.
Use separate terminals:
# Terminal 1: Piston runner
cd <repo-root>
docker compose -f docker-compose.piston.yml up -d# Terminal 2: backend
cd <repo-root>\Starsync_backend
npm run dev# Terminal 3: frontend
cd <repo-root>\Starsync_frontend
npm run devOpen http://localhost:5173.
# Backend
cd Starsync_backend
npm run build
npx prisma validate
npx prisma migrate deploy
npx prisma db seed# Frontend
cd Starsync_frontend
npm run lint
npm run build
npm run preview# Piston
cd <repo-root>
docker compose -f docker-compose.piston.yml ps
docker compose -f docker-compose.piston.yml downThe deploy/ folder contains an example same-origin production setup with Nginx. Same-origin deployment is recommended because the frontend, API, WebSocket server, and HttpOnly sid cookie work best behind one public domain.
For Vercel frontend deployment, make sure the project root is set to:
Starsync_frontendUse:
Build command: npm run build
Output directory: distCheck that Redis is running and REDIS_URL is correct. The app uses a Redis-backed HttpOnly sid cookie for both HTTP and WebSocket auth.
Confirm CLIENT_ORIGIN and FRONTEND_URL match the frontend URL, usually http://localhost:5173.
Start Docker Desktop and run:
docker compose -f docker-compose.piston.yml up -d
Invoke-RestMethod http://localhost:2000/api/v2/runtimesCheck DATABASE_URL. Neon URLs usually need sslmode=require.
This repository does not include .env files, node_modules, dist, local Piston runtime data, or local planning notes. Create environment files from the provided examples before running the app.