# akashcx/chord-p2p-file-sharing-system architecture

> Architecture diagram of the GitHub repository akashcx/chord-p2p-file-sharing-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akashcx/chord-p2p-file-sharing-system
- Repository: https://github.com/akashcx/chord-p2p-file-sharing-system

## Overview

##### Project Components
- Bootstrap Node: The central entry point initiating the chord network. It’s clearly the “bootstrap” container that the README refers to.
- Peer Nodes: Multiple containers (scaled via Docker Compose) that form the P2P network and participate in file transfer operations.
- Node Internal Logic: In the “node” directory, you have files such as assembler.go, chunker.go, message.go, and node.go indicating internal functionalities—assemble data, break it into chunks, handle messaging, and node behavior respectively.
- Utilities and Supporting Logic: The “utils” folder houses helper functions (utils.go) that likely support operations across nodes.
- Data Layer: The “data” folder contains files (like file.txt and a video file) which are likely used in demonstrating file transfer capabilities.
- Infrastructure & Orchestration: The Dockerfile, docker-compose.yml, and the overall Docker-based orchestration underline how the containers are built and interact.

##### Architecturally Significant Patterns
- Container-based Deployment: Highlight Docker’s role in orchestrating the bootstrap and peer nodes.
- Modularity in Node Functionality: The separation between assembling, chunking, and messaging within the node indicates a modular structure internally.

- One for the "Bootstrap Node"
- Message handling (from message.go)
- Data chunking (from chunker.go)
- Assembling files (from assembler.go)
- Another for core application components (bootstrap and peers)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        DCO["Docker Compose Orchestrator"]:::infra
        DF["Dockerfile"]:::infra
    end

    %% Application Layer
    subgraph "Application Layer"
        BS["Bootstrap Node"]:::node
        PN1["Peer Node 1"]:::node
        PN2["Peer Node 2"]:::node
        PN3["Peer Node 3"]:::node

        subgraph "Node Internal Logic"
            AST["Assembler"]:::module
            CHK["Chunker"]:::module
            MSG["Message Handler"]:::module
        end

        UT["Utilities"]:::util
    end

    %% Data Repository
    DR["Data Repository"]:::data

    %% Connections from Infrastructure to Application
    DCO -->|"launches"| BS
    DCO -->|"launches"| PN1
    DCO -->|"launches"| PN2
    DCO -->|"launches"| PN3

    %% Chord network between Bootstrap and Peer Nodes
    BS -->|"chord"| PN1
    PN1 -->|"chord"| PN2
    PN2 -->|"chord"| PN3
    PN3 -->|"chord"| BS

    %% Data transfer connection
    DR -->|"file_transfer"| PN1
    DR -->|"file_transfer"| PN2
    DR -->|"file_transfer"| PN3

    %% Utilities supporting nodes
    UT -->|"supports"| BS
    UT -->|"supports"| PN1
    UT -->|"supports"| PN2
    UT -->|"supports"| PN3

    %% Peer Nodes using Internal Logic (dotted arrows)
    PN1 -.->|"logic"| AST
    PN1 -.->|"logic"| CHK
    PN1 -.->|"logic"| MSG

    PN2 -.->|"logic"| AST
    PN2 -.->|"logic"| CHK
    PN2 -.->|"logic"| MSG

    PN3 -.->|"logic"| AST
    PN3 -.->|"logic"| CHK
    PN3 -.->|"logic"| MSG

    %% Click Events
    click BS "https://github.com/akashcx/chord-p2p-file-sharing-system/blob/main/docker-compose.yml"
    click PN1 "https://github.com/akashcx/chord-p2p-file-sharing-system/blob/main/node/node.go"
    click PN2 "https://github.com/akashcx/chord-p2p-file-sharing-system/blob/main/node/node.go"
    click PN3 "https://github.com/akashcx/chord-p2p-file-sharing-system/blob/main/node/node.go"
    click AST "https://github.com/akashcx/chord-p2p-file-sharing-system/blob/main/node/assembler.go"
    click CHK "https://github.com/akashcx/chord-p2p-file-sharing-system/blob/main/node/chunker.go"
    click MSG "https://github.com/akashcx/chord-p2p-file-sharing-system/blob/main/node/message.go"
    click UT "https://github.com/akashcx/chord-p2p-file-sharing-system/blob/main/utils/utils.go"
    click DR "https://github.com/akashcx/chord-p2p-file-sharing-system/tree/main/data/"
    click DCO "https://github.com/akashcx/chord-p2p-file-sharing-system/blob/main/docker-compose.yml"
    click DF "https://github.com/akashcx/chord-p2p-file-sharing-system/tree/main/Dockerfile"

    %% Styles
    classDef infra fill:#a2d9ff,stroke:#1f618d,stroke-width:2px;
    classDef node fill:#abebc6,stroke:#145a32,stroke-width:2px;
    classDef module fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef util fill:#fad7a0,stroke:#d35400,stroke-width:2px;
    classDef data fill:#d2b4de,stroke:#6c3483,stroke-width:2px;
```
