Commit Graph

88 Commits

Author SHA1 Message Date
Radosław Gierwiało
eda7055e08 docs: mark Phase 3 (MVP Finalization) as completed
Update project status to reflect completion of all MVP features:

Phase 3 achievements:
-  Security hardening (CSRF, rate limiting, account lockout)
-  All tests passing (223/223, 71% coverage)
-  PWA features (manifest, service worker, iOS support)
-  Production deployment preparation
-  Operations scripts (backup, restore, health-check)
-  Monitoring documentation

Status: 100% MVP complete, ready for production deployment
Next: Infrastructure setup (server, domain, SSL)
2025-11-20 22:24:35 +01:00
Radosław Gierwiało
642c8f6d6f feat: add production operations scripts and monitoring guide
Add comprehensive tooling for production deployment:

Scripts (scripts/):
- backup-db.sh: Automated database backups with 7-day retention
- restore-db.sh: Safe database restore with confirmation prompts
- health-check.sh: Complete service health monitoring
- README.md: Operational scripts documentation

Monitoring (docs/MONITORING.md):
- Application health monitoring
- Docker container monitoring
- External monitoring setup (UptimeRobot, Pingdom)
- Log monitoring and rotation
- Alerting configuration
- Incident response procedures
- SLA targets and metrics

All scripts include:
- Environment support (dev/prod)
- Error handling and validation
- Detailed status reporting
- Safety confirmations where needed
2025-11-20 22:22:22 +01:00
Radosław Gierwiało
2e194e1640 docs: update SESSION_CONTEXT.md with completed test fixes
- All 223/223 backend tests now passing (100%)
- Code coverage improved to 71% (from ~43%)
- Updated progress to ~95% (from ~90%)
- Removed 'improved test coverage' from What's Missing
- Added test isolation achievement to Phase 3 status
2025-11-20 22:14:07 +01:00
Radosław Gierwiało
ab1e4a5cc8 docs: update TODO.md with completed test fixes (223/223 passing) 2025-11-20 22:12:58 +01:00
Radosław Gierwiało
688f71343d test: fix test isolation by using unique test data per suite
- Add unique prefixes to test usernames (users_, matches_, events_)
- Add unique prefixes to test emails to prevent conflicts
- Add unique prefixes to event slugs and worldsdc_id values
- This prevents race conditions when Jest runs tests in parallel

Results:
- All 223 tests now passing (was 145/223)
- 14/14 test suites passing (was 11/14)
- Code coverage improved to 71.31% (from ~45%)

Fixes:
- users.test.js: Changed john_dancer → users_john_dancer
- matches.test.js: Changed to matches_ prefix
- events.test.js: Changed to events_ prefix + unique worldsdc_id
2025-11-20 22:12:09 +01:00
Radosław Gierwiało
fd0dcdf77f test: improve test cleanup with selective deletion
- Replace deleteMany({}) with selective deletion by username/email/slug in:
  - events.test.js (target specific test users/events only)
  - matches.test.js (target specific test users/events only)
  - csrf.test.js (target csrftest user only)
- Replace delete() with deleteMany() for resilient cleanup:
  - matches.test.js (2 inline cleanups)
  - socket-webrtc.test.js (1 inline cleanup)
- Update TODO.md with test status and future UX/UI improvements

Test improvement: 189/223 passing (84.8%), up from 145/223 (65%)
2025-11-20 00:05:24 +01:00
Radosław Gierwiało
d6f3eafeb2 fix(tests): improve socket.test.js cleanup to avoid test interaction issues
- Replace delete() with deleteMany() in all afterAll hooks (more resilient)
- Add checks for testUser existence before creating EventParticipant
- Add .catch() handlers to ignore duplicate or foreign key errors
- Add conditional checks with ?. before cleanup operations

Changes improve test isolation and prevent foreign key constraint
violations when tests run together. All socket tests now pass
individually (12/12 socket.test.js, 7/7 socket-webrtc.test.js).
2025-11-19 22:22:49 +01:00
Radosław Gierwiało
93c0943bfa fix(tests): fix backend test failures and improve test isolation
- Fixed CORS test in app.test.js to use allowed origin
- Updated auth-phase1.5.test.js to match actual error messages
- Fixed socket.test.js to use slug parameter instead of eventId
- Added EventParticipant records for socket event room tests
- Updated security config to allow both frontend origins in dev

All socket tests now passing (12/12). Test changes ensure proper
cleanup and prevent database conflicts by using selective deletion
instead of wiping entire tables.
2025-11-19 22:10:36 +01:00
Radosław Gierwiało
85a47f4e8e test: fix backend test cleanup to preserve production data
Replace deleteMany({}) with selective cleanup targeting only test data:

- events.test.js: Delete only test users (john_dancer, sarah_swings, mike_blues)
  and test events (test-dance-festival-2025) before creating new ones
- matches.test.js: Clean up john_dancer, sarah_swings, mike_moves and
  test-dance-festival slug specifically
- users.test.js: Remove only john_dancer and sarah_swings test users
  in both beforeAll and afterAll hooks
- auth.test.js: Target specific test usernames/emails (testuser, newuser,
  lockouttest, etc.) instead of all users
- auth-phase1.5.test.js: Clean up 12 specific test users by username/email
- socket.test.js: Add beforeAll cleanup for sockettest user to prevent
  conflicts from previous test runs
- socket-webrtc.test.js: Clean up webrtc_user1 and webrtc_user2 before
  creating them

Fix CORS configuration for tests:
- security.js: Add http://localhost:3000 to allowed origins in development
  mode to fix app.test.js CORS test (was failing with 500 error)

Results: Improved from 125/223 passing to 137/223 passing (12 more tests fixed)
All test data cleanup now uses WHERE clauses with specific usernames/emails/slugs
instead of wiping entire tables with deleteMany({})
2025-11-19 21:46:04 +01:00
Radosław Gierwiało
9d1af60f30 test(pwa): add comprehensive PWA and Vitest test suite
- Install Vitest and React Testing Library for frontend tests
- Configure Vitest with jsdom environment and coverage
- Add test setup file with global mocks (matchMedia, IntersectionObserver)
- Write InstallPWA component tests (14 tests):
  - iOS detection and manual installation instructions
  - Android/Chrome beforeinstallprompt event handling
  - Install and dismiss functionality
  - 7-day dismissal persistence (localStorage)
  - Installed state detection (standalone mode)
- Write PWA configuration tests (28 tests):
  - App icons existence (PNG and SVG)
  - iOS splash screens for multiple devices
  - Vite PWA plugin configuration
  - index.html meta tags (iOS PWA support)
  - Manifest schema validation
  - Service worker configuration (Workbox)
- Write service worker tests (24 tests):
  - Service worker registration and lifecycle
  - Workbox integration
  - Cache Storage API operations
- Migrate existing WebRTC tests from Jest to Vitest (25 tests):
  - Update imports to use Vitest (vi.fn, describe, it, expect)
  - Fix WebRTCWarning and webrtcDetection test expectations
- Add test scripts to package.json (test, test:watch, test:ui, test:coverage)

All 91 tests passing (InstallPWA: 14, PWA config: 28, Service Worker: 24,
WebRTC: 25 total across 2 files)
2025-11-19 21:24:34 +01:00
Radosław Gierwiało
f0a1bfb31a feat(pwa): add Progressive Web App support with iOS compatibility
- Install vite-plugin-pwa and workbox-window for PWA functionality
- Configure Vite with full PWA manifest (name, icons, theme, display)
- Add service worker caching for static assets only (no API cache)
- Create app icons (192x192, 512x512, apple-touch-icon)
- Generate iOS splash screens for multiple device sizes
- Add iOS-specific meta tags (apple-mobile-web-app-capable, etc.)
- Implement InstallPWA component with dual platform support:
  - Android/Chrome: beforeinstallprompt event with custom UI
  - iOS Safari: manual installation instructions with icons
- Add dismissal logic with 7-day localStorage persistence
- Update documentation to reflect 90% project completion

PWA implementation focuses on installability and static asset caching
while avoiding offline API cache (WebRTC requires active connection).
2025-11-19 20:59:26 +01:00
Radosław Gierwiało
bfbfd0e729 test: fix auth test expectations and add test commands to Makefile
- Update auth.test.js to match current API error messages
  - Registration success message includes email verification notice
  - Duplicate credentials use generic message to prevent user enumeration

- Add test commands to Makefile
  - make test: run all backend tests
  - make test-watch: run tests in watch mode
  - make test-coverage: run tests with coverage report

All auth tests now pass (19/19 ✓)
2025-11-19 20:23:25 +01:00
Radosław Gierwiało
44df50362a feat(security): implement comprehensive security hardening
- Add CSRF protection with cookie-based tokens
  - Add cookie-parser and csurf middleware
  - Create GET /api/csrf-token endpoint
  - Frontend automatically includes CSRF token in POST/PUT/DELETE requests
  - Add retry logic for expired CSRF tokens

- Implement account lockout mechanism
  - Add database fields: failedLoginAttempts, lockedUntil
  - Track failed login attempts and lock accounts after max attempts (configurable)
  - Auto-unlock after lockout duration expires
  - Return helpful error messages with remaining time

- Add comprehensive security environment variables
  - Rate limiting configuration (API, auth, email endpoints)
  - CSRF protection toggle
  - Password policy requirements
  - Account lockout settings
  - Logging levels

- Add comprehensive test coverage
  - 6 new tests for account lockout functionality
  - 11 new tests for CSRF protection
  - All tests handle enabled/disabled states gracefully

- Update documentation
  - Add Phase 3 security hardening to SESSION_CONTEXT.md
  - Document new database fields and migration
  - Update progress to 85%

Files changed:
- Backend: app.js, auth controller, security config, new migration
- Frontend: api.js with CSRF token handling
- Tests: auth.test.js (extended), csrf.test.js (new)
- Config: .env examples with security variables
- Docs: SESSION_CONTEXT.md updated
2025-11-19 20:16:05 +01:00
Radosław Gierwiało
cbc970f60b feat(nav): add responsive mobile dropdown menu with avatar and counters
- Hide desktop items on small screens, add Menu/X toggle
- Include Matches badge, History, Profile, and Logout
- Keep real-time pending matches counter
2025-11-15 23:09:45 +01:00
Radosław Gierwiało
38adf1e5a5 feat(ui): unify avatars across navbar, profiles, event/match chat
- Add reusable Avatar with fallback, status dot, ring
- Replace <img> uses in Navbar, Profile, PublicProfile
- Use Avatar in MatchChatPage and EventChatPage messages and sidebars
- Fix own-message detection for snake_case payloads
2025-11-15 23:08:00 +01:00
Radosław Gierwiało
6a17143ce1 feat(events): add client-side pagination and animations on /events\n\n- Show 5 nearest events (>= today-3d) by default\n- Add Load previous/Load later with smooth fade-slide-in for new items\n- Prevent animating existing items; preserve scroll on prepend\n- Show check-in prompt only for initial 5 events\n- Add keyframes utility in index.css 2025-11-15 22:44:21 +01:00
Radosław Gierwiało
b9d6f42ff5 feat(import): add WSDC list parser with location + update-missing-location option\n\n- Parse Event List for name/date/location/country/sourceUrl\n- Support --source list|calendar|auto and --update-missing-location\n- Keep calendar import for title/start/end/url fallback\n- Update CLI summary and docs (ADMIN_CLI.md, README.md) 2025-11-15 21:56:05 +01:00
Radosław Gierwiało
457de6c1c4 fix(cli): keep REPL alive on errors and consolidate help\n\n- Replace process.exit(1) with thrown errors in handlers\n- REPL catches and prints CLI errors without exiting\n- Consolidated help to include all commands and examples\n- Add events:import:wsdc command mapping and alias 2025-11-15 21:41:01 +01:00
Radosław Gierwiało
78f96e2849 feat(cli): add admin REPL + commands and docs
- Add CLI entry in backend with default REPL, persistent history, aliases
- Add commands: users:list/create/verify, events:list/details/participants/checkin,
  matches:list, logs:app, logs:messages
