Skip to content

ayush80942/P2P-File-Transfer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ P2P File Transfer

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.


βš™οΈ Features

  • πŸ“‘ 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 /Backend and /Frontend folders

πŸ“ Folder Structure

.
β”œβ”€β”€ Backend/       # Axum server with WebSocket logic
β”œβ”€β”€ Frontend/      # Next.js frontend UI
β”œβ”€β”€ .DS_Store      # macOS system file (ignored)
└── README.md

πŸš€ Getting Started

1. Clone the repository

git clone https://github.com/your-username/p2p-file-transfer.git
cd p2p-file-transfer

2. Run the Backend (Rust + Axum)

Ensure Rust is installed.

cd Backend
cargo run

βœ… Backend runs at ws://localhost:8000/ws


3. Run the Frontend (Next.js)

Requires Node.js v18+

cd ../Frontend
npm install
npm run dev

βœ… Frontend runs at http://localhost:3000


πŸ”§ How It Works

  • Each WebSocket connection is assigned a unique ID using Uuid.
  • Clients send a register message to claim a connectionId.
  • Messages with target_id are forwarded to the appropriate peer.
  • Supports:
    • Text: JSON-based signaling for registration & session control
    • Binary: File data sent directly between browsers

πŸ“Έ Demo (Local)

  1. Open two browser tabs at http://localhost:3000
  2. Share the session code between them
  3. Select or drag a file to start transferring

✨ Built With

About

Mono repo for a peer-to-peer file transfer application made using Rust & NextJS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published