# aggelako/distributed-ntua architecture

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

- Interactive diagram: https://gitdiagram.com/aggelako/distributed-ntua
- Repository: https://github.com/aggelako/distributed-ntua

## Overview

##### Project Type and Purpose
- The README explains that this is a file transfer application using a DHT based on the Chord protocol.
- The project is laid out as a distributed system: a bootstrap node (server.py) to initialize and manage the chord network and slave nodes (slaveserver.py) which join the DHT.
- There is also a CLI (cli.py) that allows a user to issue commands (file transfers or queries) to the network.

##### File Structure
- Main executable scripts include:
– server.py: Likely the bootstrap node which initializes the chord ring and sets up replication/consistency options.
– slaveserver.py: For individual node instantiation (each representing a slave/worker) that join the chord network.
– cli.py: The command-line interface issuing commands to interact with the system.
– dhtclasses.py: Contains the classes and logic for DHT operations (e.g., node management, finger table, stabilization, file lookup).
- Supporting scripts (runall.sh, script.sh) likely automate the start-up of multiple nodes or execute typical operations.
- Additional files like Report.pdf and assignment20_21.pdf suggest academic or documentation content, but the system’s architecture is fundamentally determined by the DHT and its node interactions.

##### README for Additional Insights
- The README details how to install dependencies (e.g., Flask, termcolor, pyfiglet) and hints at a possible web component or a simple UI aspect enabled by Flask.
- It specifies required configurations, such as hardcoded IPs and ports, emphasizing the network nature.
- The parameters for starting the server (replication factor and consistency type) indicate that nodes interact with a replication and consistency protocol—this part is key in your design.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        CLI["CLI (cli.py)"]:::cli
    end

    %% Application/Server Layer
    subgraph "Application/Server Layer"
        SERVER["Bootstrap Node (server.py)"]:::server
        NOTE["ReplicationFactor&Consistency"]:::noteStyle
    end

    %% Node Layer
    subgraph "Node Layer"
        SLAVE1["Slave Node (slaveserver.py)"]:::node
        SLAVE2["Slave Node (slaveserver.py)"]:::node
        DHT["DHT Logic (dhtclasses.py)"]:::dht
    end

    %% Automation/Orchestration Layer
    subgraph "Automation Scripts"
        RUNALL["Automation Script (runall.sh)"]:::script
        SCRIPT["Automation Script (script.sh)"]:::script
    end

    %% Connections
    CLI -->|"command"| SERVER
    SERVER -->|"init_join"| SLAVE1
    SERVER -->|"init_join"| SLAVE2
    SERVER ---|"utilizes"| DHT
    SLAVE1 ---|"utilizes"| DHT
    SLAVE2 ---|"utilizes"| DHT
    SLAVE1 <-->|"stabilize_lookup"| SLAVE2

    %% Annotation connection for server config details
    SERVER --- NOTE

    %% Click Events
    click SERVER "https://github.com/aggelako/distributed-ntua/blob/main/server.py"
    click SLAVE1 "https://github.com/aggelako/distributed-ntua/blob/main/slaveserver.py"
    click CLI "https://github.com/aggelako/distributed-ntua/blob/main/cli.py"
    click DHT "https://github.com/aggelako/distributed-ntua/blob/main/dhtclasses.py"
    click RUNALL "https://github.com/aggelako/distributed-ntua/blob/main/runall.sh"
    click SCRIPT "https://github.com/aggelako/distributed-ntua/blob/main/script.sh"

    %% Styles
    classDef cli fill:#f9c,stroke:#333,stroke-width:2px;
    classDef server fill:#bbf,stroke:#333,stroke-width:2px;
    classDef node fill:#afa,stroke:#333,stroke-width:2px;
    classDef dht fill:#ffc,stroke:#333,stroke-width:2px;
    classDef script fill:#fdd,stroke:#333,stroke-width:2px;
    classDef noteStyle fill:#eee,stroke:#333,stroke-dasharray: 5, 5,stroke-width:1px;
```