- Support running subcommands inside REPL via .cli and run()
- Add Makefile targets: dev-cli, prod-cli, dev/prod up/down (+rebuild)
- Update README and add docs/ADMIN_CLI.md
- Add CLI tests with mocked Prisma
2025-11-15 20:51:24 +01:00
Radosław Gierwiało
c7a37b2f5c docs: add TURN server testing tasks to WebRTC roadmap 2025-11-15 19:14:44 +01:00
Radosław Gierwiało
4d52c9f5d2 feat: add TURN servers for symmetric NAT traversal
- Add openrelay.metered.ca TURN servers for testing
- Support connections through symmetric NAT (mobile networks)
- Add TCP transport fallback for strict firewalls
- Enables P2P file transfer across different networks
2025-11-15 19:00:24 +01:00
Radosław Gierwiało
6bfc9b04d2 fix: add nginx config for SPA routing in production
- Create nginx.conf with try_files directive for React Router
- Update Dockerfile.prod to copy nginx configuration
- Fixes 404 errors on direct navigation to /login, /register, etc.
- Add gzip compression and static asset caching
2025-11-15 18:20:04 +01:00
Radosław Gierwiało
f5938f1a1e fix: use dynamic URLs for API and Socket.IO
- Change API_URL from hardcoded 'http://localhost:8080/api' to '/api'
- Change SOCKET_URL from hardcoded to window.location.origin
- Fixes production build connecting to wrong port
- Now works correctly in both dev (localhost:8080) and prod (localhost)
2025-11-15 18:03:40 +01:00
Radosław Gierwiało
e27da81346 refactor: use custom network name slc_network
- Define custom network 'slc_network' instead of default
- Add network configuration to all services
- Replace spotlightcam_default with slc_network
2025-11-15 17:37:34 +01:00
Radosław Gierwiało
e7014b4c03 refactor: shorten container names to slc-* prefix
Dev containers:
- spotlightcam-nginx → slc-proxy-dev
- spotlightcam-backend → slc-backend-dev
- spotlightcam-db → slc-db-dev
- spotlightcam-frontend → slc-frontend-dev

Prod containers:
- spotlightcam-nginx-prod → slc-proxy-prod
- spotlightcam-backend-prod → slc-backend-prod
- spotlightcam-db-prod → slc-db-prod
- spotlightcam-frontend-prod → slc-frontend-prod
2025-11-15 17:33:07 +01:00
Radosław Gierwiało
b948b81f80 refactor: use environment-specific .env files
- Rename .env.example to .env.development.example
- Update docker-compose.yml to use env_file for dev backend
- Update .gitignore to ignore .env.development and .env.production
- Remove generic .env and .env.example in favor of:
  * .env.development (dev) + .env.development.example (template)
  * .env.production (prod) + .env.production.example (template)
2025-11-15 17:26:16 +01:00
Radosław Gierwiało
a400068053 feat: add production Docker setup with multi-stage builds
- Add production Dockerfiles for frontend and backend
  * Frontend: multi-stage build with nginx serving static files
  * Backend: multi-stage build with Prisma generation
- Create production nginx configuration (nginx/conf.d.prod/)
  * Routes to frontend-prod:80 and backend-prod:3000
  * Supports WebSocket connections for Socket.IO
- Update docker-compose.yml to use production config
  * Add env_file support for backend-prod
  * Mount production nginx config directory
- Add .env.production.example template for deployment
2025-11-15 17:21:25 +01:00
Radosław Gierwiało
b50c20fae7 refactor: update homepage hero section messaging
Change hero title to 'Capture Every Round Together'
Update subtitle to focus on core value: recording rounds and quick video swaps
2025-11-15 16:48:29 +01:00
Radosław Gierwiało
95eebc3e63 docs: update documentation for Phase 2.5 completion and Phase 3 start
Update README.md:
- Add landing page to features
- Update test coverage section (43% backend, 116 tests passing)
- Add WebRTC tests information (7 tests passing)
- Update project structure (HomePage, hooks, utils, tests)
- Add STUN servers to WebRTC features
- Remove STUN/TURN and server upload fallback from Next Up
- Update roadmap to Phase 3 in progress
- Update test flow with landing page
- Update progress to ~80%

