Minimal BitTorrent client in Node.js – tracker communication, peer list, torrent parsing and downloading files from peers
A fully functional BitTorrent client built from scratch using Node.js. This project demonstrates how the BitTorrent protocol works at a low level, including tracker communication (UDP & HTTP), torrent file parsing, peer discovery, and file downloading via the peer wire protocol.
This BitTorrent client is designed for educational and experimental purposes. It covers the entire flow of downloading files using .torrent metadata:
- Parses
.torrentfiles - Communicates with trackers to discover peers
- Connects to peers using the BitTorrent wire protocol
- Requests and downloads file pieces from peers
- Assembles and saves the complete file(s) locally
- ✅ Torrent file parsing (bencode decoding)
- ✅ Tracker communication (UDP and HTTP)
- ✅ Peer discovery and peer list extraction
- ✅ Peer wire protocol (handshake, bitfield, request, piece, etc.)
- ✅ Piece selection and reassembly
- ✅ File download and save to disk
- 🛠️ Error handling and reconnection logic
- 📊 Logging for all major events (trackers, peers, progress, etc.)
- Node.js (v18+ recommended)
- Core modules:
net,dgram,fs,crypto,events,buffer - Custom bencode parser
- Minimal dependencies – built from scratch to understand internals