# divyanshgarg25/nodelink architecture

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

- Interactive diagram: https://gitdiagram.com/divyanshgarg25/nodelink
- Repository: https://github.com/divyanshgarg25/nodelink

## Overview

NodeLink is a browser-based peer-to-peer file-transfer and chat application. A user creates or joins a PIN room, the signaling server matches peers and relays WebRTC negotiation, and the connected peers transfer files and chat over WebRTC data channels. File selection preserves folder paths; incoming batches can be written to disk with streaming and backpressure. The source excerpts show the UI and server behavior, but omit much of the WebRTC hook, so some internal transfer relationships are documented by the README rather than verified in source.

Main entry points: [`src/App.jsx`](https://github.com/divyanshgarg25/nodelink/blob/main/src/App.jsx) (App coordinator), [`src/hooks/useWebRTC.js`](https://github.com/divyanshgarg25/nodelink/blob/main/src/hooks/useWebRTC.js) (WebRTC hook), [`server/server.js`](https://github.com/divyanshgarg25/nodelink/blob/main/server/server.js) (WebSocket signaling), [`src/main.jsx`](https://github.com/divyanshgarg25/nodelink/blob/main/src/main.jsx) (React entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser application"]
  node_entry["React entry<br/>[main.jsx]"]
  node_app["App coordinator<br/>[App.jsx]"]
  node_rooms["Room controls<br/>[RoomManager.jsx]"]
end

subgraph group_signal["Room signaling"]
  node_webrtc["WebRTC hook<br/>[useWebRTC.js]"]
  node_signaling["WebSocket signaling<br/>[server.js]"]
  node_roomstate[("In-memory rooms<br/>[server.js]")]
end

subgraph group_transfer["Peer transfer"]
  node_filepicker["File and folder selection<br/>[DragDropZone.jsx]"]
  node_batch["Batch transfer<br/>[useWebRTC.js]"]
  node_disk["Disk streaming<br/>[useWebRTC.js]"]
  node_chatstate["Chat transport<br/>[useWebRTC.js]"]
end

subgraph group_presentation["Transfer interface"]
  node_chatui["Chat interface<br/>[ChatBox.jsx]"]
  node_progress["Transfer progress<br/>[ProgressBar.jsx]"]
end

node_user(("User"))
node_peer(("Remote peer"))

node_user -->|"opens app"| node_entry
node_entry -->|"renders"| node_app
node_app -->|"uses hook"| node_webrtc
node_app -->|"renders"| node_rooms
node_rooms -->|"requests join"| node_app
node_app -->|"renders"| node_filepicker
node_filepicker -->|"passes files"| node_app
node_app -->|"renders"| node_chatui
node_chatui -->|"submits text"| node_app
node_app -->|"renders progress"| node_progress
node_webrtc -->|"signals peers"| node_signaling
node_signaling -->|"manages rooms"| node_roomstate
node_signaling -->|"relays negotiation"| node_peer
node_webrtc -->|"negotiates WebRTC"| node_peer
node_batch -->|"transfers chunks"| node_peer
node_chatstate -->|"sends chat"| node_peer
node_disk -->|"receives files"| node_peer
node_webrtc -.->|"manages transfer"| node_batch
node_webrtc -.->|"manages chat"| node_chatstate
node_batch -->|"streams downloads"| node_disk
node_webrtc -.->|"requests matchmaking"| node_roomstate

click node_entry "https://github.com/divyanshgarg25/nodelink/blob/main/src/main.jsx"
click node_app "https://github.com/divyanshgarg25/nodelink/blob/main/src/App.jsx"
click node_rooms "https://github.com/divyanshgarg25/nodelink/blob/main/src/components/RoomManager.jsx"
click node_webrtc "https://github.com/divyanshgarg25/nodelink/blob/main/src/hooks/useWebRTC.js"
click node_signaling "https://github.com/divyanshgarg25/nodelink/blob/main/server/server.js"
click node_roomstate "https://github.com/divyanshgarg25/nodelink/blob/main/server/server.js"
click node_filepicker "https://github.com/divyanshgarg25/nodelink/blob/main/src/components/DragDropZone.jsx"
click node_batch "https://github.com/divyanshgarg25/nodelink/blob/main/src/hooks/useWebRTC.js"
click node_disk "https://github.com/divyanshgarg25/nodelink/blob/main/src/hooks/useWebRTC.js"
click node_chatstate "https://github.com/divyanshgarg25/nodelink/blob/main/src/hooks/useWebRTC.js"
click node_chatui "https://github.com/divyanshgarg25/nodelink/blob/main/src/components/ChatBox.jsx"
click node_progress "https://github.com/divyanshgarg25/nodelink/blob/main/src/components/ProgressBar.jsx"

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_entry,node_app,node_rooms,node_user toneBlue
class node_webrtc,node_signaling,node_roomstate toneAmber
class node_filepicker,node_batch,node_disk,node_chatstate toneMint
class node_chatui,node_progress toneRose
class node_peer toneIndigo
```

## Components

### Browser application

- [React entry](https://github.com/divyanshgarg25/nodelink/blob/main/src/main.jsx): `src/main.jsx`
- [App coordinator](https://github.com/divyanshgarg25/nodelink/blob/main/src/App.jsx): `src/App.jsx`
- [Room controls](https://github.com/divyanshgarg25/nodelink/blob/main/src/components/RoomManager.jsx): `src/components/RoomManager.jsx`

### Room signaling

- [WebRTC hook](https://github.com/divyanshgarg25/nodelink/blob/main/src/hooks/useWebRTC.js): `src/hooks/useWebRTC.js`
- [WebSocket signaling](https://github.com/divyanshgarg25/nodelink/blob/main/server/server.js): `server/server.js`
- [In-memory rooms](https://github.com/divyanshgarg25/nodelink/blob/main/server/server.js): `server/server.js`

### Peer transfer

- [File and folder selection](https://github.com/divyanshgarg25/nodelink/blob/main/src/components/DragDropZone.jsx): `src/components/DragDropZone.jsx`
- [Batch transfer](https://github.com/divyanshgarg25/nodelink/blob/main/src/hooks/useWebRTC.js): `src/hooks/useWebRTC.js`
- [Disk streaming](https://github.com/divyanshgarg25/nodelink/blob/main/src/hooks/useWebRTC.js): `src/hooks/useWebRTC.js`
- [Chat transport](https://github.com/divyanshgarg25/nodelink/blob/main/src/hooks/useWebRTC.js): `src/hooks/useWebRTC.js`

### Transfer interface

- [Chat interface](https://github.com/divyanshgarg25/nodelink/blob/main/src/components/ChatBox.jsx): `src/components/ChatBox.jsx`
- [Transfer progress](https://github.com/divyanshgarg25/nodelink/blob/main/src/components/ProgressBar.jsx): `src/components/ProgressBar.jsx`

### Other components

- **User**
- **Remote peer**

## Connections

- User → React entry: opens app (evidence: `src/main.jsx`)
- React entry → App coordinator: renders (evidence: `src/main.jsx`)
- App coordinator → WebRTC hook: uses hook (evidence: `src/App.jsx`)
- App coordinator → Room controls: renders (evidence: `src/App.jsx`)
- Room controls → App coordinator: requests join (evidence: `src/components/RoomManager.jsx`)
- App coordinator → File and folder selection: renders (evidence: `src/App.jsx`)
- File and folder selection → App coordinator: passes files (evidence: `src/App.jsx`)
- App coordinator → Chat interface: renders (evidence: `src/App.jsx`)
- Chat interface → App coordinator: submits text (evidence: `src/App.jsx`)
- App coordinator → Transfer progress: renders progress (evidence: `src/App.jsx`)
- WebRTC hook → WebSocket signaling: signals peers (evidence: `README.md`)
- WebSocket signaling → In-memory rooms: manages rooms (evidence: `server/server.js`)
- WebSocket signaling → Remote peer: relays negotiation (evidence: `server/server.js`)
- WebRTC hook → Remote peer: negotiates WebRTC (evidence: `README.md`)
- Batch transfer → Remote peer: transfers chunks (evidence: `README.md`)
- Chat transport → Remote peer: sends chat (evidence: `README.md`)
- Disk streaming → Remote peer: receives files (evidence: `README.md`)
- WebRTC hook → Batch transfer: manages transfer (evidence: `src/hooks/useWebRTC.js`)
- WebRTC hook → Chat transport: manages chat (evidence: `src/hooks/useWebRTC.js`)
- Batch transfer → Disk streaming: streams downloads (evidence: `README.md`)
- WebRTC hook → In-memory rooms: requests matchmaking
