# sotheasokea/multi-threaded-file-download-client-server architecture

> Architecture diagram of the GitHub repository sotheasokea/multi-threaded-file-download-client-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sotheasokea/multi-threaded-file-download-client-server
- Repository: https://github.com/sotheasokea/multi-threaded-file-download-client-server

## Overview

This is a Java TCP file-download client/server. The client queries the server for a file listing and size, downloads byte ranges into a local file, and checks size and SHA-256; the server handles concurrent connections and serves listing, metadata, and range requests from a shared directory. Traditional socket I/O and NIO transfer are optional modes. The client currently configures one range despite providing range-splitting and parallel-worker logic. Relationships reflect the sampled source and README; the shared directory is configured in the server, while its contents are external.

Main entry points: [`MultithreadFileDownload/src/Client.java`](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java) (Download workflow), [`MultithreadFileDownload/src/Server.java`](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java) (Command handler), [`MultithreadFileDownload/src/TestServerSide.java`](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/TestServerSide.java) (Server test client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client"]
  node_client_workflow["Download workflow<br/>[Client.java]"]
  node_range_planner["Range planner<br/>[Client.java]"]
  node_download_workers["Download workers<br/>[Client.java]"]
  node_output_file["Downloaded file<br/>[Client.java]"]
  node_verification["Download verification<br/>[Client.java]"]
end

subgraph group_server["Server"]
  node_server_listener["Connection listener<br/>[Server.java]"]
  node_request_handler["Command handler<br/>[Server.java]"]
  node_shared_files[("Shared files<br/>[Server.java]")]
  node_traditional_io["Traditional transfer<br/>[Server.java]"]
  node_nio_transfer["NIO transfer<br/>[Server.java]"]
end

node_user(("User"))
node_test_client["Server test client"]

node_user -->|"requests download"| node_client_workflow
node_client_workflow -->|"requests LIST, INFO"| node_server_listener
node_client_workflow -->|"calculates ranges"| node_range_planner
node_client_workflow -->|"starts downloads"| node_download_workers
node_download_workers -->|"requests GET ranges"| node_server_listener
node_download_workers -->|"writes ranges"| node_output_file
node_client_workflow -->|"checks download"| node_verification
node_verification -->|"reads and hashes"| node_output_file
node_server_listener -->|"dispatches connections"| node_request_handler
node_request_handler -->|"lists and reads"| node_shared_files
node_request_handler -->|"streams bytes"| node_traditional_io
node_request_handler -->|"transfers bytes"| node_nio_transfer
node_test_client -->|"sends test requests"| node_server_listener

click node_client_workflow "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java"
click node_range_planner "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java"
click node_download_workers "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java"
click node_output_file "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java"
click node_verification "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java"
click node_server_listener "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java"
click node_request_handler "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java"
click node_shared_files "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java"
click node_traditional_io "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java"
click node_nio_transfer "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java"
click node_test_client "https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/TestServerSide.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_workflow,node_range_planner,node_download_workers,node_output_file,node_verification,node_user,node_test_client toneBlue
class node_server_listener,node_request_handler,node_shared_files,node_traditional_io,node_nio_transfer toneAmber
```

## Components

### Client

- [Download workflow](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java): `MultithreadFileDownload/src/Client.java`
- [Range planner](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java): `MultithreadFileDownload/src/Client.java`
- [Download workers](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java): `MultithreadFileDownload/src/Client.java`
- [Downloaded file](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java): `MultithreadFileDownload/src/Client.java`
- [Download verification](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Client.java): `MultithreadFileDownload/src/Client.java`

### Server

- [Connection listener](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java): `MultithreadFileDownload/src/Server.java`
- [Command handler](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java): `MultithreadFileDownload/src/Server.java`
- [Shared files](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java): `MultithreadFileDownload/src/Server.java`
- [Traditional transfer](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java): `MultithreadFileDownload/src/Server.java`
- [NIO transfer](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/Server.java): `MultithreadFileDownload/src/Server.java`

### Other components

- **User**
- [Server test client](https://github.com/sotheasokea/multi-threaded-file-download-client-server/blob/back_up_main/MultithreadFileDownload/src/TestServerSide.java): `MultithreadFileDownload/src/TestServerSide.java`

## Connections

- User → Download workflow: requests download (evidence: `MultithreadFileDownload/src/Client.java`)
- Download workflow → Connection listener: requests LIST, INFO (evidence: `MultithreadFileDownload/src/Client.java`)
- Download workflow → Range planner: calculates ranges (evidence: `MultithreadFileDownload/src/Client.java`)
- Download workflow → Download workers: starts downloads (evidence: `MultithreadFileDownload/src/Client.java`)
- Download workers → Connection listener: requests GET ranges (evidence: `MultithreadFileDownload/src/Client.java`)
- Download workers → Downloaded file: writes ranges (evidence: `MultithreadFileDownload/src/Client.java`)
- Download workflow → Download verification: checks download (evidence: `MultithreadFileDownload/src/Client.java`)
- Download verification → Downloaded file: reads and hashes (evidence: `MultithreadFileDownload/src/Client.java`)
- Connection listener → Command handler: dispatches connections (evidence: `MultithreadFileDownload/src/Server.java`)
- Command handler → Shared files: lists and reads (evidence: `MultithreadFileDownload/src/Server.java`)
- Command handler → Traditional transfer: streams bytes (evidence: `MultithreadFileDownload/src/Server.java`)
- Command handler → NIO transfer: transfers bytes (evidence: `MultithreadFileDownload/src/Server.java`)
- Server test client → Connection listener: sends test requests (evidence: `MultithreadFileDownload/src/TestServerSide.java`)
