# findingnothing85/systems-from-scratch architecture

> Architecture diagram of the GitHub repository findingnothing85/systems-from-scratch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/findingnothing85/systems-from-scratch
- Repository: https://github.com/findingnothing85/systems-from-scratch

## Overview

Systems-From-Scratch is a series of progressively developed C socket-programming examples, culminating in a TCP file-transfer client/server. The core workflow sends a requested filename, reads the matching server-side file, and returns its size and contents for the client to save. Later server versions add per-client threads and then a worker queue. The graph emphasizes the sampled implementations; several intermediate versions appear in the tree but were not sampled, so their internal behavior is not inferred.

Main entry points: [`V11/fileclient.c`](https://github.com/findingnothing85/systems-from-scratch/blob/main/V11/fileclient.c) (Size-aware download), [`V11/fileserver.c`](https://github.com/findingnothing85/systems-from-scratch/blob/main/V11/fileserver.c) (Size-header server), [`V1/fileclient.c`](https://github.com/findingnothing85/systems-from-scratch/blob/main/V1/fileclient.c) (Basic download), [`V4/fileclient.c`](https://github.com/findingnothing85/systems-from-scratch/blob/main/V4/fileclient.c) (Fixed-file download)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["File client"]
  node_client_v1["Basic download<br/>[fileclient.c]"]
  node_client_v4["Fixed-file download<br/>[fileclient.c]"]
  node_client_v5["Named-file download<br/>[fileclient.c]"]
  node_client_v6["Stream to file<br/>[fileclient.c]"]
  node_client_v8["Request filename<br/>[fileclient.c]"]
  node_client_v11["Size-aware download<br/>[fileclient.c]"]
end

subgraph group_server["File server"]
  node_server_v6["Single-file server<br/>[fileserver.c]"]
  node_server_v10["Requested-file server<br/>[fileserver.c]"]
  node_server_v11["Size-header server<br/>[fileserver.c]"]
  node_server_v12["Thread-per-client<br/>[fileserver.c]"]
  node_server_v14["Queued server<br/>[fileserver.c]"]
end

subgraph group_concurrency["Server concurrency"]
  node_accept["Accept clients<br/>[fileserver.c]"]
  node_queue["Client queue<br/>[fileserver.c]"]
  node_worker["Worker threads<br/>[fileserver.c]"]
end

node_user(("User"))
node_network(("TCP connection"))
node_server_file[("Server files")]
node_client_file["Downloaded file"]

node_user -->|"requests file"| node_client_v11
node_client_v11 -->|"sends filename"| node_network
node_network -->|"delivers request"| node_server_v11
node_server_v11 -->|"reads requested file"| node_server_file
node_server_v11 -->|"sends size and bytes"| node_network
node_network -->|"delivers response"| node_client_v11
node_client_v11 -->|"writes contents"| node_client_file
node_user -->|"provides filename"| node_client_v8
node_client_v8 -->|"sends filename"| node_network
node_server_v10 -->|"reads requested file"| node_server_file
node_server_v10 -->|"sends file bytes"| node_network
node_server_v6 -->|"reads configured file"| node_server_file
node_server_v6 -->|"sends file bytes"| node_network
node_client_v6 -->|"receives bytes"| node_network
node_client_v6 -->|"writes contents"| node_client_file
node_client_v1 -->|"receives bytes"| node_network
node_client_v1 -->|"writes contents"| node_client_file
node_client_v4 -->|"receives bytes"| node_network
node_client_v4 -->|"writes contents"| node_client_file
node_client_v5 -->|"sends filename"| node_network
node_client_v5 -->|"writes contents"| node_client_file
node_client_v11 -->|"connects"| node_network
node_server_v14 -->|"accepts connections"| node_accept
node_accept -->|"enqueues clients"| node_queue
node_queue -->|"dispatches clients"| node_worker
node_worker -->|"handles request"| node_server_v14
node_server_v12 -->|"reads requested file"| node_server_file
node_server_v12 -->|"sends size and bytes"| node_network

click node_client_v1 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V1/fileclient.c"
click node_client_v4 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V4/fileclient.c"
click node_client_v5 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V5/fileclient.c"
click node_client_v6 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V6/fileclient.c"
click node_client_v8 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V8/fileclient.c"
click node_client_v11 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V11/fileclient.c"
click node_server_v6 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V6/fileserver.c"
click node_server_v10 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V10/fileserver.c"
click node_server_v11 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V11/fileserver.c"
click node_server_v12 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V12/fileserver.c"
click node_server_v14 "https://github.com/findingnothing85/systems-from-scratch/blob/main/V14/fileserver.c"
click node_accept "https://github.com/findingnothing85/systems-from-scratch/blob/main/V14/fileserver.c"
click node_queue "https://github.com/findingnothing85/systems-from-scratch/blob/main/V14/fileserver.c"
click node_worker "https://github.com/findingnothing85/systems-from-scratch/blob/main/V14/fileserver.c"

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_v1,node_client_v4,node_client_v5,node_client_v6,node_client_v8,node_client_v11,node_user toneBlue
class node_server_v6,node_server_v10,node_server_v11,node_server_v12,node_server_v14,node_server_file toneAmber
class node_accept,node_queue,node_worker toneMint
class node_network,node_client_file toneIndigo
```

## Components

### File client

- [Basic download](https://github.com/findingnothing85/systems-from-scratch/blob/main/V1/fileclient.c): `V1/fileclient.c`
- [Fixed-file download](https://github.com/findingnothing85/systems-from-scratch/blob/main/V4/fileclient.c): `V4/fileclient.c`
- [Named-file download](https://github.com/findingnothing85/systems-from-scratch/blob/main/V5/fileclient.c): `V5/fileclient.c`
- [Stream to file](https://github.com/findingnothing85/systems-from-scratch/blob/main/V6/fileclient.c): `V6/fileclient.c`
- [Request filename](https://github.com/findingnothing85/systems-from-scratch/blob/main/V8/fileclient.c): `V8/fileclient.c`
- [Size-aware download](https://github.com/findingnothing85/systems-from-scratch/blob/main/V11/fileclient.c): `V11/fileclient.c`

### File server

- [Single-file server](https://github.com/findingnothing85/systems-from-scratch/blob/main/V6/fileserver.c): `V6/fileserver.c`
- [Requested-file server](https://github.com/findingnothing85/systems-from-scratch/blob/main/V10/fileserver.c): `V10/fileserver.c`
- [Size-header server](https://github.com/findingnothing85/systems-from-scratch/blob/main/V11/fileserver.c): `V11/fileserver.c`
- [Thread-per-client](https://github.com/findingnothing85/systems-from-scratch/blob/main/V12/fileserver.c): `V12/fileserver.c`
- [Queued server](https://github.com/findingnothing85/systems-from-scratch/blob/main/V14/fileserver.c): `V14/fileserver.c`

### Server concurrency

- [Accept clients](https://github.com/findingnothing85/systems-from-scratch/blob/main/V14/fileserver.c): `V14/fileserver.c`
- [Client queue](https://github.com/findingnothing85/systems-from-scratch/blob/main/V14/fileserver.c): `V14/fileserver.c`
- [Worker threads](https://github.com/findingnothing85/systems-from-scratch/blob/main/V14/fileserver.c): `V14/fileserver.c`

### Other components

- **User**
- **TCP connection**
- **Server files**
- **Downloaded file**

## Connections

- User → Size-aware download: requests file
- Size-aware download → TCP connection: sends filename
- TCP connection → Size-header server: delivers request
- Size-header server → Server files: reads requested file
- Size-header server → TCP connection: sends size and bytes
- TCP connection → Size-aware download: delivers response
- Size-aware download → Downloaded file: writes contents
- User → Request filename: provides filename
- Request filename → TCP connection: sends filename
- Requested-file server → Server files: reads requested file
- Requested-file server → TCP connection: sends file bytes
- Single-file server → Server files: reads configured file
- Single-file server → TCP connection: sends file bytes
- Stream to file → TCP connection: receives bytes
- Stream to file → Downloaded file: writes contents
- Basic download → TCP connection: receives bytes
- Basic download → Downloaded file: writes contents
- Fixed-file download → TCP connection: receives bytes
- Fixed-file download → Downloaded file: writes contents
- Named-file download → TCP connection: sends filename
- Named-file download → Downloaded file: writes contents
- Size-aware download → TCP connection: connects
- Queued server → Accept clients: accepts connections
- Accept clients → Client queue: enqueues clients
- Client queue → Worker threads: dispatches clients
- Worker threads → Queued server: handles request
- Thread-per-client → Server files: reads requested file
- Thread-per-client → TCP connection: sends size and bytes
