How ameya-jarvis-07/p2p-file-sharing works
This is a single-node web app whose primary purpose is peer-to-peer (P2P) file transfer using WebRTC DataChannels, with a Node/Express + Socket.IO signaling server. The server’s job is *not* to proxy or store files; it only:
• serves the static frontend
• provides “room/presence” + signaling messages (offer/answer/ICE candidates) so browsers can establish a direct WebRTC connection
• Signaling traffic goes through the server
• File bytes do not (they flow directly peer-to-peer)
File structure analysis (map files to components)
From the file tree:
• server.js
Backend entrypoint. Likely:
• Express static hosting (public/)
• Socket.IO server for realtime peer discovery + WebRTC signaling
• public/index.html, public/styles.css
UI shell and styling.
• public/client.js
Core client logic:
• connects to Socket.IO signaling
• manages peer list/presence UI
• creates RTCPeerConnections, DataChannels
• chunks/sends files, receives/reassembles files
• progress reporting/backpressure
• package.json
Confirms runtime and dependencies (express, socket.io, etc.) and start command for deployment.
This is a “two-tier” app in terms of deployable units (server + browser client) but “three logical planes” in terms of networking:
README insights to reflect
• “True P2P Transfer”: bytes go peer↔peer over WebRTC DataChannels
• “Server acts as signaling server”
• “No server storage”
• “STUN for NAT traversal” (possibly TURN is not mentioned; show as optional/absent)
Socket.IO Signaling Server
4. (Optional) In-memory peer registry / sessions (even if implicit; it’s conceptually there)
Client-side (per device/browser)
WebRTC Stack
• RTCPeerConnection
• ICE agent
• DataChannel (the actual file transfer transport)
File API / Chunking pipeline
• chunk sizing strategy
• buffering / backpressure
• progress tracking
Received-file assembly & download (Blob creation + link)
External/Internet infrastructure
STUN server(s) (NAT traversal)
12. (Optional) TURN server as “not included / if needed in restrictive NATs” (mark as optional to avoid implying it exists)
Static asset delivery
• Browser → Server (HTTP GET /, /client.js, /styles.css)
Signaling & presence
• Browser ↔ Server (Socket.IO over WebSocket)
• “join / set name”
• “peer list updates”
• “offer / answer / ICE candidates”
• This is many-to-one (multiple clients connected to the signaling server).
P2P data plane (the critical one)
• Browser A ↔ Browser B (WebRTC DataChannel)
NAT traversal
• Each browser ↔ STUN server
Show:
• “P2P File Sharing Web App” as a system
• Users/devices as multiple browsers
• Render-hosted signaling server
• External STUN (and optional TURN)
Two distinct channels:
• signaling via server
• file transfer direct peer-to-peer
Containers:
• Node.js/Express/Socket.IO server (single container)
• Browser client (many instances)
External:
• STUN
Connections:
• HTTP, WebSocket, WebRTC
This is where WebRTC correctness shines. Include steps:
Important architectural patterns/principles to call out
• Control plane vs data plane split
• Control plane: Socket.IO signaling
• Data plane: WebRTC DataChannel (direct)
• No server persistence (explicitly annotate “no file storage” on server)
• Event-driven realtime (Socket.IO)
• Chunked streaming + backpressure (client-side pipeline)
• Many-to-many connectivity (peer discovery suggests N peers; each pair may form a connection)
• “Peer mesh”: each browser can establish DataChannels to multiple peers
• Use a hub-and-spoke only for signaling, not data
• Node Signaling Server → server.js
• Client App → public/client.js
• UI → public/index.html, public/styles.css
• Build/Run → package.json (npm start)
What *not* to accidentally imply
• Don’t include a database unless you confirm it exists in code.
• Don’t claim TURN is present unless configured; show it as optional.
• [ ] Distinct lanes for HTTP vs Socket.IO vs WebRTC
• [ ] STUN shown as external dependency for ICE/NAT traversal
• [ ] Multiple browsers shown (multi-device)
• [ ] Client-side chunking/buffering noted (since it’s a core feature)
• [ ] Deployment boundary (Render.com) shown around Node service