@@ -240,3 +240,213 @@ LOG_LEVEL=info # debug | info | warn | error
240240### App
241241
242242No ` .env ` file - configuration via connection dialog on first launch.
243+
244+ ## CI/CD and Automation
245+
246+ ### GitHub Actions Workflows
247+
248+ The project has automated testing and release workflows:
249+
250+ ** tests.yml** - Runs on push to ` dev ` and ` main ` branches:
251+ - ** Server tests** : Go linting (golangci-lint) + ` make test `
252+ - ** Client tests** : ESLint + Vitest tests on Linux, macOS, and Windows
253+ - All tests must pass before merge
254+
255+ ** release.yml** - Runs on push to ` releases ` branch:
256+ - Builds production binaries for all platforms
257+ - Creates artifacts: ` .deb ` , ` .AppImage ` , ` .dmg ` , ` .app ` , ` .msi ` , ` .exe `
258+ - Server binary built with Go
259+
260+ ### Pre-commit Checklist
261+
262+ Before committing code changes:
263+ 1 . Run linters: ` npm run lint:fix ` (app) or ` make lint-fix ` (server)
264+ 2 . Run tests: ` npm test ` (app) or ` make test ` (server)
265+ 3 . Verify builds: ` npm run build ` (app) or ` go build ` (server)
266+ 4 . Test changes manually if UI-related
267+
268+ ### Adding New Tests
269+
270+ - ** App Tests** : Add ` .test.ts ` or ` .test.tsx ` files next to components/modules
271+ - ** Server Tests** : Add ` *_test.go ` files in same package as code under test
272+ - Use existing test patterns (see ` reconciliation.test.ts ` for comprehensive examples)
273+ - Mock external dependencies (Socket.IO, database, file system)
274+
275+ ## Dependency Management
276+
277+ ### Adding Dependencies
278+
279+ ** App (npm)** :
280+ ``` bash
281+ cd excalidraw-app
282+ npm install < package> # Production dependency
283+ npm install -D < package> # Dev dependency
284+ ```
285+ - Check package is maintained and has TypeScript types
286+ - Prefer packages with no/minimal transitive dependencies
287+ - Update ` package.json ` and commit ` package-lock.json `
288+
289+ ** Server (Go)** :
290+ ``` bash
291+ cd excalidraw-server
292+ go get < package> # Adds to go.mod
293+ go mod tidy # Cleans up unused deps
294+ ```
295+ - Use semantic versioning in go.mod
296+ - Prefer stdlib over third-party when possible
297+ - Run ` make test ` after adding dependencies
298+
299+ ### Updating Dependencies
300+
301+ ** App** :
302+ ``` bash
303+ cd excalidraw-app
304+ npm update # Update within semver ranges
305+ npm outdated # Check for newer versions
306+ ```
307+
308+ ** Server** :
309+ ``` bash
310+ cd excalidraw-server
311+ go get -u ./... # Update all dependencies
312+ go mod tidy
313+ ```
314+
315+ ** Security updates** : Renovate bot automatically creates PRs for dependency updates.
316+
317+ ## Security Best Practices
318+
319+ ### Code Security
320+
321+ - ** No hardcoded secrets** : Use environment variables for sensitive data
322+ - ** Validate input** : All user input (room IDs, drawing data) must be validated
323+ - ** Sanitize errors** : Don't expose internal paths or stack traces to clients
324+ - ** Use prepared statements** : SQLite queries use parameterized statements (already implemented)
325+
326+ ### Collaboration Security
327+
328+ - ** Room isolation** : Ensure room IDs properly isolate user sessions
329+ - ** Data validation** : Validate all WebSocket messages before processing
330+ - ** Rate limiting** : Consider adding rate limits for production deployments
331+ - ** CORS policy** : Server configured for localhost only; adjust for production
332+
333+ ### Deployment Security
334+
335+ - ** Use HTTPS** : Always use TLS in production (reverse proxy recommended)
336+ - ** Update dependencies** : Keep Go, Node, Rust, and packages up to date
337+ - ** Minimal permissions** : Run server with non-root user
338+ - ** Database backups** : Regularly backup SQLite databases
339+
340+ ## Debugging Strategies
341+
342+ ### App Debugging
343+
344+ ** Browser DevTools** :
345+ - Open DevTools (F12) to see React errors, console logs, network requests
346+ - Check Application tab → Local Storage for saved config
347+ - Check Network tab → WS for WebSocket messages
348+
349+ ** Tauri DevTools** :
350+ ``` bash
351+ cd excalidraw-app
352+ RUST_LOG=debug npm run tauri dev
353+ ```
354+ - Rust logs appear in terminal
355+ - Frontend logs in browser console
356+
357+ ** Common Issues** :
358+ - ** Blank screen** : Check browser console for errors
359+ - ** WebSocket fails** : Verify server URL in localStorage
360+ - ** Drawings not saving** : Check Tauri command errors in terminal
361+
362+ ### Server Debugging
363+
364+ ** Enable debug logging** :
365+ ``` bash
366+ cd excalidraw-server
367+ ./excalidraw-server --loglevel debug
368+ ```
369+ or set ` LOG_LEVEL=debug ` in ` .env `
370+
371+ ** Monitor WebSocket events** :
372+ ``` go
373+ // Add to handlers/websocket/collab.go
374+ log.WithField (" event" , eventName).Debug (" Received event" )
375+ ```
376+
377+ ** Database inspection** (SQLite):
378+ ``` bash
379+ sqlite3 excalidraw.db
380+ .schema # Show table structure
381+ SELECT * FROM documents; # View all documents
382+ ```
383+
384+ ** Common Issues** :
385+ - ** Port already in use** : ` lsof -i :3002 ` to find process
386+ - ** Database locked** : Check for multiple server instances
387+ - ** CORS errors** : Verify client origin in main.go CORS config
388+
389+ ## Code Review Guidelines
390+
391+ ### What to Look For
392+
393+ ** Type Safety** :
394+ - TypeScript: No ` any ` types without explicit reason
395+ - Go: No unchecked type assertions
396+ - Rust: Avoid unwrap() in favor of proper error handling
397+
398+ ** Error Handling** :
399+ - Always handle errors gracefully
400+ - Log errors with context (use ` logrus.WithField() ` in Go)
401+ - Show user-friendly messages to frontend
402+
403+ ** Performance** :
404+ - Debounce/throttle frequent operations (auto-save, broadcasts)
405+ - Avoid N+1 queries in database operations
406+ - Use indexes for frequently queried fields
407+
408+ ** Testing** :
409+ - Add tests for new features (especially reconciliation logic)
410+ - Update tests when changing existing behavior
411+ - Ensure tests are deterministic (no random failures)
412+
413+ ### Code Style
414+
415+ ** TypeScript/React** :
416+ - Use functional components with hooks
417+ - Prefer ` const ` over ` let `
418+ - Use destructuring for props
419+ - Follow existing ESLint rules
420+
421+ ** Go** :
422+ - Follow standard Go formatting (gofmt)
423+ - Use meaningful variable names
424+ - Keep functions small and focused
425+ - Document exported functions
426+
427+ ** Rust** :
428+ - Use ` Result<T, E> ` for error handling
429+ - Follow Clippy suggestions
430+ - Use ` #[tauri::command] ` for all commands
431+ - Keep commands simple, move logic to separate modules
432+
433+ ## Contributing Workflow
434+
435+ ### Making Changes
436+
437+ 1 . ** Create feature branch** : ` git checkout -b feature/your-feature `
438+ 2 . ** Make changes** : Follow code style and patterns
439+ 3 . ** Test locally** : Run linters, tests, and manual testing
440+ 4 . ** Commit** : Use clear, descriptive commit messages
441+ 5 . ** Push** : ` git push origin feature/your-feature `
442+ 6 . ** Open PR** : GitHub Actions will run tests automatically
443+
444+ ### Pull Request Checklist
445+
446+ - [ ] Code follows existing patterns and style
447+ - [ ] Linters pass (` npm run lint ` / ` make lint ` )
448+ - [ ] Tests pass (` npm test ` / ` make test ` )
449+ - [ ] New tests added for new functionality
450+ - [ ] Documentation updated if needed
451+ - [ ] No hardcoded credentials or secrets
452+ - [ ] Works on dev/main branch (check for conflicts)
0 commit comments