A lightweight real-time peer-to-peer (P2P) file transfer application using WebSockets, built with Rust (Axum) on the backend and Next.js on the frontend β structured as a mono-repo.
- π‘ WebSocket-based real-time file streaming between peers
- π Peer registration and routing using unique
connectionId - π Direct binary data transfer (files) without server-side storage
- π Next.js UI for easy sharing between browsers
- π§© Mono-repo structure with separate
/Backendand/Frontendfolders
.
βββ Backend/ # Axum server with WebSocket logic
βββ Frontend/ # Next.js frontend UI
βββ .DS_Store # macOS system file (ignored)
βββ README.md
git clone https://github.com/your-username/p2p-file-transfer.git
cd p2p-file-transferEnsure Rust is installed.
cd Backend
cargo runβ Backend runs at
ws://localhost:8000/ws
Requires Node.js v18+
cd ../Frontend
npm install
npm run devβ Frontend runs at
http://localhost:3000
- Each WebSocket connection is assigned a unique ID using
Uuid. - Clients send a
registermessage to claim aconnectionId. - Messages with
target_idare forwarded to the appropriate peer. - Supports:
Text: JSON-based signaling for registration & session controlBinary: File data sent directly between browsers
- Open two browser tabs at
http://localhost:3000 - Share the session code between them
- Select or drag a file to start transferring