# rosstheross/csci4061-projects architecture

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

- Interactive diagram: https://gitdiagram.com/rosstheross/csci4061-projects
- Repository: https://github.com/rosstheross/csci4061-projects

## Overview

This repository contains four operating-systems projects: two MapReduce implementations (P1 and P2) and two threaded web servers (P3 and P4). The MapReduce workflow divides input into chunks, maps words to intermediate counts, shuffles them to reducers, and writes final results; the web-server workflow accepts requests, queues them for workers, serves files or errors, and logs activity, with caching and dynamic worker management in the later server. MapReduce orchestration and reducer details are only partially evidenced here, so those relationships are marked unverified or omitted.

Main entry points: [`P4/server.c`](https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c) (Request worker), [`P3/util.h`](https://github.com/rosstheross/csci4061-projects/blob/master/P3/util.h) (Connection and response API), [`P4/util.h`](https://github.com/rosstheross/csci4061-projects/blob/master/P4/util.h) (Connection and response API), [`P1/src/mapreduce.c`](https://github.com/rosstheross/csci4061-projects/blob/master/P1/src/mapreduce.c) (Job orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_p1["P1 MapReduce"]
  node_p1_orchestrator["Job orchestration<br/>[mapreduce.c]"]
  node_p1_utils["Chunk and shuffle utilities<br/>[utils.h]"]
  node_p1_mapper["Mapper<br/>[mapper.c]"]
  node_p1_reducer["Reducer<br/>[reducer.c]"]
end

subgraph group_p2["P2 MapReduce"]
  node_p2_orchestrator["Job orchestration<br/>[mapreduce.c]"]
  node_p2_utils["Chunk and shuffle utilities<br/>[utils.c]"]
  node_p2_mapper["Mapper<br/>[mapper.c]"]
  node_p2_reducer["Reducer<br/>[reducer.c]"]
end

subgraph group_p3["P3 Web Server"]
  node_p3_server["Server lifecycle<br/>[server.c]"]
  node_p3_network["Connection and response API<br/>[util.h]"]
  node_p3_dispatch["Request dispatch<br/>[server.c]"]
  node_p3_queue["Request queue<br/>[server.c]"]
  node_p3_worker["Request worker<br/>[server.c]"]
  node_p3_cache[("File cache<br/>[server.c]")]
end

subgraph group_p4["P4 Web Server"]
  node_p4_server["Server lifecycle<br/>[server.c]"]
  node_p4_network["Connection and response API<br/>[util.h]"]
  node_p4_dispatch["Request dispatch<br/>[server.c]"]
  node_p4_queue["Request queue<br/>[server.c]"]
  node_p4_worker["Request worker<br/>[server.c]"]
  node_p4_cache[("File cache<br/>[server.c]")]
  node_p4_disk["Static files<br/>[server.c]"]
  node_p4_log["Request log<br/>[server.c]"]
end

node_input["Input file"]
node_client(("HTTP client"))

node_p1_mapper -->|"gets chunks and words"| node_p1_utils
node_p1_orchestrator -.->|"starts mapper"| node_p1_mapper
node_p1_orchestrator -.->|"coordinates shuffle"| node_p1_utils
node_p1_orchestrator -.->|"starts reducer"| node_p1_reducer
node_p2_mapper -->|"gets chunks and words"| node_p2_utils
node_p2_orchestrator -.->|"starts mapper"| node_p2_mapper
node_p2_orchestrator -.->|"coordinates shuffle"| node_p2_utils
node_p2_orchestrator -.->|"starts reducer"| node_p2_reducer
node_client -.->|"connects and requests"| node_p3_network
node_p3_server -.->|"initializes listener"| node_p3_network
node_p3_dispatch -->|"accepts and parses"| node_p3_network
node_p3_dispatch -->|"enqueues request"| node_p3_queue
node_p3_worker -->|"dequeues request"| node_p3_queue
node_p3_worker -->|"checks and updates"| node_p3_cache
node_p3_worker -->|"returns result or error"| node_p3_network
node_client -.->|"connects and requests"| node_p4_network
node_p4_server -.->|"initializes listener"| node_p4_network
node_p4_dispatch -->|"accepts and parses"| node_p4_network
node_p4_dispatch -.->|"enqueues request"| node_p4_queue
node_p4_worker -->|"dequeues request"| node_p4_queue
node_p4_worker -->|"checks and updates"| node_p4_cache
node_p4_worker -->|"reads on cache miss"| node_p4_disk
node_p4_worker -->|"writes request record"| node_p4_log
node_p4_worker -->|"returns result or error"| node_p4_network
node_p4_server -->|"initializes and deletes"| node_p4_cache

click node_p1_orchestrator "https://github.com/rosstheross/csci4061-projects/blob/master/P1/src/mapreduce.c"
click node_p1_utils "https://github.com/rosstheross/csci4061-projects/blob/master/P1/include/utils.h"
click node_p1_mapper "https://github.com/rosstheross/csci4061-projects/blob/master/P1/src/mapper.c"
click node_p1_reducer "https://github.com/rosstheross/csci4061-projects/blob/master/P1/src/reducer.c"
click node_p2_orchestrator "https://github.com/rosstheross/csci4061-projects/blob/master/P2/src/mapreduce.c"
click node_p2_utils "https://github.com/rosstheross/csci4061-projects/blob/master/P2/lib/utils.c"
click node_p2_mapper "https://github.com/rosstheross/csci4061-projects/blob/master/P2/src/mapper.c"
click node_p2_reducer "https://github.com/rosstheross/csci4061-projects/blob/master/P2/src/reducer.c"
click node_p3_server "https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c"
click node_p3_network "https://github.com/rosstheross/csci4061-projects/blob/master/P3/util.h"
click node_p3_dispatch "https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c"
click node_p3_queue "https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c"
click node_p3_worker "https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c"
click node_p3_cache "https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c"
click node_p4_server "https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c"
click node_p4_network "https://github.com/rosstheross/csci4061-projects/blob/master/P4/util.h"
click node_p4_dispatch "https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c"
click node_p4_queue "https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c"
click node_p4_worker "https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c"
click node_p4_cache "https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c"
click node_p4_disk "https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c"
click node_p4_log "https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.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_p1_orchestrator,node_p1_utils,node_p1_mapper,node_p1_reducer,node_client toneBlue
class node_p2_orchestrator,node_p2_utils,node_p2_mapper,node_p2_reducer toneAmber
class node_p3_server,node_p3_network,node_p3_dispatch,node_p3_queue,node_p3_worker,node_p3_cache toneMint
class node_p4_server,node_p4_network,node_p4_dispatch,node_p4_queue,node_p4_worker,node_p4_cache,node_p4_disk,node_p4_log toneRose
class node_input toneIndigo
```

## Components

### P1 MapReduce

- [Job orchestration](https://github.com/rosstheross/csci4061-projects/blob/master/P1/src/mapreduce.c): `P1/src/mapreduce.c`
- [Chunk and shuffle utilities](https://github.com/rosstheross/csci4061-projects/blob/master/P1/include/utils.h): `P1/include/utils.h`
- [Mapper](https://github.com/rosstheross/csci4061-projects/blob/master/P1/src/mapper.c): `P1/src/mapper.c`
- [Reducer](https://github.com/rosstheross/csci4061-projects/blob/master/P1/src/reducer.c): `P1/src/reducer.c`

### P2 MapReduce

- [Job orchestration](https://github.com/rosstheross/csci4061-projects/blob/master/P2/src/mapreduce.c): `P2/src/mapreduce.c`
- [Chunk and shuffle utilities](https://github.com/rosstheross/csci4061-projects/blob/master/P2/lib/utils.c): `P2/lib/utils.c`
- [Mapper](https://github.com/rosstheross/csci4061-projects/blob/master/P2/src/mapper.c): `P2/src/mapper.c`
- [Reducer](https://github.com/rosstheross/csci4061-projects/blob/master/P2/src/reducer.c): `P2/src/reducer.c`

### P3 Web Server

- [Server lifecycle](https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c): `P3/server.c`
- [Connection and response API](https://github.com/rosstheross/csci4061-projects/blob/master/P3/util.h): `P3/util.h`
- [Request dispatch](https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c): `P3/server.c`
- [Request queue](https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c): `P3/server.c`
- [Request worker](https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c): `P3/server.c`
- [File cache](https://github.com/rosstheross/csci4061-projects/blob/master/P3/server.c): `P3/server.c`

### P4 Web Server

- [Server lifecycle](https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c): `P4/server.c`
- [Connection and response API](https://github.com/rosstheross/csci4061-projects/blob/master/P4/util.h): `P4/util.h`
- [Request dispatch](https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c): `P4/server.c`
- [Request queue](https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c): `P4/server.c`
- [Request worker](https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c): `P4/server.c`
- [File cache](https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c): `P4/server.c`
- [Static files](https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c): `P4/server.c`
- [Request log](https://github.com/rosstheross/csci4061-projects/blob/master/P4/server.c): `P4/server.c`

### Other components

- **Input file**
- **HTTP client**

## Connections

- Mapper → Chunk and shuffle utilities: gets chunks and words (evidence: `P1/src/mapper.c`)
- Job orchestration → Mapper: starts mapper
- Job orchestration → Chunk and shuffle utilities: coordinates shuffle
- Job orchestration → Reducer: starts reducer
- Mapper → Chunk and shuffle utilities: gets chunks and words (evidence: `P2/src/mapper.c`)
- Job orchestration → Mapper: starts mapper
- Job orchestration → Chunk and shuffle utilities: coordinates shuffle
- Job orchestration → Reducer: starts reducer
- HTTP client → Connection and response API: connects and requests
- Server lifecycle → Connection and response API: initializes listener (evidence: `P3/server.c`)
- Request dispatch → Connection and response API: accepts and parses (evidence: `P3/server.c`)
- Request dispatch → Request queue: enqueues request (evidence: `P3/server.c`)
- Request worker → Request queue: dequeues request (evidence: `P3/server.c`)
- Request worker → File cache: checks and updates (evidence: `P3/server.c`)
- Request worker → Connection and response API: returns result or error (evidence: `P3/server.c`)
- HTTP client → Connection and response API: connects and requests
- Server lifecycle → Connection and response API: initializes listener (evidence: `P4/server.c`)
- Request dispatch → Connection and response API: accepts and parses (evidence: `P4/server.c`)
- Request dispatch → Request queue: enqueues request (evidence: `P4/server.c`)
- Request worker → Request queue: dequeues request (evidence: `P4/server.c`)
- Request worker → File cache: checks and updates (evidence: `P4/server.c`)
- Request worker → Static files: reads on cache miss (evidence: `P4/server.c`)
- Request worker → Request log: writes request record (evidence: `P4/server.c`)
- Request worker → Connection and response API: returns result or error (evidence: `P4/server.c`)
- Server lifecycle → File cache: initializes and deletes (evidence: `P4/server.c`)
