Add account tier system (BASIC/SUPPORTER/COMFORT) to reduce recording burden for premium users while maintaining fairness through karma-based assignment. Database Changes: - Add AccountTier enum (BASIC, SUPPORTER, COMFORT) - Add User.accountTier with BASIC default - Add User.recordingsDone and User.recordingsReceived for karma tracking - Add EventParticipant.accountTierOverride for event-specific tier upgrades - Migration: 20251129220604_add_account_tiers_and_recording_stats Matching Algorithm Updates: - Implement fairness debt calculation: receivedCount - doneCount - Apply tier penalties: SUPPORTER (-10), COMFORT (-50) - New sorting priority: Location > Fairness > Load balancing - Add getEffectiveTier() helper for tier resolution with override support - Add getRecordingStatsForUsers() for fetching karma statistics Tier Behavior: - BASIC: Normal recording frequency (baseline, no penalty) - SUPPORTER: Moderately reduced frequency (fairness penalty -10) - COMFORT: Significantly reduced frequency (fairness penalty -50) - All tiers can still be assigned when no better candidates available Constants: - ACCOUNT_TIER enum in src/constants/tiers.js - FAIRNESS_SUPPORTER_PENALTY = 10 - FAIRNESS_COMFORT_PENALTY = 50 Tests: - Update tests for dual buffer system semantics - All 30 tests passing - Fix imports: HEAT_BUFFER → HEAT_BUFFER_BEFORE
spotlight.cam Backend
Node.js + Express backend for spotlight.cam - P2P video exchange app for dance events.
Features
- ✅ Express REST API
- ✅ CORS enabled
- ✅ Health check endpoint
- ✅ Error handling
- ✅ Unit tests (Jest + Supertest)
- ⏳ PostgreSQL integration (planned)
- ⏳ JWT authentication (planned)
- ⏳ Socket.IO for real-time chat (planned)
- ⏳ WebRTC signaling (planned)
API Endpoints
Health Check
GET /api/health- Backend health status
Future Endpoints
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/users/me- Get current userGET /api/events- List eventsPOST /api/matches- Create matchPOST /api/ratings- Rate partner
Development
Install dependencies
npm install
Run in development mode
npm run dev
Run tests
npm test
Run tests in watch mode
npm run test:watch
Run in production mode
npm start
Environment Variables
Create a .env file (see .env.example):
NODE_ENV=development
PORT=3000
CORS_ORIGIN=http://localhost:8080
Project Structure
backend/
├── src/
│ ├── __tests__/ # Unit tests
│ │ └── app.test.js
│ ├── routes/ # API routes (future)
│ ├── controllers/ # Business logic (future)
│ ├── middleware/ # Custom middleware (future)
│ ├── utils/ # Helper functions (future)
│ ├── app.js # Express app setup
│ └── server.js # Server entry point
├── .env # Environment variables (gitignored)
├── .env.example # Environment variables template
├── package.json
└── Dockerfile
Testing
Tests are written using:
- Jest - Test framework
- Supertest - HTTP assertions
Run tests:
npm test
Current test coverage:
- Health check endpoint
- 404 error handling
- CORS configuration
- JSON body parsing
Docker
Build and run with Docker Compose (from project root):
docker compose up --build
Backend will be available at:
- Internal: http://backend:3000
- Through nginx: http://localhost:8080/api
Next Steps
- ✅ Basic Express setup
- ✅ Health check endpoint
- ✅ Unit tests
- ⏳ PostgreSQL connection
- ⏳ Database schema and migrations
- ⏳ Authentication (JWT + bcrypt)
- ⏳ Socket.IO for real-time chat
- ⏳ WebRTC signaling
License
TBD