# andrewfoxfox/distributedsystems-lab1 architecture

> Architecture diagram of the GitHub repository andrewfoxfox/distributedsystems-lab1, 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/andrewfoxfox/distributedsystems-lab1
- Repository: https://github.com/andrewfoxfox/distributedsystems-lab1

## Overview

This repository is a distributed-systems lab example: Part 1 demonstrates durable RabbitMQ work delivery and acknowledgements; Part 2 extends it to an asynchronous text-processing API with persistent status, AI generation, retries, and dead-lettering. The harness is test infrastructure and is omitted. The README content and several source excerpts are unavailable, so the graph shows only relationships supported by the supplied tree and source.

Main entry points: [`part2_producer.py`](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part2_producer.py) (Processing API), [`part2_consumer.py`](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part2_consumer.py) (AI worker), [`common.py`](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/common.py) (Queue setup), [`part1_producer.py`](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part1_producer.py) (Batch producer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_part1["Part 1 Messaging"]
  node_part1producer["Batch producer<br/>[part1_producer.py]"]
  node_part1consumer["Worker consumer<br/>[part1_consumer.py]"]
end

subgraph group_part2["Part 2 Service"]
  node_api["Processing API<br/>[part2_producer.py]"]
  node_store[("Result store<br/>[part2_store.py]")]
  node_worker["AI worker<br/>[part2_consumer.py]"]
end

subgraph group_infra["Messaging Infrastructure"]
  node_common["Queue setup<br/>[common.py]"]
  node_broker["RabbitMQ"]
end

node_sender(("Message sender"))
node_apiuser(("API client"))
node_ai["Ollama API"]

node_sender -->|"starts batch"| node_part1producer
node_part1producer -->|"connects and sets up"| node_common
node_common -->|"declares queues"| node_broker
node_part1producer -->|"publishes jobs"| node_broker
node_broker -->|"delivers jobs"| node_part1consumer
node_part1consumer -->|"acknowledges"| node_broker
node_apiuser -->|"submits text"| node_api
node_api -->|"records processing"| node_store
node_api -->|"connects and sets up"| node_common
node_api -->|"publishes job"| node_broker
node_api -->|"reads result"| node_store
node_api -->|"returns status"| node_apiuser
node_broker -->|"delivers job"| node_worker
node_worker -->|"generates response"| node_ai
node_worker -->|"records outcome"| node_store
node_worker -->|"acks or retries"| node_broker
node_common -->|"configures dead lettering"| node_broker

click node_part1producer "https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part1_producer.py"
click node_part1consumer "https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part1_consumer.py"
click node_api "https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part2_producer.py"
click node_store "https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part2_store.py"
click node_worker "https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part2_consumer.py"
click node_common "https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/common.py"

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_part1producer,node_part1consumer,node_apiuser toneBlue
class node_api,node_store,node_worker toneAmber
class node_common,node_broker,node_ai toneMint
class node_sender toneIndigo
```

## Components

### Part 1 Messaging

- [Batch producer](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part1_producer.py): `part1_producer.py`
- [Worker consumer](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part1_consumer.py): `part1_consumer.py`

### Part 2 Service

- [Processing API](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part2_producer.py): `part2_producer.py`
- [Result store](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part2_store.py): `part2_store.py`
- [AI worker](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/part2_consumer.py): `part2_consumer.py`

### Messaging Infrastructure

- [Queue setup](https://github.com/andrewfoxfox/distributedsystems-lab1/blob/main/common.py): `common.py`
- **RabbitMQ**

### Other components

- **Message sender**
- **API client**
- **Ollama API**

## Connections

- Message sender → Batch producer: starts batch
- Batch producer → Queue setup: connects and sets up
- Queue setup → RabbitMQ: declares queues
- Batch producer → RabbitMQ: publishes jobs
- RabbitMQ → Worker consumer: delivers jobs
- Worker consumer → RabbitMQ: acknowledges
- API client → Processing API: submits text
- Processing API → Result store: records processing
- Processing API → Queue setup: connects and sets up
- Processing API → RabbitMQ: publishes job
- Processing API → Result store: reads result
- Processing API → API client: returns status
- RabbitMQ → AI worker: delivers job
- AI worker → Ollama API: generates response
- AI worker → Result store: records outcome
- AI worker → RabbitMQ: acks or retries
- Queue setup → RabbitMQ: configures dead lettering
