How ishandhull2953/p2p-file-sharing works
P2P Mesh lets browser peers select a file and destination, find a route through the live topology, then send chunks directly over WebRTC data channels; intermediate peers relay chunks and the receiver reassembles and verifies the file. The Express/Socket.IO server registers peers, proposes links, exchanges WebRTC signaling, and broadcasts topology, but does not carry file data. The README also documents churn, connectivity and MST views, routing choices, and optional TURN credentials. Architecture links follow the sampled code and README; several UI and transfer details are documented but their complete implementations were not sampled.
Main entry points: app.js Browser UI · server.js HTTP and Socket.IO · transfer.js Transfer manager · algorithms.js Routing algorithms
Components 13
Signaling server
- HTTP and Socket.IO
server/server.js - Topology state
server/server.js
Peer browser
- Browser UI
frontend/js/app.js - Socket client
frontend/js/app.js
Topology and routing
- Peer graph
frontend/js/graph.js - Routing algorithms
frontend/js/algorithms.js
WebRTC transfer
- Transfer manager
frontend/js/transfer.js - Peer data channels
frontend/js/transfer.js
Other components
- Peer user
- Metered TURN
- Remote peers
- Selected file
- Received file
Connections 19
- Peer user → Browser UI: selects and sends
- Selected file → Browser UI: selects
- Browser UI → Socket client: connects and signals
- Socket client → HTTP and Socket.IO: Socket.IO events
- HTTP and Socket.IO → Topology state: registers and updates
- HTTP and Socket.IO → Socket client: initializes and broadcasts
- HTTP and Socket.IO → Remote peers: relays signaling
- HTTP and Socket.IO → Metered TURN: fetches credentials
- HTTP and Socket.IO → Socket client: provides ICE servers
- Browser UI → Peer graph: syncs topology
- Browser UI → Transfer manager: creates and directs
- Browser UI → Routing algorithms: computes route and MST
- Transfer manager → Routing algorithms: finds transfer route
- Transfer manager → Socket client: exchanges signaling and latency
- Transfer manager → Peer data channels: opens peer connections
- Peer data channels → Remote peers: exchanges chunks directly
- Peer data channels → Transfer manager: delivers received chunks
- Transfer manager → Browser UI: reports progress and completion
- Browser UI → Received file: offers completed file