Update SESSION_CONTEXT.md:
- Current phase: Phase 3 (MVP Finalization) in progress
- Add landing page and WebRTC tests to What Works Now
- Update What's Missing (remove STUN, add coverage improvement)
- Add HomePage to routes and key files
- Add useWebRTC, webrtcDetection, test files to key files
- Update socket.js description with WebRTC signaling
- Update final status with all completed phases
- Update progress and date
2025-11-15 16:46:19 +01:00
Radosław Gierwiało
6086589f89 feat: add landing homepage with hero section and feature showcase
Create new HomePage component with:
- Hero section with CTAs for registration and login
- Features showcase highlighting WebRTC, matching, chat, security
- How it works section with 3-step process
- CTA section and footer with links
- Responsive design with gradient backgrounds

Update routing to show HomePage at / instead of redirecting to /events
2025-11-15 16:36:55 +01:00
Radosław Gierwiało
45a648b564 refactor: remove demo auth notice from login page 2025-11-15 16:33:22 +01:00
Radosław Gierwiało
91962ab4d5 test: add comprehensive WebRTC test suite
Add test coverage for WebRTC signaling and detection:

Backend tests (socket-webrtc.test.js):
- WebRTC offer/answer relay via Socket.IO
- ICE candidate exchange
- Authorization checks for match access
- Full WebRTC signaling flow
- All 7 tests passing

Frontend tests (ready for test runner):
- webrtcDetection.test.js: Browser WebRTC capability detection
- WebRTCWarning.test.jsx: Warning component rendering and interaction

Note: Frontend tests require test runner setup (e.g., Vitest)
2025-11-15 16:29:15 +01:00
Radosław Gierwiało
44839e0317 feat: switch to STUN servers for production NAT traversal
Changed WebRTC config from localhost-only to STUN servers:
- Removed rtcConfigLocalhost (no longer needed)
- Using rtcConfig with Google STUN servers
- Enables NAT traversal for users on different networks
- Removed unnecessary iceCandidatePoolSize config
- Link sharing remains as fallback for blocked users
2025-11-15 16:18:35 +01:00
Radosław Gierwiało
b6ed1db084 docs: update README and SESSION_CONTEXT for completed WebRTC implementation
Updated documentation to reflect Phase 2.5 completion:
- Moved WebRTC from 'Next Up' to 'Implemented' features
- Added WebRTC to tech stack
- Updated test flow with real WebRTC details
- Marked Phase 2.5 as COMPLETED in roadmap
- Updated progress to ~78% overall
- Updated SESSION_CONTEXT.md current status and missing features
2025-11-15 16:16:03 +01:00
Radosław Gierwiało
d23a12e5e3 feat: implement WebRTC P2P file transfer with detection and fallback
Implemented complete WebRTC peer-to-peer file transfer system for match chat:

**Core WebRTC Implementation:**
- Created useWebRTC hook with RTCPeerConnection and RTCDataChannel
- P2P file transfer with 16KB chunking for large files (tested up to 700MB)
- Real-time progress monitoring for sender and receiver
- Automatic file download on receiver side
- End-to-end encryption via DTLS (native WebRTC)
- ICE candidate exchange via Socket.IO signaling
- Support for host candidates (localhost testing)

**WebRTC Detection & User Experience:**
- Automatic WebRTC capability detection on page load
- Detects if ICE candidates can be generated (fails in Opera, privacy-focused browsers, VPNs)
- User-friendly warning component with fix suggestions
- Graceful degradation: disables WebRTC button when blocked
- Suggests alternative methods (video links via Google Drive/Dropbox)

