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