The Problem
Large files still need a quick, private way to move from one browser to many others without installing software or trusting a third‑party cloud. Existing services either require accounts, impose size caps, or route data through a central server that can see the contents.
What This Does
FileSync implements a peer‑to‑peer, WebRTC‑based file‑transfer hub. The browser UI lives in web/index.html and its logic under web/js/modules/webrtc/. Signalling is handled by the tiny Python server in api/main.py and api/signaling.py. Docker makes the whole stack portable (Dockerfile, deploy/docker-compose.yml). The repo ships a ready‑to‑run Docker image, a Caddy‑based HTTPS front‑end, and an optional password‑protected “room”.
How It Is Wired
- Entry point – The container starts the Python signalling server (
api/main.py). This process listens for WebSocket connections from the browser clients. - WebRTC setup – In the browser,
web/js/modules/webrtc/user.js(967 LOC) creates aRTCPeerConnection, configuring ICE viaweb/js/modules/webrtc/turn.jsandweb/js/modules/webrtc/mode.js. It then hands the connection toweb/js/modules/webrtc/file.jswhich streams incoming blobs directly to disk using the File System Access API. - Call hot‑spots – The internal call graph shows 763 resolved edges. Functions
on,makeError,ge,e,n,r,trigger,hide,showToast, and_are each called from 10‑13 distinct places, giving them the widest blast radius.show → triggerappears 10 times, and_setListeners → onappears 8 times, indicating that event‑listener wiring is a central concern. - External effects – The only filesystem writes are in the E2E harness (
e2e/run.mjs) viafsp.copyFileandfsp.readFile. The production code does not write to the server’s filesystem; all file data stays in the browser, satisfying the “private by design” claim. - Module hubs –
web/js/modules/webrtc/user.jsimports 7 other modules (instability 0.88) and is the biggest source of cross‑module coupling.web/js/modules/webrtc/file.jsimports 5 modules (instability 0.83). Both are candidates for refactoring to reduce cognitive load. - Unmapped paths – The static analysis could not resolve framework callbacks (e.g., React render) that eventually trigger the WebRTC flow, so those edges are not shown.
How To Use It
# 1. Clone the original repository
git clone https://github.com/moses-y/FileSync.git
cd FileSync
# 2. Generate a secret key (required for TURN auth)
python3 -c "import secrets, base64; print(base64.b64encode(secrets.token_bytes(32)).decode())"
# → copy the output
# 3. Insert the secret into the compose file (replace both placeholders)
sed -i "s|<SECRET_KEY>|YOUR_GENERATED_KEY|g" deploy/docker-compose.yml
# 4. Build and run the stack
docker compose -f deploy/docker-compose.yml up -d
The service becomes reachable at http://localhost (or the host’s IP). Open that URL in a modern browser, create a room, share the link/QR, and drag‑drop files. For public HTTPS deployments, follow the same steps with deploy/docker-compose-ssl.yml and configure Caddy as described in the README.
Real‑World Use
A small design studio wants to exchange multi‑gigabyte video drafts between on‑site editors and remote reviewers. They spin up FileSync on a local machine, generate a secret key, and run the Docker compose file. Reviewers open the shared link in Chrome, receive streamed files directly to their download folder, and no corporate file‑share server sees the content.
Code Health & Issues
- High – Pin third‑party GitHub Actions to a commit SHA (
.github/workflows/*). - Medium – Declare least‑privilege
permissionsforGITHUB_TOKEN(.github/workflows/checks.yml). - Medium – Pin the Docker base image by digest (
Dockerfile). - Medium – Add a dependency‑vulnerability scan step to CI (
.github/workflows/*). - Medium – Set
persist-credentials: falseon the checkout step (.github/workflows/checks.yml). - Medium – Add a non‑root
USERto the container (Dockerfile). - Low – Specify
timeout-minuteson workflow jobs (.github/workflows/checks.yml). - Low – Add repository convention files (
.editorconfig,.gitattributes, formatter config).
Static analysis also flagged three medium‑severity maintainability concerns: broad exception handling in api/signaling.py, high branching density in several WebRTC modules, and the oversized web/js/modules/webrtc/user.js. No critical defects were found, and the repository includes tests, CI, a license, and a lockfile.
The Bottom Line
FileSync delivers a functional, Docker‑ready peer‑to‑peer file‑transfer service with a clean browser UI, but the JavaScript core is tightly coupled and cognitively dense. Security‑focused teams will appreciate the minimal server surface, yet they should address the high‑impact CI hardening issues and consider refactoring the large WebRTC modules before extensive customization. Suitable for teams comfortable with Docker and willing to invest in modest code‑base cleanup.