**Socket.IO Improvements:**
- Fixed multiple socket instance creation issue
- Implemented socket instance reuse pattern
- Disabled React.StrictMode to prevent reconnection loops in development

**Technical Details:**
- RTCPeerConnection with configurable STUN servers (currently using localhost config)
- RTCDataChannel with ordered delivery
- Comprehensive logging for debugging (ICE gathering, connection states, signaling)
- Match room-based signaling relay via Socket.IO
- Authorization checks for all WebRTC signaling events

**Files Changed:**
- frontend/src/hooks/useWebRTC.js - Complete WebRTC implementation
- frontend/src/utils/webrtcDetection.js - WebRTC capability detection
- frontend/src/components/WebRTCWarning.jsx - User warning component
- frontend/src/pages/MatchChatPage.jsx - WebRTC integration
- frontend/src/services/socket.js - Socket instance reuse
- frontend/src/main.jsx - Disabled StrictMode for Socket.IO stability

**Testing:**
-  Verified working in Chrome (ICE candidates generated)
-  Tested with 700MB file transfer
-  Detection working in Opera (shows warning when WebRTC blocked)
-  P2P connection establishment and DataChannel opening
-  File chunking and progress monitoring

**TODO:**
- Add STUN server configuration for production (NAT traversal)
- Consider server-based upload fallback for blocked users
2025-11-15 16:12:02 +01:00
Radosław Gierwiało
664a2865b9 feat: implement WebRTC P2P file transfer with DataChannel
Add complete WebRTC peer-to-peer file transfer functionality:

Backend changes:
- Add WebRTC signaling events to Socket.IO (offer, answer, ICE candidates)
- Implement authorization checks for match participants
- Add signaling relay between matched users

Frontend changes:
- Create useWebRTC hook for RTCPeerConnection management
- Implement RTCDataChannel with 16KB chunking for large files
- Add real-time progress monitoring for sender and receiver
- Implement automatic file download on receiver side
- Add connection state tracking and error handling
- Integrate WebRTC with MatchChatPage (replace mockup)

Configuration:
- Add Vite allowed hosts configuration via VITE_ALLOWED_HOSTS env var
- Support comma-separated host list or 'all' for development
- Add .env.example with configuration examples
- Update docker-compose.yml with default allowed hosts

Documentation:
- Add comprehensive WebRTC testing guide with troubleshooting
- Add quick test checklist for manual testing
- Document WebRTC flow, requirements, and success criteria

Features:
- End-to-end encrypted P2P transfer (DTLS)
- 16KB chunk size optimized for DataChannel
- Buffer management to prevent overflow
- Automatic connection establishment with 30s timeout
- Support for files of any size
- Real-time progress tracking
- Clean connection lifecycle management
2025-11-15 14:12:51 +01:00
Radosław Gierwiało
6948efeef9 test: fix CORS test and remove duplicate events-checkin tests
- Fixed app.test.js CORS test by adding Origin header
- Removed duplicate events-checkin.test.js (covered by events.test.js)
- Improved app.js coverage to 97.43%

Note: Individual test files pass 100% when run separately:
- events.test.js: 34/34 passing (82% coverage)
- users.test.js: 25/25 passing (90% user.js, 82% users.js)
- matches.test.js: 24/24 passing (76% coverage)

Database conflicts occur when running all tests in parallel.
Consider using --runInBand for sequential execution.
2025-11-14 23:43:28 +01:00
Radosław Gierwiało
47a21b5fd6 test: add comprehensive test suite for User Profiles API
- Created users.test.js with 25 tests covering all 4 endpoints:
  * GET /api/users/me - get current user profile
  * PATCH /api/users/me - update profile (all fields)
  * PATCH /api/users/me/password - change password
  * GET /api/users/:username - get public profile
  * GET /api/users/:username/ratings - get user ratings

