# joewil08/p2p-file-synchronization-group-3 architecture

> Architecture diagram of the GitHub repository joewil08/p2p-file-synchronization-group-3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joewil08/p2p-file-synchronization-group-3
- Repository: https://github.com/joewil08/p2p-file-synchronization-group-3

## Overview

##### Project type and purpose
- This is a Python‑based, CLI peer‑to‑peer file synchronization application for a local network that uses a central tracker for peer discovery. Users register, share public/private files, send messages, and manage trusted peers.

##### File structure
- Top‑level scripts
– main.py             → CLI entrypoint, shows main menu and orchestrates user commands
– file_sync.py        → handles sending/receiving files (public/private)
– files_directory.py  → manages local file index and metadata (IDs, access control)
– message.py          → messaging service (send, receive, reply)
– peer.py             → peer discovery & registration messages
– subscription.py     → subscribe/unsubscribe logic for tracker broadcasts
- utils/
– generate_peer_id.py → creates unique peer IDs
– get_host_ip.py      → retrieves local host IP for announcements
– validate_peers.py   → checks peer liveness/trust lists
- .venv, .DS_Store, README.md

Architectural hints:
– Modular services (file sync, messaging, peer discovery)
– Central tracker role for peer registration/discovery
– CLI frontend driving these services

##### README for additional insights
- Central server used only for peer discovery
- Public files broadcast to all, private only to “trusted peers”
- Messaging center with one‑at‑a‑time anti‑spam
- Automatic background peer discovery and file sharing
- Users register/deregister with network broadcasts

##### Detailed but focused
- Trust list gating private file transfers
- Background vs user‑initiated flows

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI Layer"
        CLI["CLI Frontend"]:::cli
    end

    subgraph "Core Services"
        subgraph "Peer Discovery & Tracker Service"
            PDReg["Peer Registration"]:::core
            PDSub["Subscription Service"]:::core
        end
        FD["File Directory Service"]:::core
        FT["File Transfer Engine"]:::core
        MS["Messaging Service"]:::core
        TP["Trusted Peers Manager"]:::core
    end

    subgraph "Utilities"
        U1["Peer ID Generation"]:::util
        U2["Host IP Lookup"]:::util
        U3["Peer Validation/Trust"]:::util
    end

    CT["Central Tracker"]:::external
    Peers("Other Peers")

    CLI -->|"invoke registration"| PDReg
    CLI -->|"invoke subscription"| PDSub
    PDReg -->|"register via UDP/HTTP"| CT
    PDSub -->|"subscribe to broadcasts"| CT
    CT -->|"peer list updates"| PDReg
    CT -->|"broadcast announcements"| PDSub
    PDReg -->|"update CLI"| CLI
    PDSub -->|"update CLI"| CLI

    CLI -->|"list/index files"| FD
    FD -->|"hand off files"| FT
    TP -->|"enforce ACL"| FT
    FT -->|"direct P2P transfer"| Peers

    CLI -->|"send/receive messages"| MS
    MS -->|"direct messaging"| Peers

    U1 --> PDReg
    U2 --> PDReg
    U3 --> TP

    classDef cli fill:#ADD8E6,stroke:#000
    classDef core fill:#90EE90,stroke:#000
    classDef util fill:#D3D3D3,stroke:#000
    classDef external fill:#FFA500,stroke:#000

    click CLI "https://github.com/joewil08/p2p-file-synchronization-group-3/blob/main/main.py"
    click PDReg "https://github.com/joewil08/p2p-file-synchronization-group-3/blob/main/peer.py"
    click PDSub "https://github.com/joewil08/p2p-file-synchronization-group-3/blob/main/subscription.py"
    click FD "https://github.com/joewil08/p2p-file-synchronization-group-3/blob/main/files_directory.py"
    click FT "https://github.com/joewil08/p2p-file-synchronization-group-3/blob/main/file_sync.py"
    click MS "https://github.com/joewil08/p2p-file-synchronization-group-3/blob/main/message.py"
    click U1 "https://github.com/joewil08/p2p-file-synchronization-group-3/blob/main/utils/generate_peer_id.py"
    click U2 "https://github.com/joewil08/p2p-file-synchronization-group-3/blob/main/utils/get_host_ip.py"
    click U3 "https://github.com/joewil08/p2p-file-synchronization-group-3/blob/main/utils/validate_peers.py"
```
