# elementalmp4/netflixparty architecture

> Architecture diagram of the GitHub repository elementalmp4/netflixparty, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/elementalmp4/netflixparty
- Repository: https://github.com/elementalmp4/netflixparty

## Overview

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: [`src/main/java/de/voidtech/netflixparty/api/http/HttpRestController.java`](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/api/http/HttpRestController.java) (HTTP controller), [`src/main/java/de/voidtech/netflixparty/service/MessageHandler.java`](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/MessageHandler.java) (Message handler), [`extension/manifest.json`](https://github.com/elementalmp4/netflixparty/blob/main/extension/manifest.json) (Manifest), [`extension/js/netflix-party-interface.js`](https://github.com/elementalmp4/netflixparty/blob/main/extension/js/netflix-party-interface.js) (Netflix interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_extension["Chrome extension"]
  node_node_ext_manifest["Manifest<br/>[manifest.json]"]
  node_node_ext_interface["Netflix interface<br/>content script"]
  node_node_ext_popup["Popup UI<br/>extension ui<br/>[popup.js]"]
  node_node_ext_create["Create room<br/>extension flow<br/>[createroom.js]"]
  node_node_ext_share["Share room<br/>extension flow<br/>[shareroom.js]"]
end

subgraph group_group_backend["Java backend"]
  node_node_entrypoint["NetflixParty<br/>Spring boot app<br/>[NetflixParty.java]"]
  node_node_config["Config service<br/>runtime config<br/>[ConfigService.java]"]
  node_node_filereader["File reader<br/>content loader<br/>[FileReader.java]"]
  node_node_http["HTTP controller<br/>http api"]
  node_node_http_error["Error controller<br/>http errors"]
  node_node_ws_config["Gateway config<br/>websocket setup"]
  node_node_ws_handler["Gateway handler<br/>websocket endpoint"]
  node_node_dispatcher["Message handler<br/>message router"]
  node_node_annotation(("Handler annotation<br/>handler marker<br/>[Handler.java]"))
  node_node_party_service["Party service<br/>room state<br/>[PartyService.java]"]
  node_node_chat_service["Chat service"]
  node_node_gateway_response["Response service<br/>gateway response"]
  node_node_database["Database service<br/>persistence"]
  node_node_party[("Party<br/>room entity<br/>[Party.java]")]
  node_node_message_model["Messages<br/>message model"]
end

subgraph group_group_web["Public website"]
  node_node_www_site["Public site<br/>static web<br/>[index.html]"]
  node_node_www_client["Site client<br/>site script<br/>[netflix.js]"]
end

node_node_entrypoint -->|"loads"| node_node_config
node_node_entrypoint -->|"starts"| node_node_http
node_node_entrypoint -->|"enables"| node_node_ws_config
node_node_http -->|"uses"| node_node_http_error
node_node_http -->|"serves"| node_node_filereader
node_node_http -->|"hosts"| node_node_www_site
node_node_ws_config -->|"routes"| node_node_ws_handler
node_node_ws_handler -->|"dispatches"| node_node_dispatcher
node_node_dispatcher -.->|"discovers"| node_node_annotation
node_node_dispatcher -->|"invokes"| node_node_party_service
node_node_dispatcher -->|"invokes"| node_node_chat_service
node_node_dispatcher -->|"formats"| node_node_gateway_response
node_node_party_service -->|"manages"| node_node_party
node_node_party_service -->|"persists"| node_node_database
node_node_chat_service -->|"builds"| node_node_message_model
node_node_gateway_response -->|"creates"| node_node_message_model
node_node_message_model -.->|"exchanged via"| node_node_ws_handler
node_node_ext_manifest -->|"injects"| node_node_ext_interface
node_node_ext_manifest -->|"opens"| node_node_ext_popup
node_node_ext_manifest -->|"opens"| node_node_ext_create
node_node_ext_manifest -->|"opens"| node_node_ext_share
node_node_ext_interface -->|"connects"| node_node_ws_handler
node_node_ext_interface -->|"calls"| node_node_http
node_node_ext_popup -.->|"navigates"| node_node_ext_create
node_node_ext_create -.->|"continues"| node_node_ext_share
node_node_ext_interface -.->|"syncs"| node_node_party_service
node_node_www_client -->|"fetches"| node_node_http

click node_node_entrypoint "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/NetflixParty.java"
click node_node_config "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/ConfigService.java"
click node_node_filereader "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/FileReader.java"
click node_node_http "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/api/http/HttpRestController.java"
click node_node_http_error "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/api/http/HttpErrorController.java"
click node_node_ws_config "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/api/websocket/GatewayConfiguration.java"
click node_node_ws_handler "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/api/websocket/GatewayHandler.java"
click node_node_dispatcher "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/MessageHandler.java"
click node_node_annotation "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/annotations/Handler.java"
click node_node_party_service "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/PartyService.java"
click node_node_chat_service "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/ChatMessageService.java"
click node_node_gateway_response "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/GatewayResponseService.java"
click node_node_database "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/DatabaseService.java"
click node_node_party "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/entities/Party.java"
click node_node_message_model "https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/entities/message/MessageBuilder.java"
click node_node_ext_manifest "https://github.com/elementalmp4/netflixparty/blob/main/extension/manifest.json"
click node_node_ext_interface "https://github.com/elementalmp4/netflixparty/blob/main/extension/js/netflix-party-interface.js"
click node_node_ext_popup "https://github.com/elementalmp4/netflixparty/blob/main/extension/js/popup.js"
click node_node_ext_create "https://github.com/elementalmp4/netflixparty/blob/main/extension/js/createroom.js"
click node_node_ext_share "https://github.com/elementalmp4/netflixparty/blob/main/extension/js/shareroom.js"
click node_node_www_site "https://github.com/elementalmp4/netflixparty/blob/main/www/html/index.html"
click node_node_www_client "https://github.com/elementalmp4/netflixparty/blob/main/www/js/netflix.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_ext_manifest,node_node_ext_interface,node_node_ext_popup,node_node_ext_create,node_node_ext_share toneBlue
class node_node_entrypoint,node_node_config,node_node_filereader,node_node_http,node_node_http_error,node_node_ws_config,node_node_ws_handler,node_node_dispatcher,node_node_annotation,node_node_party_service,node_node_chat_service,node_node_gateway_response,node_node_database,node_node_party,node_node_message_model toneAmber
class node_node_www_site,node_node_www_client toneMint
```

## Components

### Chrome extension

Browser-side product surface injected into Netflix and used for room creation and control.

- [Manifest](https://github.com/elementalmp4/netflixparty/blob/main/extension/manifest.json): extension manifest · Wires popup, room screens, CSS, and Netflix injection. · `extension/manifest.json`
- [Netflix interface](https://github.com/elementalmp4/netflixparty/blob/main/extension/js/netflix-party-interface.js): content script · Runs in the Netflix page and bridges playback/chat actions. · `extension/js/netflix-party-interface.js`
- [Popup UI](https://github.com/elementalmp4/netflixparty/blob/main/extension/js/popup.js): extension ui · Entry UI for the browser extension. · `extension/js/popup.js`
- [Create room](https://github.com/elementalmp4/netflixparty/blob/main/extension/js/createroom.js): extension flow · Creates a new party from the extension UI. · `extension/js/createroom.js`
- [Share room](https://github.com/elementalmp4/netflixparty/blob/main/extension/js/shareroom.js): extension flow · Shares room details with other participants. · `extension/js/shareroom.js`

### Java backend

Server application handling HTTP pages, configuration, and real-time room synchronization.

- [NetflixParty](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/NetflixParty.java): Spring boot app · Server application entrypoint and bootstrap. · `src/main/java/de/voidtech/netflixparty/NetflixParty.java`
- [Config service](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/ConfigService.java): runtime config · Loads server properties and runtime configuration. · `src/main/java/de/voidtech/netflixparty/service/ConfigService.java`
- [File reader](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/FileReader.java): content loader · Reads static file content for the backend. · `src/main/java/de/voidtech/netflixparty/service/FileReader.java`
- [HTTP controller](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/api/http/HttpRestController.java): http api · Main HTTP boundary for browser-facing pages and endpoints. · `src/main/java/de/voidtech/netflixparty/api/http/HttpRestController.java`
- [Error controller](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/api/http/HttpErrorController.java): http errors · Centralized HTTP error responses. · `src/main/java/de/voidtech/netflixparty/api/http/HttpErrorController.java`
- [Gateway config](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/api/websocket/GatewayConfiguration.java): websocket setup · Configures the real-time gateway transport. · `src/main/java/de/voidtech/netflixparty/api/websocket/GatewayConfiguration.java`
- [Gateway handler](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/api/websocket/GatewayHandler.java): websocket endpoint · Receives and emits real-time party events. · `src/main/java/de/voidtech/netflixparty/api/websocket/GatewayHandler.java`
- [Message handler](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/MessageHandler.java): message router · Dispatches inbound gateway messages to concrete handlers. · `src/main/java/de/voidtech/netflixparty/service/MessageHandler.java`
- [Handler annotation](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/annotations/Handler.java): handler marker · Marks and registers message handlers. · `src/main/java/de/voidtech/netflixparty/annotations/Handler.java`
- [Party service](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/PartyService.java): room state · Owns room lifecycle and shared party state. · `src/main/java/de/voidtech/netflixparty/service/PartyService.java`
- [Chat service](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/ChatMessageService.java): chat service · Formats and manages chat messages. · `src/main/java/de/voidtech/netflixparty/service/ChatMessageService.java`
- [Response service](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/GatewayResponseService.java): gateway response · Standardizes outbound gateway responses. · `src/main/java/de/voidtech/netflixparty/service/GatewayResponseService.java`
- [Database service](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/service/DatabaseService.java): persistence · Persistence abstraction behind party and message state. · `src/main/java/de/voidtech/netflixparty/service/DatabaseService.java`
- [Party](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/entities/Party.java): room entity · Shared room state model. · `src/main/java/de/voidtech/netflixparty/entities/Party.java`
- [Messages](https://github.com/elementalmp4/netflixparty/blob/main/src/main/java/de/voidtech/netflixparty/entities/message/MessageBuilder.java): message model · 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](https://github.com/elementalmp4/netflixparty/blob/main/www/html/index.html): static web · Server-hosted landing and room entry site. · `www/html/index.html`
- [Site client](https://github.com/elementalmp4/netflixparty/blob/main/www/js/netflix.js): site script · Client-side logic for the public website. · `www/js/netflix.js`

## Connections

- 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.
