Development Setup
Prerequisites
| Tool | Version | Install |
|---|---|---|
| Node.js | 20+ | nodejs.org |
| pnpm | 8+ | npm install -g pnpm |
| Git | Any | git-scm.com |
IDE Setup
VS Code (Recommended)
Install these extensions:
- Svelte for VS Code - Svelte language support
- ESLint - Linting
- Prettier - Formatting
- TypeScript Vue Plugin - Vue/Svelte TypeScript
Settings
{ "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "typescript.preferences.importModuleSpecifier": "relative"}Project Scripts
Root Level
| Script | Description |
|---|---|
pnpm dev | Start all dev servers |
pnpm build | Production build |
pnpm start | Start production server |
pnpm lint | Run ESLint everywhere |
pnpm typecheck | TypeScript checks |
Frontend (apps/web)
| Script | Description |
|---|---|
pnpm dev | Vite dev server (port 5173) |
pnpm build | Build static files |
pnpm preview | Preview production build |
Backend (apps/server)
| Script | Description |
|---|---|
pnpm dev | ts-node-dev with hot reload |
pnpm build | Compile TypeScript |
pnpm start | Run compiled JS |
Debugging
Frontend (Browser DevTools)
- Open Chrome DevTools (F12)
- Go to Sources → Filesystem
- Add
apps/web/srcfolder - Set breakpoints in
.sveltefiles
Backend (VS Code)
Create .vscode/launch.json:
{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Attach to Server", "port": 9229, "restart": true } ]}Start server with inspect:
cd apps/serverpnpm dev --inspectSocket.io Debugging
Enable debug logs:
DEBUG=socket.io* pnpm devOr in browser console:
localStorage.debug = 'socket.io-client:*';Testing Locally
Multi-Player Testing
- Open 5+ browser tabs at
http://localhost:5173 - Each tab is a separate player
- Game auto-starts at 5 players
Private Room Testing
- Tab 1: Create private room → get code
- Tab 2-5: Join with room code
- Tab 1 (host): Start game manually
Mobile Testing
# Find your local IPifconfig | grep "inet "# → 192.168.1.x
# Access from phonehttp://192.168.1.x:5173Common Issues
”Port 3000 already in use"
# Find processlsof -i :3000# Kill itkill -9 <PID>"Cannot find module”
# Clear node_modules and reinstallrm -rf node_modules apps/*/node_modulespnpm installTypeScript Errors After Pull
# Restart TS server in VS CodeCmd+Shift+P → "TypeScript: Restart TS Server"Hot Reload Not Working
# Restart dev serverCtrl+Cpnpm devArchitecture Tips
Adding a Socket Event
- Define handler in
apps/server/src/socket.ts - Add Zod schema in
validation.ts - Add rate limit in
rateLimit.ts - Update client in
apps/web/src/lib/socketBridge.ts - Add types to both sides
Adding a Game Phase
- Add phase to
GamePhasetype - Implement logic in
phases.ts - Add timer handling
- Create UI component in
features/ - Handle in
socketBridge.ts
Adding a Component
Follow Atomic Design:
- Atom: Single-purpose, no business logic
- Molecule: 2-3 atoms combined
- Organism: Complex section
- Feature: Game phase with business logic