# handefidan/team7-distributed-agents architecture

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

- Interactive diagram: https://gitdiagram.com/handefidan/team7-distributed-agents
- Repository: https://github.com/handefidan/team7-distributed-agents

## Overview

Distributed Agents is a master/worker task-dispatch service. A caller registers a worker with the master, submits a task for a chosen worker, and receives the worker’s acknowledgement through the master; accepted work runs asynchronously on the worker, with results polled directly from that worker. The graph preserves the separate registration, dispatch, acknowledgement, execution, and result stages, plus worker health and local Ollama execution. State is in memory. Relationships are based on the shown source and README; no persistent store is present.

Main entry points: [`agent/main.py`](https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py) (Worker endpoints), [`master/main.py`](https://github.com/handefidan/team7-distributed-agents/blob/main/master/main.py) (Master endpoints), [`shared/schemas.py`](https://github.com/handefidan/team7-distributed-agents/blob/main/shared/schemas.py) (Task and dispatch schemas)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_master["Master API"]
  node_master_api["Master endpoints<br/>[main.py]"]
  node_agent_registry[("Agent registry<br/>[main.py]")]
  node_dispatch_state[("Dispatch records<br/>[main.py]")]
end

subgraph group_worker["Worker Agent"]
  node_worker_api["Worker endpoints<br/>[main.py]"]
  node_worker_queue["Task queue<br/>[main.py]"]
  node_acknowledgements[("Acknowledgements<br/>[main.py]")]
  node_task_execution["Background execution<br/>[main.py]"]
  node_task_results[("Task results<br/>[main.py]")]
  node_worker_health["Health endpoint<br/>[main.py]"]
end

subgraph group_contract["Shared Contract"]
  node_message_schemas["Task and dispatch schemas<br/>[schemas.py]"]
end

node_caller(("API caller"))
node_ollama["Ollama server"]

node_caller -->|"registers or submits"| node_master_api
node_master_api -->|"reads and writes"| node_agent_registry
node_master_api -->|"records dispatch"| node_dispatch_state
node_master_api -->|"POSTs task"| node_worker_api
node_worker_api -->|"returns acknowledgement"| node_master_api
node_master_api -->|"uses models"| node_message_schemas
node_worker_api -->|"uses models"| node_message_schemas
node_worker_api -->|"checks and stores"| node_acknowledgements
node_worker_api -->|"queues accepted task"| node_worker_queue
node_worker_api -->|"schedules task"| node_task_execution
node_task_execution -->|"requests generation"| node_ollama
node_task_execution -->|"stores outcome"| node_task_results
node_worker_api -->|"serves polled result"| node_task_results
node_caller -->|"polls result"| node_worker_api
node_worker_api -->|"reports queue status"| node_worker_queue
node_caller -.->|"checks health"| node_worker_health

click node_master_api "https://github.com/handefidan/team7-distributed-agents/blob/main/master/main.py"
click node_agent_registry "https://github.com/handefidan/team7-distributed-agents/blob/main/master/main.py"
click node_dispatch_state "https://github.com/handefidan/team7-distributed-agents/blob/main/master/main.py"
click node_worker_api "https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py"
click node_worker_queue "https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py"
click node_acknowledgements "https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py"
click node_task_execution "https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py"
click node_task_results "https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py"
click node_worker_health "https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py"
click node_message_schemas "https://github.com/handefidan/team7-distributed-agents/blob/main/shared/schemas.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_master_api,node_agent_registry,node_dispatch_state toneBlue
class node_worker_api,node_worker_queue,node_acknowledgements,node_task_execution,node_task_results,node_worker_health toneAmber
class node_message_schemas,node_caller,node_ollama toneMint
```

## Components

### Master API

- [Master endpoints](https://github.com/handefidan/team7-distributed-agents/blob/main/master/main.py): `master/main.py`
- [Agent registry](https://github.com/handefidan/team7-distributed-agents/blob/main/master/main.py): `master/main.py`
- [Dispatch records](https://github.com/handefidan/team7-distributed-agents/blob/main/master/main.py): `master/main.py`

### Worker Agent

- [Worker endpoints](https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py): `agent/main.py`
- [Task queue](https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py): `agent/main.py`
- [Acknowledgements](https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py): `agent/main.py`
- [Background execution](https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py): `agent/main.py`
- [Task results](https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py): `agent/main.py`
- [Health endpoint](https://github.com/handefidan/team7-distributed-agents/blob/main/agent/main.py): `agent/main.py`

### Shared Contract

- [Task and dispatch schemas](https://github.com/handefidan/team7-distributed-agents/blob/main/shared/schemas.py): `shared/schemas.py`

### Other components

- **API caller**
- **Ollama server**

## Connections

- API caller → Master endpoints: registers or submits (evidence: `README.md`)
- Master endpoints → Agent registry: reads and writes (evidence: `master/main.py`)
- Master endpoints → Dispatch records: records dispatch (evidence: `master/main.py`)
- Master endpoints → Worker endpoints: POSTs task (evidence: `master/main.py`)
- Worker endpoints → Master endpoints: returns acknowledgement (evidence: `master/main.py`)
- Master endpoints → Task and dispatch schemas: uses models (evidence: `master/main.py`)
- Worker endpoints → Task and dispatch schemas: uses models (evidence: `agent/main.py`)
- Worker endpoints → Acknowledgements: checks and stores (evidence: `agent/main.py`)
- Worker endpoints → Task queue: queues accepted task (evidence: `agent/main.py`)
- Worker endpoints → Background execution: schedules task (evidence: `agent/main.py`)
- Background execution → Ollama server: requests generation (evidence: `agent/main.py`)
- Background execution → Task results: stores outcome (evidence: `agent/main.py`)
- Worker endpoints → Task results: serves polled result (evidence: `agent/main.py`)
- API caller → Worker endpoints: polls result (evidence: `README.md`)
- Worker endpoints → Task queue: reports queue status (evidence: `agent/main.py`)
- API caller → Health endpoint: checks health