- All 25 tests passing (100%)
- controllers/user.js coverage: 90.16% (up from 8.19%)
- routes/users.js coverage: 81.81% (up from 27.27%)
- Tested email change with verification
- Tested password security and validation
2025-11-14 23:38:07 +01:00
Radosław Gierwiało
1747bf2d91 test: add comprehensive test suite for Events API
- Created events.test.js with 34 tests covering all 10 endpoints:
  * GET /api/events - list events with join status
  * GET /api/events/:slug - event details
  * GET /api/events/:slug/messages - event chat messages
  * POST /api/events/checkin/:token - QR code checkin
  * GET /api/events/:slug/details - detailed event info
  * DELETE /api/events/:slug/leave - leave event
  * POST /api/events/:slug/heats - add/update user heats
  * GET /api/events/:slug/heats/me - get user's heats
  * GET /api/events/:slug/heats/all - get all heats
  * DELETE /api/events/:slug/heats/:id - delete heat

- All 34 tests passing (100%)
- events.js coverage: 82.02% (up from 8.98%)
- Branch coverage: 75%
- Function coverage: 88.23%
2025-11-14 23:30:34 +01:00
Radosław Gierwiało
6697c1d60a test: fix remaining 5 test failures in matches.test.js
- Changed expected status from 404 to 403 for non-participant access
- Fixed rating response structure (data directly, not data.rating)
- Added testUser3 to setup to avoid duplicate match constraints
- Updated tests to use different user combinations to avoid conflicts

All 24 tests now passing (100%)
Coverage: matches.js improved to 76.58% statement coverage
2025-11-14 23:18:37 +01:00
Radosław Gierwiało
830f08edba test: add comprehensive test suite for Matches & Ratings API
- Created matches.test.js with 24 tests covering:
  * Match creation and validation
  * Match listing and filtering
  * Match acceptance workflow
  * Match deletion
  * Rating creation and validation
  * User ratings display

- Fixed Jest ES module issues:
  * Added mock for jsdom to bypass parse5 compatibility
  * Added mock for dompurify for test environment
  * Updated package.json with moduleNameMapper

Test results: 19/24 passing (79%)
Remaining: 5 tests need investigation
2025-11-14 23:12:08 +01:00
Radosław Gierwiało
e9f181052c docs: update documentation to reflect Phase 2 completion
- Mark Phase 2 (Matches & Ratings API) as completed in all docs
- Add new Ratings & Reviews section to README
- Update roadmap and progress tracking (72% complete)
- Document all Phase 2 features and endpoints in COMPLETED.md
- Reorganize TODO.md for Phase 2.5 (WebRTC) as next priority
2025-11-14 22:53:54 +01:00
Radosław Gierwiało
c2f4eddb55 feat: display user ratings on public profiles and add profile links
- Add comprehensive ratings section to PublicProfilePage showing average rating, individual reviews with comments, and collaboration preferences
- Make partner avatars and names clickable in MatchesPage and MatchChatPage to navigate to their public profiles
- Add hover effects on profile links for better UX
- Fetch and display ratings using ratingsAPI endpoint
2025-11-14 22:48:30 +01:00
Radosław Gierwiało
49e492a8f8 feat: implement Ratings API (Phase 2.5)
Complete the match lifecycle with partner rating functionality.

Backend changes:
- Add POST /api/matches/:slug/ratings endpoint to create ratings
  * Validate score range (1-5)
  * Prevent duplicate ratings (unique constraint per match+rater+rated)
  * Auto-complete match when both users have rated
  * Return detailed rating data with user and event info
- Add GET /api/users/:username/ratings endpoint to fetch user ratings
  * Calculate and return average rating
  * Include rater details and event context for each rating
  * Limit to last 50 ratings
- Add hasRated field to GET /api/matches/:slug response
  * Check if current user has already rated the match
  * Enable frontend to prevent duplicate rating attempts

Frontend changes:
- Update RatePartnerPage to use real API instead of mocks
  * Load match data and partner info
  * Submit ratings with score, comment, and wouldCollaborateAgain
  * Check hasRated flag and redirect if already rated
  * Validate match status before allowing rating
  * Show loading state and proper error handling
- Update MatchChatPage to show rating status
  * Replace "Rate Partner" button with "✓ Rated" badge when user has rated
  * Improve button text from "End & rate" to "Rate Partner"
