Skip to content

drona-gyawali/SDR-9

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SecureTransfer (SDR-9)

SecureTransfer is a high-performance, real-time file-sharing system built on the WebRTC protocol. It enables fully peer-to-peer (P2P) transfers, ensuring your files never touch a central server.


System Architecture

SecureTransfer uses a Signaling-First, P2P-Second approach. While the server helps peers find each other, it never sees the file data.

Connection Flow

sequenceDiagram
    participant S as Sender (Peer A)
    participant SS as Signaling Server (Node/Socket.io)
    participant R as Receiver (Peer B)
    
    S->>SS: Generate Offer
    SS->>R: Relay Offer (via Link/Email)
    R->>SS: Generate Answer
    SS->>S: Relay Answer
    Note over S,R: WebRTC Data Channel Open (P2P)
    S->>R: Stream File Chunks
Loading

Demo Video

Screencast.from.2025-12-18.21-48-23.mov

System Architecture

SecureTransfer relies on WebRTC Data Channels to facilitate direct communication between browsers.

How it Works

  1. The Handshake: The Sender creates a room, which generates a unique WebRTC "Offer."
  2. Signaling: The Receiver joins via a shared link or email invitation. We use a Socket.io signaling server to exchange connection metadata.
  3. The Connection: Once the peers find each other via STUN servers, the connection becomes purely P2P.
    • Note: Success rates for STUN-based connections are typically around 80%. If a connection fails, it is usually due to restrictive firewalls (Symmetric NAT), not the software itself.
  4. The Transfer: Files are broken into small chunks, sent over the data channel, and reassembled in real-time on the receiver's end.

The "Hard Part": Chunking & Assembly

Handling files over 1GB without crashing the browser was the primary challenge.

  • Memory Management: To avoid memory overflow, we don't load the whole file at once. We slice the file into ArrayBuffer chunks.
  • Reassembly: On the receiver side, we manage Uint8Array fragments, ensuring they are reassembled in the correct order to maintain file integrity.

Tech Stack

  • Frontend: React (UI & WebRTC implementation)
  • Signaling Server: Node.js (Express & Socket.io)
  • Email Queue: BullMQ + Redis (Handles invitation delivery)
  • **UI Design and implementation is done by Kushal Aryal

Installation & Setup

Access the UI

Docker Installation(Recommended)

// run command from the root
docker compose up -d

1. Prerequisites

  • Node.js installed
  • Redis server running (for BullMQ)

2. Backend Setup

cd backend
npm install
# Configure your .env file (see .env.example)
npm run dev

3. Run the Worker (For Email Invitations)

cd backend
npm run worker

4. Frontend Setup

cd frontend
npm install
npm run dev

Love it! Give it a star.

About

SDR-9 - direct p2p file sharing system without central storage server.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors