How elementalmp4/netflixparty works
1. Overall shape
- This repo is a Java backend plus a Chrome extension. The backend serves HTTP pages and a WebSocket gateway, while the extension embeds UI into Netflix and coordinates room/chat playback behavior.
2. Browser extension boundary
- The extension/ folder is the client-side product surface for Chrome.
- manifest.json wires together popup, room creation, share-room screens, CSS, and the Netflix page injection script.
- netflix-party-interface.js is the key content script: it runs in the Netflix page context and connects the extension UI to playback/chat actions.
- popup.js, createroom.js, and shareroom.js implement the room workflow in the extension UI.
- The README notes that RESOURCE_URL in the JS must point at the deployed server, so the extension is tightly coupled to the backend endpoint location.
3. Server bootstrap
- src/main/java/de/voidtech/netflixparty/NetflixParty.java is the application entrypoint.
- The server is configured through properties such as http.port and cache flags in a config file read by the backend.
- ConfigService and FileReader are the supporting pieces for loading runtime configuration and static file content.
4. HTTP layer
- api/http/HttpRestController and HttpErrorController form the HTTP-facing boundary.
- This layer likely serves the public website under www/ and handles non-real-time endpoints needed by the extension or room pages.
- HttpErrorController centralizes error responses, which matters because browser clients will hit these routes directly.
5. WebSocket gateway
- api/websocket/GatewayConfiguration and GatewayHandler define the real-time transport used for party synchronization.
- This is the core collaboration channel for room membership, chat, typing state, and playback events.
- The architecture is event-driven: browser clients send messages into the gateway, and the server relays state updates back out to room participants.
6. Message dispatch architecture
- service/MessageHandler is the dispatcher that routes inbound gateway messages to the correct handler.
- The custom annotations/Handler suggests a handler-registration model rather than hardcoded switch logic.
- Concrete handlers in handlers/ separate concerns by message type: create room, join room, ping, typing updates, play, pause, and chat.
7. Room and synchronization workflows
- CreatePartyHandler and JoinPartyHandler manage room lifecycle and membership.
- VideoPlayHandler, VideoPauseHandler, and TypingUpdateHandler coordinate synchronized user actions across clients.
- PingHandler likely keeps connections and room membership alive or measures latency.
- These handlers are the main business events that move through the system.
8. Domain model
- entities/Party represents the shared room state.
- entities/message/ChatMessage, SystemMessage, and MessageBuilder model the payloads flowing over the WebSocket/API boundary.
- This separation implies the server treats playback/chat updates as structured messages rather than raw text.
9. Service layer
- PartyService owns room-level state and lifecycle logic.
- ChatMessageService handles chat creation/formatting/dispatch.
- GatewayResponseService likely standardizes responses sent back through the gateway.
- DatabaseService indicates persistence exists behind an abstraction, even if the concrete database is not visible in the tree.
10. Static website
- www/ contains a public-facing site with HTML, CSS, JS, images, and a Netflix-branded landing page.
- www/js/netflix.js is likely the client-side logic for the public site or room entry flow.
- This is distinct from the Chrome extension: the site is server-hosted web content, while the extension is the in-browser Netflix integration.
11. Execution path
- A user creates or joins a room in the extension.
- The extension talks to the backend over HTTP/WebSocket.
- The backend validates/updates room state through services and handlers.
- Playback/chat events are broadcast back to all connected room members through the gateway.
12. Important architectural boundary
- The system is centered on browser clients synchronized by a Java server, not on a standalone client app.
- The main integration points are:
- Netflix page injection from the extension
- Server-hosted HTTP pages
- Real-time WebSocket room synchronization
- Configuration-driven server URL and port selection
Main entry points: HttpRestController.java HTTP controller · MessageHandler.java Message handler · manifest.json Manifest · netflix-party-interface.js Netflix interface
Components 22
Chrome extension
Browser-side product surface injected into Netflix and used for room creation and control.
- Manifest · Wires popup, room screens, CSS, and Netflix injection.
extension/manifest.json - Netflix interface · Runs in the Netflix page and bridges playback/chat actions.
extension/js/netflix-party-interface.js - Popup UI · Entry UI for the browser extension.
extension/js/popup.js - Create room · Creates a new party from the extension UI.
extension/js/createroom.js - Share room · Shares room details with other participants.
extension/js/shareroom.js
Java backend
Server application handling HTTP pages, configuration, and real-time room synchronization.
- NetflixParty · Server application entrypoint and bootstrap.
src/main/java/de/voidtech/netflixparty/NetflixParty.java - Config service · Loads server properties and runtime configuration.
src/main/java/de/voidtech/netflixparty/service/ConfigService.java - File reader · Reads static file content for the backend.
src/main/java/de/voidtech/netflixparty/service/FileReader.java - HTTP controller · Main HTTP boundary for browser-facing pages and endpoints.
src/main/java/de/voidtech/netflixparty/api/http/HttpRestController.java - Error controller · Centralized HTTP error responses.
src/main/java/de/voidtech/netflixparty/api/http/HttpErrorController.java - Gateway config · Configures the real-time gateway transport.
src/main/java/de/voidtech/netflixparty/api/websocket/GatewayConfiguration.java - Gateway handler · Receives and emits real-time party events.
src/main/java/de/voidtech/netflixparty/api/websocket/GatewayHandler.java - Message handler · Dispatches inbound gateway messages to concrete handlers.
src/main/java/de/voidtech/netflixparty/service/MessageHandler.java - Handler annotation · Marks and registers message handlers.
src/main/java/de/voidtech/netflixparty/annotations/Handler.java - Party service · Owns room lifecycle and shared party state.
src/main/java/de/voidtech/netflixparty/service/PartyService.java - Chat service · Formats and manages chat messages.
src/main/java/de/voidtech/netflixparty/service/ChatMessageService.java - Response service · Standardizes outbound gateway responses.
src/main/java/de/voidtech/netflixparty/service/GatewayResponseService.java - Database service · Persistence abstraction behind party and message state.
src/main/java/de/voidtech/netflixparty/service/DatabaseService.java - Party · Shared room state model.
src/main/java/de/voidtech/netflixparty/entities/Party.java - Messages · Structured payloads exchanged across HTTP and WebSocket boundaries.
src/main/java/de/voidtech/netflixparty/entities/message/MessageBuilder.java
Public website
Server-hosted static site used for landing and room entry flows.
- Public site · Server-hosted landing and room entry site.
www/html/index.html - Site client · Client-side logic for the public website.
www/js/netflix.js
Connections 27
- NetflixParty → Config service: loads · Bootstrap reads runtime configuration.
- NetflixParty → HTTP controller: starts · Application exposes HTTP routes.
- NetflixParty → Gateway config: enables · Application registers websocket transport.
- HTTP controller → Error controller: uses · HTTP boundary delegates failures to error responses.
- HTTP controller → File reader: serves · HTTP layer reads static content for browser clients.
- HTTP controller → Public site: hosts · Public site is served through the HTTP layer.
- Gateway config → Gateway handler: routes · Gateway configuration binds the realtime handler.
- Gateway handler → Message handler: dispatches · Inbound websocket messages are routed to message handlers.
- Message handler → Handler annotation: discovers · Handler registration is annotation-driven.
- Message handler → Party service: invokes · Message handling updates party state.
- Message handler → Chat service: invokes · Chat-related messages use chat service logic.
- Message handler → Response service: formats · Responses are normalized before being sent back.
- Party service → Party: manages · Party service owns the room model.
- Party service → Database service: persists · Room state can be stored through the database abstraction.
- Chat service → Messages: builds · Chat service produces structured message payloads.
- Response service → Messages: creates · Outbound gateway payloads use the shared message model.
- Messages → Gateway handler: exchanged via · Message payloads cross the websocket boundary.
- Manifest → Netflix interface: injects · Manifest wires the Netflix content script.
- Manifest → Popup UI: opens · Manifest wires the popup surface.
- Manifest → Create room: opens · Manifest wires the create-room screen.
- Manifest → Share room: opens · Manifest wires the share-room screen.
- Netflix interface → Gateway handler: connects · Netflix page integration talks to the realtime gateway.
- Netflix interface → HTTP controller: calls · Extension uses backend HTTP resources and room flows.
- Popup UI → Create room: navigates · Popup drives the room creation flow.
- Create room → Share room: continues · Room creation leads into share-room flow.
- Netflix interface → Party service: syncs · Playback and chat actions are coordinated through party state.
- Site client → HTTP controller: fetches · Public site client uses backend HTTP endpoints.