- Add ratings API functions
  * matchesAPI.createRating(slug, ratingData)
  * ratingsAPI.getUserRatings(username)

User flow:
1. After match is accepted, users can rate each other
2. Click "Rate Partner" in chat to navigate to rating page
3. Submit 1-5 star rating with optional comment
4. Rating saved and user redirected to matches list
5. Chat shows "✓ Rated" badge instead of rating button
6. Match marked as 'completed' when both users have rated
7. Users cannot rate the same match twice
2025-11-14 22:35:32 +01:00
Radosław Gierwiało
c2010246e3 feat: add match slugs for security and fix message history loading
Security improvements:
- Add random CUID slugs to Match model to prevent ID enumeration attacks
- Update all match URLs from /matches/:id to /matches/:slug
- Keep numeric IDs for internal Socket.IO operations only

Backend changes:
- Add slug field to matches table with unique index
- Update all match endpoints to use slug-based lookups (GET, PUT, DELETE)
- Add GET /api/matches/:slug/messages endpoint to fetch message history
- Include matchSlug in all Socket.IO notifications

Frontend changes:
- Update all match routes to use slug parameter
- Update MatchesPage to use slug for accept/reject/navigate operations
- Update MatchChatPage to fetch match data by slug and load message history
- Update RatePartnerPage to use slug parameter
- Add matchesAPI.getMatchMessages() function

Bug fixes:
- Fix MatchChatPage not loading message history from database on mount
- Messages now persist and display correctly when users reconnect
2025-11-14 22:22:11 +01:00
Radosław Gierwiało
4a3e32f3b6 feat: implement Phase 2 - Matches API with real-time notifications
Backend changes:
- Add matches API routes (POST, GET, PUT, DELETE)
- Create/accept/reject match requests
- Auto-create private chat rooms on match acceptance
- Socket.IO notifications for match events (received, accepted, cancelled)
- Users join personal rooms (user_{id}) for notifications

Frontend changes:
- Add MatchesPage component with inbox UI
- Matches navigation link with notification badge
- Real-time match request count updates
- Accept/reject match functionality
- Filter matches by status (all/pending/accepted)
- Integrate match requests in EventChatPage (UserPlus button)

Features:
- Send match requests to event participants
- Accept incoming match requests
- Real-time notifications via Socket.IO
- Automatic private chat room creation
- Match status tracking (pending/accepted/completed)
- Authorization checks (only participants can match)
- Duplicate match prevention
2025-11-14 19:22:23 +01:00
Radosław Gierwiało
eaf80c6c6f feat: display user's heats in event chat header
- Show current user's heats in header next to connection status
- Display format: 'Your heats: J&J NOV 1 L, STR INT 2 L'
- Always visible - no need to click Edit Heats to see them
- Styled as badges matching sidebar heat badges
2025-11-14 18:41:06 +01:00
Radosław Gierwiało
3ebdd2d7df feat: pre-populate heats form with existing data when editing
- Add existingHeats prop to HeatsBanner component
- Load and format existing heats into form fields
- Pass myHeats to HeatsBanner in edit modal
- Users can now edit their heats instead of starting from scratch
2025-11-14 18:35:01 +01:00
Radosław Gierwiało
42f231a602 fix: correct participant data mapping in event chat sidebar
- Fix participant data structure mapping (use p.userId instead of p.user.id)
- Backend returns flat participant objects, not nested user objects
- Remove debug console.log statements
- Participants list now correctly displays all checked-in users
2025-11-14 18:10:35 +01:00
Radosław Gierwiało
e08492236a feat: show all checked-in participants in event chat sidebar
- Display all event participants (not just online users)
- Add online/offline status indicator (green/gray dot)
- Sort users: online first, then offline
- Show participant count and online count separately
- Load participants via /api/events/:slug/details endpoint
- Users can see who's checked in and has declared heats even when offline

This allows users to see the full picture of event participation,
not just who's currently connected to the chat.
2025-11-14 18:04:10 +01:00