# rajin-khan/fliccs architecture

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

- Interactive diagram: https://gitdiagram.com/rajin-khan/fliccs
- Repository: https://github.com/rajin-khan/fliccs

## Overview

#### Purpose and Runtime
Fliccs is a private, real-time watch-party application with two modes: synchronized playback of independently selected local files, and host-to-guest WebRTC streaming. It has a Vite/React browser client and a Node.js real-time signaling/session server. Entry points are `client/src/main.jsx`, `client/src/App.jsx`, and `server/src/index.js`.

#### Client Application Shell
`client/src/App.jsx` owns top-level application state and routes users between landing, session, pricing, and legal surfaces. `client/src/components/Landing.jsx` is the pre-session entry flow; `client/src/components/StreamRoom.jsx` composes the active watch room; `client/src/components/Layout/PageLayout.jsx` provides shared layout framing.

#### Session Lifecycle and Authority
The server maintains ephemeral session state, including host/guest membership, password-gated access, and cleanup when a host leaves. `server/src/handlers/session.js` implements create/join/leave and participant lifecycle events, while `server/src/utils/id.js` generates session identifiers. Client controls live under `client/src/components/Session/Create.jsx`, `client/src/components/Session/Join.jsx`, and `client/src/components/Session/Leave.jsx`.

#### Socket Transport and Event Boundary
Socket-based signaling is the control-plane boundary between browser clients and the server. `server/src/index.js` registers handlers, and `server/src/handlers/chat.js`, `server/src/handlers/sync.js`, and `server/src/handlers/session.js` separate event domains. On the client, `client/src/services/socket.js` creates the transport and `client/src/hooks/useSocket.js` manages socket connectivity and event subscriptions.

#### Playback Synchronization Mode
In Sync Mode, each participant supplies the same local video file; no media bytes are uploaded. `client/src/utils/fileHash.js` fingerprints files to validate compatibility. The player in `client/src/components/VideoPlayer/index.jsx` uses `client/src/components/VideoPlayer/useVideoSync.js` to emit and apply host playback actions through the server synchronization handler at `server/src/handlers/sync.js`.

#### WebRTC Stream Mode
In Stream Mode, the host captures and distributes local media directly to guests over WebRTC; the server is signaling-only rather than a media relay. `client/src/hooks/useWebRTC.js` owns peer-connection/media negotiation, and `server/src/handlers/sync.js` likely carries the associated signaling events. External TURN infrastructure is required for NAT/firewall traversal; the README identifies Twilio-provided temporary TURN servers.

#### In-Room Collaboration UI
The room combines video, participants, invite flow, and chat. `client/src/components/VideoPlayer/PlayerControls.jsx` provides local playback interaction, while `client/src/components/Session/Participants.jsx` and `client/src/components/Session/InviteButton.jsx` expose room state and sharing. `client/src/hooks/useChat.js`, `client/src/components/Chat/index.jsx`, and `server/src/handlers/chat.js` implement real-time text chat as a separate socket event stream.

#### Deployment and Persistence Model
The repository includes a built static client at `client/dist/index.html` and a deployable Node server at `server/src/index.js`; the documented live deployment is Railway. Sessions, membership, chat, and sync state are designed to be transient in server memory: no database, accounts, uploads, or persistent user data appear in the repository tree.

