How tranlam2004/peer-to-peer-sharing works
Main Components
• Tracker: Acts as a central coordinator, managing communication between the Seeder and the Peers.
• Seeder: Responsible for uploading (sharing) files and serving them to Peers.
• Peers: Nodes that request and download files from the Seeder (and potentially other Peers).
• CLI Interface: Facilitates all user commands and interactions (e.g., file creation, upload, download, and info display).
• Supporting Modules: Components such as PeerConnection, Downloader, Upload, Torrent, and utility modules that encapsulate the core functionalities and communication logic.
• External Dependencies: Although not in the file tree, the README mentions tools like Python, Docker, Pip, and MySQL. (Even if MySQL is not explicitly represented in the file list, include it as an external component if it is used for metadata management).
Architectural Relationships and Interactions
• The CLI serves as the entry point for user commands, triggering actions like torrent file creation (using Torrent.py), uploading (handled by Upload.py), or downloading files (via Downloader.py).
• The Tracker sits in the center of the file-sharing network, managing discovery and coordination between the Seeder and Peers. It receives status or update messages (possibly via modules such as sendMessage.py) and informs nodes about available resources.
• PeerConnection handles the communication protocols among peers, ensuring proper data exchange.
• The Seeder shares files across the network in response to download requests received either directly from Peers or via Tracker-mediated discovery.
• Peers initiate downloads by querying the Tracker to get lists or metadata of available torrents and then connecting to the Seeder to retrieve file data.
Architectural Patterns and Design Principles
• P2P Architecture with a central coordination element (Tracker) which simplifies discovery in a LAN-based network.
• Modular design: Each file (e.g., Downloader.py, Upload.py, Torrent.py) encapsulates specific functionality, improving separation of concerns.
• CLI-driven control ensures that each role (Tracker, Seeder, Peer) can be started or managed individually on different devices as outlined in the README.
• Extensibility: Modules are decoupled, so enhancements (such as adding error handling, improved peer selection, or additional metadata handling) can be implemented without major changes in the overall structure.