A collaborative web app for playing the coLoc board game—teaching co-localization analysis in microscopy. Game Master runs sessions; teams join with a code, get assigned experiments, and plan acquisition and analysis cards. Review phase uses issue and details cards with a dice roll for experimental details.
- Node.js 18 or newer (includes npm)
- If you don't have Node: install from nodejs.org (LTS) or with
brew install nodeon macOS.
-
Install dependencies (first time only):
npm install
-
Start the dev server:
npm run dev
-
Open in a browser
Use the URL printed in the terminal (e.g.http://localhost:5173).
No build step or backend is required for local play. All assets (logo, card images, experiment images) live inside the project under public/.
-
Start the backend (from project root):
cd server npm install npm startServer runs on port 3001. Leave this terminal open.
-
Create
.envin the project root:VITE_SOCKET_URL=http://YOUR_LOCAL_IP:3001Replace
YOUR_LOCAL_IPwith your machine's IP (e.g.192.168.1.5). -
Start the frontend (new terminal, from project root):
npm run dev
-
Share the URL
Other players on the same network openhttp://YOUR_LOCAL_IP:5173, choose Team, enter the session code, and join.
To let anyone on the internet play together, deploy the frontend to GitHub Pages and the backend to a Node host.
The backend must run on a service that supports Node.js. Two straightforward options:
-
Create an account at railway.app.
-
Click New Project → Deploy from GitHub repo (or upload the
server/folder). -
If using GitHub: select the repo, then set the root directory to
server(or only deploy theserver/folder). -
Railway auto-detects Node. Ensure the start command is:
node index.js
(or
npm startif yourpackage.jsonhas it). -
Click Deploy. When it finishes, open Settings → Networking → Generate Domain. Copy the URL (e.g.
https://coloc-game-production-xxxx.up.railway.app). -
Save this URL — you'll use it as
VITE_SOCKET_URLwhen building the frontend.
-
Create an account at render.com.
-
Click New → Web Service.
-
Connect your GitHub repo (or upload the project). Set the root directory to
server. -
Configure:
- Build command:
npm install - Start command:
npm startornode index.js
- Build command:
-
Click Create Web Service. Render will build and deploy.
-
Once deployed, copy the service URL (e.g.
https://coloc-game.onrender.com). -
Save this URL — you'll use it as
VITE_SOCKET_URLwhen building the frontend.
-
Push the project to GitHub
Create a repo and push thecoloc-gameproject (or the folder containing it). -
Set the base path in Vite
If the app will be athttps://username.github.io/coloc-game/(repo name as subpath), addbasetovite.config.ts:export default defineConfig({ base: '/coloc-game/', // Replace with your repo name plugins: [react()], // ... });
If the repo is
username.github.io(user/organization site), usebase: '/'. -
Build the frontend with the backend URL
Replacehttps://your-backend-url.example.comwith the URL from Part 1:VITE_SOCKET_URL=https://your-backend-url.example.com npm run build
This creates the
dist/folder with the production app. -
Deploy
dist/to GitHub PagesMethod A: Using
gh-pages(recommended)npm install --save-dev gh-pages
Add to
package.json(adjust thedeployscript andhomepage):"scripts": { "deploy": "gh-pages -d dist" }, "homepage": "https://YOUR_USERNAME.github.io/coloc-game"
Replace
YOUR_USERNAMEandcoloc-gamewith your GitHub username and repo name.Build and deploy (run the build with your backend URL, then deploy):
VITE_SOCKET_URL=https://your-backend-url.example.com npm run build npm run deploy
The first time,
gh-pageswill prompt for your GitHub credentials. It pushes the contents ofdist/to thegh-pagesbranch.Method B: Using GitHub Actions
Create
.github/workflows/deploy.yml:name: Deploy to GitHub Pages on: push: branches: [main] jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - run: npm ci - run: npm run build env: VITE_SOCKET_URL: ${{ secrets.VITE_SOCKET_URL }} - uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./dist
In your repo, go to Settings → Secrets and variables → Actions → New repository secret. Add
VITE_SOCKET_URLwith your backend URL.Push to
main; the workflow will build and deploy automatically. -
Enable GitHub Pages
In the repo: Settings → Pages → Source: select Deploy from a branch → gh-pages branch → / (root) → Save. -
Share the URL
After a few minutes, the app is live athttps://YOUR_USERNAME.github.io/coloc-game/(or your custom domain). Share this URL with players.
| Step | Action |
|---|---|
| 1 | Deploy backend to Railway or Render; copy the live URL |
| 2 | Set base in vite.config.ts to match your GitHub Pages path |
| 3 | Build with VITE_SOCKET_URL set to the backend URL |
| 4 | Deploy dist/ to GitHub Pages (gh-pages or Actions) |
| 5 | Share the GitHub Pages URL with players |
| Command | Description |
|---|---|
npm run dev |
Start dev server (hot reload) |
npm run build |
Production build to dist/ |
npm run preview |
Preview production build |
Backend (from server/): npm start (listens on port 3001). Use npm run kill-port to free port 3001 if needed, or npm run dev:fresh to kill and restart.
- React 18 + Vite + TypeScript
- Zustand (state; syncs with server when
VITE_SOCKET_URLis set) - Socket.io (client + server for remote play)
- TailwindCSS
- Physical game & resources: biop.github.io/coLoc
- GitHub: github.com/BIOP/coLoc