Main entry points: [`client/src/hooks/useWebRTC.js`](https://github.com/rajin-khan/fliccs/blob/main/client/src/hooks/useWebRTC.js) (WebRTC media peers), [`server/src/index.js`](https://github.com/rajin-khan/fliccs/blob/main/server/src/index.js) (Server entry), [`client/src/components/StreamRoom.jsx`](https://github.com/rajin-khan/fliccs/blob/main/client/src/components/StreamRoom.jsx) (Watch room), [`client/src/App.jsx`](https://github.com/rajin-khan/fliccs/blob/main/client/src/App.jsx) (Application shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser Client"]
  node_client_entry["Client entry<br/>React bootstrap<br/>[main.jsx]"]
  node_app_shell["Application shell<br/>routing and state<br/>[App.jsx]"]
  node_landing["Landing flow<br/>pre-session UI<br/>[Landing.jsx]"]
  node_room["Watch room<br/>room composition<br/>[StreamRoom.jsx]"]
  node_session_controls["Session controls<br/>create/join/leave UI<br/>[Create.jsx]"]
  node_socket_client["Socket transport<br/>socket service and hook<br/>[socket.js]"]
  node_sync_player["Synchronized player<br/>video playback sync<br/>[useVideoSync.js]"]
  node_file_hash["Local file validation<br/>file fingerprinting<br/>[fileHash.js]"]
  node_webrtc{{"WebRTC media peers<br/>peer negotiation<br/>[useWebRTC.js]"}}
  node_chat_client["Chat client<br/>chat hook and UI<br/>[useChat.js]"]
end

subgraph group_server["Real-Time Server"]
  node_server_entry["Server entry<br/>Node/Socket bootstrap<br/>[index.js]"]
  node_session_handler["Session authority<br/>session handler<br/>[session.js]"]
  node_session_ids["Session IDs<br/>identifier generator<br/>[id.js]"]
  node_sync_handler["Sync and signaling<br/>socket handler<br/>[sync.js]"]
  node_chat_handler["Chat events<br/>socket handler<br/>[chat.js]"]
end

subgraph group_external["External Infrastructure"]
  node_turn{{"Twilio TURN servers<br/>NAT traversal"}}
  node_deployment["Railway deployment<br/>hosting platform"]
end

node_client_entry -->|"boots"| node_app_shell
node_app_shell -->|"routes to"| node_landing
node_app_shell -->|"routes to"| node_room
node_landing -->|"starts sessions"| node_session_controls
node_session_controls -->|"uses"| node_socket_client
node_room -->|"hosts"| node_sync_player
node_room -->|"hosts"| node_chat_client
node_room -->|"selects stream mode"| node_webrtc
node_file_hash -->|"validates local media"| node_sync_player
node_socket_client -->|"Socket control plane"| node_server_entry
node_server_entry -->|"registers"| node_session_handler
node_server_entry -->|"registers"| node_sync_handler
node_server_entry -->|"registers"| node_chat_handler
node_session_handler -->|"generates"| node_session_ids
node_sync_player -->|"playback actions"| node_sync_handler
node_webrtc -->|"offer/answer/ICE signaling"| node_sync_handler
node_chat_client -->|"chat events"| node_chat_handler
node_webrtc -.->|"obtains relay connectivity"| node_turn
node_webrtc -->|"host-to-guest media"| node_webrtc
node_deployment -->|"hosts"| node_server_entry

click node_client_entry "https://github.com/rajin-khan/fliccs/blob/main/client/src/main.jsx"
click node_app_shell "https://github.com/rajin-khan/fliccs/blob/main/client/src/App.jsx"
click node_landing "https://github.com/rajin-khan/fliccs/blob/main/client/src/components/Landing.jsx"
click node_room "https://github.com/rajin-khan/fliccs/blob/main/client/src/components/StreamRoom.jsx"
click node_session_controls "https://github.com/rajin-khan/fliccs/blob/main/client/src/components/Session/Create.jsx"
click node_socket_client "https://github.com/rajin-khan/fliccs/blob/main/client/src/services/socket.js"
click node_sync_player "https://github.com/rajin-khan/fliccs/blob/main/client/src/components/VideoPlayer/useVideoSync.js"
click node_file_hash "https://github.com/rajin-khan/fliccs/blob/main/client/src/utils/fileHash.js"
click node_webrtc "https://github.com/rajin-khan/fliccs/blob/main/client/src/hooks/useWebRTC.js"
click node_chat_client "https://github.com/rajin-khan/fliccs/blob/main/client/src/hooks/useChat.js"
click node_server_entry "https://github.com/rajin-khan/fliccs/blob/main/server/src/index.js"
click node_session_handler "https://github.com/rajin-khan/fliccs/blob/main/server/src/handlers/session.js"
click node_session_ids "https://github.com/rajin-khan/fliccs/blob/main/server/src/utils/id.js"
click node_sync_handler "https://github.com/rajin-khan/fliccs/blob/main/server/src/handlers/sync.js"
click node_chat_handler "https://github.com/rajin-khan/fliccs/blob/main/server/src/handlers/chat.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_client_entry,node_app_shell,node_landing,node_room,node_session_controls,node_socket_client,node_sync_player,node_file_hash,node_webrtc,node_chat_client toneBlue
class node_server_entry,node_session_handler,node_session_ids,node_sync_handler,node_chat_handler toneAmber
class node_turn,node_deployment toneMint
```

## Components

### Browser Client

Vite/React application and room experience.

- [Client entry](https://github.com/rajin-khan/fliccs/blob/main/client/src/main.jsx): React bootstrap · `client/src/main.jsx`
- [Application shell](https://github.com/rajin-khan/fliccs/blob/main/client/src/App.jsx): routing and state · Routes landing, session, pricing, and legal surfaces. · `client/src/App.jsx`
- [Landing flow](https://github.com/rajin-khan/fliccs/blob/main/client/src/components/Landing.jsx): pre-session UI · `client/src/components/Landing.jsx`
- [Watch room](https://github.com/rajin-khan/fliccs/blob/main/client/src/components/StreamRoom.jsx): room composition · Combines playback, participants, invites, and chat. · `client/src/components/StreamRoom.jsx`
- [Session controls](https://github.com/rajin-khan/fliccs/blob/main/client/src/components/Session/Create.jsx): create/join/leave UI · `client/src/components/Session/Create.jsx`
- [Socket transport](https://github.com/rajin-khan/fliccs/blob/main/client/src/services/socket.js): socket service and hook · Creates the connection and manages event subscriptions. · `client/src/services/socket.js`
- [Synchronized player](https://github.com/rajin-khan/fliccs/blob/main/client/src/components/VideoPlayer/useVideoSync.js): video playback sync · Applies host playback actions to each participant's local file. · `client/src/components/VideoPlayer/useVideoSync.js`
- [Local file validation](https://github.com/rajin-khan/fliccs/blob/main/client/src/utils/fileHash.js): file fingerprinting · Validates that independently selected files match. · `client/src/utils/fileHash.js`
- [WebRTC media peers](https://github.com/rajin-khan/fliccs/blob/main/client/src/hooks/useWebRTC.js): peer negotiation · Host media flows directly to guests; the server does not relay media. · `client/src/hooks/useWebRTC.js`
- [Chat client](https://github.com/rajin-khan/fliccs/blob/main/client/src/hooks/useChat.js): chat hook and UI · `client/src/hooks/useChat.js`

### Real-Time Server

Node.js session authority and Socket event handlers.

- [Server entry](https://github.com/rajin-khan/fliccs/blob/main/server/src/index.js): Node/Socket bootstrap · Registers real-time event handlers. · `server/src/index.js`
- [Session authority](https://github.com/rajin-khan/fliccs/blob/main/server/src/handlers/session.js): session handler · Maintains ephemeral membership, passwords, host ownership, and cleanup. · `server/src/handlers/session.js`
- [Session IDs](https://github.com/rajin-khan/fliccs/blob/main/server/src/utils/id.js): identifier generator · `server/src/utils/id.js`
- [Sync and signaling](https://github.com/rajin-khan/fliccs/blob/main/server/src/handlers/sync.js): socket handler · Relays playback synchronization and WebRTC signaling events. · `server/src/handlers/sync.js`
- [Chat events](https://github.com/rajin-khan/fliccs/blob/main/server/src/handlers/chat.js): socket handler · `server/src/handlers/chat.js`

### External Infrastructure

- **Twilio TURN servers**: NAT traversal · Provides temporary relay candidates when direct WebRTC connectivity fails.
- **Railway deployment**: hosting platform · Hosts the deployable Node real-time server.

## Connections

- Client entry → Application shell: boots
- Application shell → Landing flow: routes to
- Application shell → Watch room: routes to
- Landing flow → Session controls: starts sessions
- Session controls → Socket transport: uses
- Watch room → Synchronized player: hosts
- Watch room → Chat client: hosts
- Watch room → WebRTC media peers: selects stream mode
- Local file validation → Synchronized player: validates local media
- Socket transport → Server entry: Socket control plane
- Server entry → Session authority: registers
- Server entry → Sync and signaling: registers
- Server entry → Chat events: registers
- Session authority → Session IDs: generates
- Synchronized player → Sync and signaling: playback actions
- WebRTC media peers → Sync and signaling: offer/answer/ICE signaling
- Chat client → Chat events: chat events
- WebRTC media peers → Twilio TURN servers: obtains relay connectivity
- WebRTC media peers → WebRTC media peers: host-to-guest media · Direct peer media stream between browser participants.
- Railway deployment → Server entry: hosts
