How sriharisrihari164-netizen/brotransfer works
Project type & purpose (from file tree + README)
This is a frontend-only Single Page Application (SPA) built with React + Vite (no backend code present). The component naming strongly indicates a P2P file transfer app running entirely in the browser:
• src/components/Sender.jsx, Receiver.jsx, FileDrop.jsx → sender/receiver UX and file selection
• src/hooks/usePeer.js, useFileSender.js, useFileReceiver.js → WebRTC peer/data-channel orchestration and file send/receive logic
• src/workers/fileWorker.js → heavy file processing off the main thread (chunking, hashing, assembling, etc.)
• Static hosting/deploy hints:
• .github/workflows/github-pages.yml → GitHub Pages deploy
• public/CNAME, public/.nojekyll, public/404.html, sitemap.xml → static site + custom domain + SPA routing behavior
So your “system” is primarily: two browsers + WebRTC + optional external NAT traversal infrastructure + static hosting.
UI / Pages (route-level)
• src/pages/Home.jsx – main flow (likely sender/receiver entry)
• src/pages/PrivacyPolicy.jsx, TermsOfService.jsx – legal pages
• Layout/branding:
• src/components/Layout.jsx, Header.jsx, Logo.jsx
• src/components/Instructions.jsx, Features.jsx
Core P2P features (high-value runtime components)
• Peer Connection / Session
• src/hooks/usePeer.js
• Responsibility: create/manage RTCPeerConnection, ICE candidates, DataChannel events, connection lifecycle
• File Sending
• src/hooks/useFileSender.js
• src/components/Sender.jsx, FileDrop.jsx
• Responsibility: select file, chunk/stream, backpressure, send over DataChannel
• File Receiving
• src/hooks/useFileReceiver.js
• src/components/Receiver.jsx
• Responsibility: receive chunks, validate/assemble, trigger download/save
• Worker offload
• src/workers/fileWorker.js
• Responsibility: CPU/memory-heavy operations off main thread (chunking, merging, hashing, etc.)
• Debug / observability
• src/components/DebugLogger.jsx
• src/utils/debugLog.js
• Responsibility: structured logging, toggles, UI visibility
Inside each browser runtime, show:
• Sender.jsx → useFileSender.js → usePeer.js → WebRTC DataChannel
• Web Worker boundary:
• useFileSender.js ↔ fileWorker.js (postMessage for chunking/processing)
• useFileReceiver.js ↔ fileWorker.js (postMessage for assembling/validation)
• DebugLogger.jsx ← debugLog.js called by hooks/components
WebRTC DataChannel opens
Annotate clearly: “Signaling is not the file transfer path.”
Flow 2: File transfer pipeline (data plane)
Sender side:
• File chosen in FileDrop.jsx / Sender.jsx
• useFileSender.js reads file (stream/chunks)
• fileWorker.js prepares chunks (optional compression/hashing)
• Chunks sent over DataChannel (backpressure / buffering)
Receiver side:
• DataChannel receives chunks (usePeer.js → useFileReceiver.js)
• fileWorker.js assembles chunks
• Receiver triggers browser download/save
• “binary chunks (ArrayBuffer/Blob)”
• “control messages (metadata: filename, size, chunk index)”
• Developer pushes to GitHub
• GitHub Actions (.github/workflows/github-pages.yml) runs:
• npm ci (from package-lock.json)
• vite build
• Output deployed to GitHub Pages
• DNS / custom domain via public/CNAME
• SPA routing support via public/404.html and .nojekyll
This is especially important because the “system” has no backend—availability is basically “static host + WebRTC infra”.
Diagramming conventions to enforce (for maximum clarity)
• Boundaries:
• “Sender Browser” boundary
• “Receiver Browser” boundary
• “Static Hosting” boundary
• “External WebRTC Services” boundary
• Rectangle: React component/hook/module
• Double-rectangle or “container”: Browser runtime / SPA container
• Labels everywhere:
• Protocol labels: HTTPS (hosting), WebRTC (P2P), STUN/TURN
• Data labels: SDP offer/answer, ICE candidates, chunked binary
Practical “don’t overthink it” decomposition (recommended final component list)
If your goal is “very detailed and capture essentials,” use this exact top-level decomposition: