# ethank1234/multi-agent-code-generation-system architecture

> Architecture diagram of the GitHub repository ethank1234/multi-agent-code-generation-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ethank1234/multi-agent-code-generation-system
- Repository: https://github.com/ethank1234/multi-agent-code-generation-system

## Overview

This repository implements an LLM-assisted algorithm-solution generation and validation loop. The principal workflow builds task-specific tests and a brute-force reference with generated inputs, generates candidate solutions, filters them with pytest, and differentially checks passing candidates against cached reference answers before selecting or revising a candidate. The excerpts show the core orchestration and model client; no README documents further capabilities.

Main entry points: [`setup.py`](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/setup.py) (Build Artifacts), [`loop.py`](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py) (Candidate Selection), [`llm.py`](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/llm.py) (LLM Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Task Setup"]
  node_setup_flow["Build Artifacts<br/>[setup.py]"]
  node_reference_gen["Reference Generator<br/>[setup.py]"]
  node_test_gen["Test Generator<br/>[setup.py]"]
  node_reference_cache[("Reference Cache<br/>[setup.py]")]
end

subgraph group_generation["Candidate Generation"]
  node_candidate_gen["Candidate Generator<br/>[loop.py]"]
end

subgraph group_validation["Validation Loop"]
  node_pytest_runner["Pytest Runner<br/>[loop.py]"]
  node_differential["Differential Checker<br/>[loop.py]"]
  node_selection["Candidate Selection<br/>[loop.py]"]
  node_iteration["Iteration Controller<br/>[loop.py]"]
end

subgraph group_model["Model Access"]
  node_llm_client["LLM Client<br/>[llm.py]"]
end

node_user(("Task Provider"))
node_gemini{{"Gemini API"}}

node_user -->|"provides task"| node_setup_flow
node_setup_flow -->|"generates reference"| node_reference_gen
node_setup_flow -->|"generates tests"| node_test_gen
node_setup_flow -->|"builds cache"| node_reference_cache
node_reference_gen -->|"requests generation"| node_llm_client
node_test_gen -->|"requests tests"| node_llm_client
node_iteration -->|"requests candidates"| node_candidate_gen
node_candidate_gen -->|"requests solution"| node_llm_client
node_iteration -->|"evaluates candidates"| node_selection
node_selection -->|"runs tests"| node_pytest_runner
node_selection -->|"checks passing candidates"| node_differential
node_differential -->|"compares answers"| node_reference_cache
node_selection -->|"returns feedback"| node_iteration
node_llm_client -->|"sends chat request"| node_gemini

click node_setup_flow "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/setup.py"
click node_reference_gen "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/setup.py"
click node_test_gen "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/setup.py"
click node_reference_cache "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/setup.py"
click node_candidate_gen "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py"
click node_pytest_runner "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py"
click node_differential "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py"
click node_selection "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py"
click node_iteration "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py"
click node_llm_client "https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/llm.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_setup_flow,node_reference_gen,node_test_gen,node_reference_cache toneBlue
class node_candidate_gen toneAmber
class node_pytest_runner,node_differential,node_selection,node_iteration,node_gemini toneMint
class node_llm_client,node_user toneRose
```

## Components

### Task Setup

- [Build Artifacts](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/setup.py): `setup.py`
- [Reference Generator](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/setup.py): `setup.py`
- [Test Generator](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/setup.py): `setup.py`
- [Reference Cache](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/setup.py): `setup.py`

### Candidate Generation

- [Candidate Generator](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py): `loop.py`

### Validation Loop

- [Pytest Runner](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py): `loop.py`
- [Differential Checker](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py): `loop.py`
- [Candidate Selection](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py): `loop.py`
- [Iteration Controller](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/loop.py): `loop.py`

### Model Access

- [LLM Client](https://github.com/ethank1234/multi-agent-code-generation-system/blob/main/llm.py): `llm.py`

### Other components

- **Task Provider**
- **Gemini API**

## Connections

- Task Provider → Build Artifacts: provides task (evidence: `setup.py`)
- Build Artifacts → Reference Generator: generates reference (evidence: `setup.py`)
- Build Artifacts → Test Generator: generates tests (evidence: `setup.py`)
- Build Artifacts → Reference Cache: builds cache (evidence: `setup.py`)
- Reference Generator → LLM Client: requests generation (evidence: `setup.py`)
- Test Generator → LLM Client: requests tests (evidence: `setup.py`)
- Iteration Controller → Candidate Generator: requests candidates (evidence: `loop.py`)
- Candidate Generator → LLM Client: requests solution (evidence: `loop.py`)
- Iteration Controller → Candidate Selection: evaluates candidates (evidence: `loop.py`)
- Candidate Selection → Pytest Runner: runs tests (evidence: `loop.py`)
- Candidate Selection → Differential Checker: checks passing candidates (evidence: `loop.py`)
- Differential Checker → Reference Cache: compares answers (evidence: `loop.py`)
- Candidate Selection → Iteration Controller: returns feedback (evidence: `loop.py`)
- LLM Client → Gemini API: sends chat request (evidence: `llm.py`)
