Skip to content

Contributing to Watch Together

Thank you for your interest in contributing to Watch Together! This document provides guidelines and instructions for contributing.

  • Docker & Docker Compose - For containerized development
  • Node.js 20+ - For frontend development
  • Python 3.11+ - For backend development
  • Git - Version control
Section titled “Option 1: Docker Development (Recommended)”
Terminal window
# Clone the repository
git clone https://github.com/rennerdo30/watch-together.git
cd watch-together
# Copy environment file
cp .env.example .env
# Start all services with hot-reload
docker compose up -d --build
# View logs
docker compose logs -f

Services:

Terminal window
# Backend
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8000
# Frontend (new terminal)
cd frontend
npm install --legacy-peer-deps
npm run dev

For local development without Cloudflare, set DEVELOPMENT_MODE=true and use the ?user= query parameter:

Terminal window
# Backend must have DEVELOPMENT_MODE enabled
DEVELOPMENT_MODE=true uvicorn main:app --reload --port 8000
http://localhost:3000/room/[email protected]

Note: The ?user= query parameter only works when DEVELOPMENT_MODE=true is set. This is disabled by default to prevent user impersonation in production.

watch-together/
├── backend/
│ ├── main.py # FastAPI app, endpoints, proxy
│ ├── connection_manager.py # WebSocket room management
│ ├── services/
│ │ ├── resolver.py # yt-dlp video resolution
│ │ ├── database.py # SQLite persistence
│ │ └── cache.py # Memory/disk caching
│ ├── api/routes/ # API route modules
│ └── core/ # Config, security
├── frontend/
│ ├── app/ # Next.js App Router pages
│ │ ├── page.tsx # Home page
│ │ └── room/[id]/ # Room page
│ ├── components/
│ │ ├── custom-player.tsx # Main video player
│ │ ├── player-controls.tsx
│ │ ├── player/hooks/ # useShakaPlayer, useHlsPlayer, etc.
│ │ └── sortable-queue-item.tsx
│ └── lib/
│ ├── api.ts # Backend API client
│ ├── abr.ts # Latency-aware bandwidth sampling for Shaka
│ └── hooks/ # useRoomSettings, useLocalStorageState
├── extension/ # Browser extension
├── nginx/ # Nginx configuration
└── docker-compose.yml
File Purpose
backend/main.py API endpoints, video proxy, app initialization
backend/connection_manager.py WebSocket room state, sync logic
backend/services/resolver.py yt-dlp integration, format selection
frontend/components/custom-player.tsx Video player component
frontend/components/player/hooks/useDashSync.ts A/V sync for DASH streams
frontend/lib/hooks/useRoomSync.ts WebSocket room synchronization
  • TypeScript: Strict mode enabled, use proper types
  • React: Functional components with hooks
  • Styling: TailwindCSS classes only (no CSS modules)
  • Imports: Use absolute imports (@/components/...)
// Good
const MyComponent: React.FC<Props> = ({ value }) => {
const [state, setState] = useState<string>('');
return (
<div className="flex items-center gap-2">
{/* ... */}
</div>
);
};
// Avoid
class MyComponent extends React.Component { } // Use functional
import styles from './styles.module.css'; // Use Tailwind
  • Type Hints: Required on all function signatures
  • Async: Use async/await for all I/O operations
  • Models: Pydantic for request/response validation
  • Style: PEP 8 with 100 character line limit
# Good
async def get_video(url: str, user_email: str | None = None) -> VideoResponse:
"""Resolve video URL and return stream info."""
result = await resolver.extract(url)
return VideoResponse(url=result.url, title=result.title)
# Avoid
def get_video(url, user_email=None): # Missing types
result = resolver.extract(url) # Sync call
  1. Define Pydantic models in backend/api/models.py (or relevant file)
  2. Add route in backend/api/routes/ or backend/main.py
  3. Add corresponding API call in frontend/lib/api.ts
  1. Add handler in backend/connection_manager.py:
    elif msg_type == "my_new_type":
    await self._handle_my_new_type(room_id, data, websocket)
  2. Update frontend/lib/hooks/useRoomSync.ts to send/receive
  • Core player logic: frontend/components/custom-player.tsx
  • A/V sync (DASH): frontend/components/player/hooks/useDashSync.ts
  • HLS playback: frontend/components/player/hooks/useHlsPlayer.ts
  • UI controls: frontend/components/player-controls.tsx
Terminal window
cd frontend
npm run build # Type checking + build
npm run lint # ESLint
Terminal window
cd backend
python -m py_compile main.py connection_manager.py services/*.py # Syntax check
pytest # Run tests (if available)
Terminal window
# Frontend must build without errors
cd frontend && npm run build
# Backend must compile without errors
cd backend && python -m py_compile main.py connection_manager.py

This repository uses GitHub Actions for quality, security, and release automation:

  • CI (.github/workflows/ci.yml): backend tests, frontend lint/build, extension sanity checks
  • CodeQL (.github/workflows/codeql.yml): security scanning for Python and TypeScript/JavaScript
  • Container Publish (.github/workflows/docker-publish.yml): publish backend/frontend images to GHCR on main
  • Chrome Extension Nightly (.github/workflows/extension-nightly.yml): package the MV3 extension on every main commit and refresh the rolling nightly prerelease
  • Dependabot (.github/dependabot.yml): automated dependency update pull requests
  1. Fork the repository
  2. Create a branch: git checkout -b feature/amazing-feature
  3. Make changes following the code style guidelines
  4. Test your changes locally
  5. Commit using conventional commits:
    • feat: New feature
    • fix: Bug fix
    • refactor: Code refactoring
    • docs: Documentation
    • chore: Maintenance
  6. Push: git push origin feature/amazing-feature
  7. Open a Pull Request with:
    • Clear description of changes
    • Screenshots for UI changes
    • Test steps if applicable
feat: add subtitle support for HLS streams
fix: prevent audio desync during seek operations
refactor: extract video player into separate hooks
docs: update deployment guide for Cloudflare

Use GitHub Issues with:

  • Bug reports: Steps to reproduce, expected vs actual behavior, browser/OS info
  • Feature requests: Clear description of the feature and use case
  • Questions: Check existing issues first, then ask

Please report vulnerabilities privately as described in SECURITY.md. Do not open public issues for potential security vulnerabilities.

When contributing code, keep these security measures in mind:

  • SSRF Protection: Any new endpoints that accept URLs must validate them via validate_proxy_url() to block access to private/internal networks
  • CORS: Origins are configured via ALLOWED_ORIGINS env var. Never hardcode allow_origins=["*"] with allow_credentials=True
  • Authentication: The ?user= query param auth is gated behind DEVELOPMENT_MODE env var. Never add unauthenticated access paths in production code
  • Input Validation: Room IDs are sanitized to [a-zA-Z0-9_-]. Validate all user inputs at system boundaries
  • Cookie Handling: Cookie uploads are limited to 1MB and validated for Netscape format. Apply similar validation to new cookie-accepting endpoints
  • WebSocket Limits: Connection limits are enforced per-room (50) and per-user (10). Consider resource implications when adding new WebSocket features
  • Docker: Container images are pinned to specific versions. Resource limits are configured. Internal services are not exposed on host ports

By participating in this project, you agree to follow the Code of Conduct.

Feel free to open an issue or discussion if you have questions about contributing!