# visshalb2007/cine_sync architecture

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

- Interactive diagram: https://gitdiagram.com/visshalb2007/cine_sync
- Repository: https://github.com/visshalb2007/cine_sync

## Overview

CineSync is a browser-based watch-party and movie-discovery application. Viewers join rooms and coordinate playback and group features through the server; the server persists room state and exposes movie-search and genre endpoints backed by TMDB with OMDb fallback. The README documents playback synchronization, host transfer, chat, reactions, polls, playlists, reconnection, and per-user subtitle and quality controls. The sampled source shows the server, discovery, and persistence paths; client implementation details are not present in the supplied tree, so client links rely on README descriptions.

Main entry points: [`server/index.ts`](https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts) (HTTP and socket gateway), [`client`](https://github.com/visshalb2007/cine_sync/tree/main/client) (Watch-party client), [`server/api/tmdb.ts`](https://github.com/visshalb2007/cine_sync/blob/main/server/api/tmdb.ts) (Catalog search and genres), [`server/api/omdb.ts`](https://github.com/visshalb2007/cine_sync/blob/main/server/api/omdb.ts) (OMDb fallback and details)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Viewer experience"]
  node_client["Watch-party client"]
end

subgraph group_rooms["Room coordination"]
  node_gateway["HTTP and socket gateway<br/>[index.ts]"]
  node_room_state["Room state and controls<br/>[index.ts]"]
  node_playback_sync["Playback synchronization<br/>[index.ts]"]
  node_host_features["Host and participant controls<br/>[index.ts]"]
  node_party_features["Chat, polls, playlist<br/>[index.ts]"]
end

subgraph group_discovery["Movie discovery"]
  node_discovery_routes["Discovery endpoints<br/>[index.ts]"]
  node_movie_search["Catalog search and genres<br/>[tmdb.ts]"]
  node_tmdb["TMDB provider<br/>[tmdb.ts]"]
  node_omdb["OMDb fallback and details<br/>[omdb.ts]"]
  node_cache["Provider response cache<br/>[cache.ts]"]
  node_rate_limit["API rate limiting<br/>[rateLimiter.ts]"]
end

subgraph group_storage["Persistence"]
  node_sqlite[("SQLite room store<br/>[db.ts]")]
end

node_viewers(("Browser viewers"))
node_external_catalogs(("TMDB and OMDb APIs"))

node_viewers -->|"use"| node_client
node_client -->|"sends events"| node_gateway
node_gateway -->|"routes events"| node_room_state
node_room_state -.->|"projects playback"| node_playback_sync
node_room_state -.->|"enforces control"| node_host_features
node_room_state -.->|"broadcasts activity"| node_party_features
node_gateway -->|"saves rooms"| node_sqlite
node_sqlite -.->|"recovers state"| node_room_state
node_client -.->|"fetches catalog"| node_discovery_routes
node_gateway -->|"serves endpoints"| node_discovery_routes
node_discovery_routes -->|"requests results"| node_movie_search
node_movie_search -->|"searches first"| node_tmdb
node_movie_search -->|"falls back"| node_omdb
node_tmdb -->|"reads and writes"| node_cache
node_omdb -->|"reads and writes"| node_cache
node_tmdb -->|"queries TMDB"| node_external_catalogs
node_omdb -->|"queries OMDb"| node_external_catalogs
node_gateway -->|"limits requests"| node_rate_limit

click node_client "https://github.com/visshalb2007/cine_sync/tree/main/client"
click node_gateway "https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts"
click node_room_state "https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts"
click node_playback_sync "https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts"
click node_host_features "https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts"
click node_party_features "https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts"
click node_discovery_routes "https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts"
click node_movie_search "https://github.com/visshalb2007/cine_sync/blob/main/server/api/tmdb.ts"
click node_tmdb "https://github.com/visshalb2007/cine_sync/blob/main/server/api/tmdb.ts"
click node_omdb "https://github.com/visshalb2007/cine_sync/blob/main/server/api/omdb.ts"
click node_cache "https://github.com/visshalb2007/cine_sync/blob/main/server/api/cache.ts"
click node_rate_limit "https://github.com/visshalb2007/cine_sync/blob/main/server/api/rateLimiter.ts"
click node_sqlite "https://github.com/visshalb2007/cine_sync/blob/main/server/db.ts"

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_client,node_viewers toneBlue
class node_gateway,node_room_state,node_playback_sync,node_host_features,node_party_features toneAmber
class node_discovery_routes,node_movie_search,node_tmdb,node_omdb,node_cache,node_rate_limit,node_external_catalogs toneMint
class node_sqlite toneRose
```

## Components

### Viewer experience

- [Watch-party client](https://github.com/visshalb2007/cine_sync/tree/main/client): `client`

### Room coordination

- [HTTP and socket gateway](https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts): `server/index.ts`
- [Room state and controls](https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts): `server/index.ts`
- [Playback synchronization](https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts): `server/index.ts`
- [Host and participant controls](https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts): `server/index.ts`
- [Chat, polls, playlist](https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts): `server/index.ts`

### Movie discovery

- [Discovery endpoints](https://github.com/visshalb2007/cine_sync/blob/main/server/index.ts): `server/index.ts`
- [Catalog search and genres](https://github.com/visshalb2007/cine_sync/blob/main/server/api/tmdb.ts): `server/api/tmdb.ts`
- [TMDB provider](https://github.com/visshalb2007/cine_sync/blob/main/server/api/tmdb.ts): `server/api/tmdb.ts`
- [OMDb fallback and details](https://github.com/visshalb2007/cine_sync/blob/main/server/api/omdb.ts): `server/api/omdb.ts`
- [Provider response cache](https://github.com/visshalb2007/cine_sync/blob/main/server/api/cache.ts): `server/api/cache.ts`
- [API rate limiting](https://github.com/visshalb2007/cine_sync/blob/main/server/api/rateLimiter.ts): `server/api/rateLimiter.ts`

### Persistence

- [SQLite room store](https://github.com/visshalb2007/cine_sync/blob/main/server/db.ts): `server/db.ts`

### Other components

- **Browser viewers**
- **TMDB and OMDb APIs**

## Connections

- Browser viewers → Watch-party client: use (evidence: `README.md`)
- Watch-party client → HTTP and socket gateway: sends events (evidence: `README.md`)
- HTTP and socket gateway → Room state and controls: routes events (evidence: `server/index.ts`)
- Room state and controls → Playback synchronization: projects playback (evidence: `README.md`)
- Room state and controls → Host and participant controls: enforces control (evidence: `README.md`)
- Room state and controls → Chat, polls, playlist: broadcasts activity (evidence: `README.md`)
- HTTP and socket gateway → SQLite room store: saves rooms (evidence: `server/index.ts`)
- SQLite room store → Room state and controls: recovers state (evidence: `README.md`)
- Watch-party client → Discovery endpoints: fetches catalog (evidence: `README.md`)
- HTTP and socket gateway → Discovery endpoints: serves endpoints (evidence: `server/index.ts`)
- Discovery endpoints → Catalog search and genres: requests results (evidence: `server/index.ts`)
- Catalog search and genres → TMDB provider: searches first (evidence: `server/api/tmdb.ts`)
- Catalog search and genres → OMDb fallback and details: falls back (evidence: `server/api/tmdb.ts`)
- TMDB provider → Provider response cache: reads and writes (evidence: `server/api/tmdb.ts`)
- OMDb fallback and details → Provider response cache: reads and writes (evidence: `server/api/omdb.ts`)
- TMDB provider → TMDB and OMDb APIs: queries TMDB (evidence: `server/api/tmdb.ts`)
- OMDb fallback and details → TMDB and OMDb APIs: queries OMDb (evidence: `server/api/omdb.ts`)
- HTTP and socket gateway → API rate limiting: limits requests (evidence: `server/index.ts`)
