# muhammadtalha-prog/local-multi-agent-code-generator architecture

> Architecture diagram of the GitHub repository muhammadtalha-prog/local-multi-agent-code-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/muhammadtalha-prog/local-multi-agent-code-generator
- Repository: https://github.com/muhammadtalha-prog/local-multi-agent-code-generator

## Overview

#### Purpose and entry point
This is a local-first CLI that converts a natural-language request into one generated, self-contained Python script. `main.py` is the executable entry point: it accepts interactive input or `--prompt`, selects a model/output path, and chooses standard versus fast orchestration.

#### Supervisor and pipeline control
`main.py` acts as the supervisor, sequencing agents, handling retry/review iterations, reporting progress, and persisting the final source file. Standard mode flows through interpretation, planning, generation, review, then static validation; `--fast` bypasses interpretation and planning for direct generation plus checking.
- `main.py`
- `config.py`

#### Prompt interpretation
The Interpreter converts an underspecified user request into a clearer technical specification suitable for downstream agents. This separates ambiguous user-facing input from the structured implementation context consumed by the Planner and Generator.
- `agents/interpreter.py`
- `agents/__init__.py`

#### Planning boundary
The Planner transforms the expanded specification into a stepwise implementation plan. Its output is an intermediate design artifact rather than executable code, enabling the Generator to operate from explicit requirements. Fast mode deliberately omits this stage.
- `agents/planner.py`
- `agents/interpreter.py`

#### Code generation and revision loop
The Generator produces Python source from the task context and plan. In standard mode, it participates in a bounded, multi-turn feedback loop with the Reviewer: review findings are returned with accumulated prior conversation so each revision addresses the complete history, not only the newest critique.
- `agents/generator.py`
- `agents/reviewer.py`
- `main.py`

#### Validation and output safety boundary
Generated source is statically inspected before being accepted: syntax is validated and imports/dependencies are identified. The system can optionally install missing packages, but does not execute generated code in a sandbox; runtime behavior remains outside the repository’s validation boundary.
- `agents/syntax_checker.py`
- `agents/static_checker.py`
- `main.py`

#### Runtime and external service
The application is a Python CLI running locally. LLM inference is delegated to a locally running Ollama service, accessed through a centralized client layer; the default intended model is a small local coder model. Configuration centralizes model/runtime defaults, while logging supports terminal-visible agent progress and diagnostics.
- `utils/llm_client.py`
- `config.py`
- `utils/logger.py`

Main entry points: [`main.py`](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/main.py) (CLI supervisor), [`agents/generator.py`](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/generator.py) (Generator), [`utils/llm_client.py`](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/utils/llm_client.py) (LLM client), [`agents/interpreter.py`](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/interpreter.py) (Interpreter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI Control"]
  node_user(("User request<br/>input"))
  node_main["CLI supervisor<br/>python entry point<br/>[main.py]"]
  node_output["Generated Python script<br/>output artifact"]
end

subgraph group_agents["Agent Pipeline"]
  node_interpreter["Interpreter<br/>agent<br/>[interpreter.py]"]
  node_planner["Planner<br/>agent<br/>[planner.py]"]
  node_generator["Generator<br/>agent<br/>[generator.py]"]
  node_reviewer["Reviewer<br/>agent<br/>[reviewer.py]"]
end

subgraph group_validation["Static Validation"]
  node_syntax_checker["Syntax checker<br/>agent<br/>[syntax_checker.py]"]
  node_static_checker["Static checker<br/>agent<br/>[static_checker.py]"]
end

subgraph group_runtime["Local Runtime"]
  node_config["Runtime configuration<br/>python module<br/>[config.py]"]
  node_logger["Progress logging<br/>python module<br/>[logger.py]"]
  node_llm_client["LLM client<br/>python client<br/>[llm_client.py]"]
  node_ollama{{"Ollama service<br/>local LLM service"}}
end

node_user -->|"interactive input or --prompt"| node_main
node_config -->|"defaults"| node_main
node_main -->|"progress and diagnostics"| node_logger
node_main -->|"standard mode"| node_interpreter
node_interpreter -->|"technical specification"| node_planner
node_planner -->|"implementation plan"| node_generator
node_main -.->|"fast mode: direct request"| node_generator
node_generator -->|"generated source"| node_reviewer
node_reviewer -->|"accumulated review feedback"| node_generator
node_generator -->|"candidate source"| node_syntax_checker
node_syntax_checker -->|"syntax-valid source"| node_static_checker
node_static_checker -->|"validation result and dependencies"| node_main
node_main -->|"persist accepted source"| node_output
node_interpreter -->|"inference"| node_llm_client
node_planner -->|"inference"| node_llm_client
node_generator -->|"inference"| node_llm_client
node_reviewer -->|"inference"| node_llm_client
node_config -->|"model defaults"| node_llm_client
node_llm_client -->|"local model requests"| node_ollama

click node_main "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/main.py"
click node_config "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/config.py"
click node_logger "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/utils/logger.py"
click node_llm_client "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/utils/llm_client.py"
click node_interpreter "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/interpreter.py"
click node_planner "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/planner.py"
click node_generator "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/generator.py"
click node_reviewer "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/reviewer.py"
click node_syntax_checker "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/syntax_checker.py"
click node_static_checker "https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/static_checker.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_user,node_main,node_output toneBlue
class node_interpreter,node_planner,node_generator,node_reviewer toneAmber
class node_syntax_checker,node_static_checker toneMint
class node_config,node_logger,node_llm_client,node_ollama toneRose
```

## Components

### CLI Control

Local orchestration and output handling.

- **User request**: input
- [CLI supervisor](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/main.py): python entry point · Selects standard or fast orchestration and persists accepted source. · `main.py`
- **Generated Python script**: output artifact · One self-contained source file.

### Agent Pipeline

Prompt-to-code stages.

- [Interpreter](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/interpreter.py): agent · Expands ambiguous requests into a technical specification. · `agents/interpreter.py`
- [Planner](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/planner.py): agent · Produces a stepwise implementation plan. · `agents/planner.py`
- [Generator](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/generator.py): agent · Produces and revises Python source. · `agents/generator.py`
- [Reviewer](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/reviewer.py): agent · Returns critiques for bounded revision iterations. · `agents/reviewer.py`

### Static Validation

Pre-acceptance source checks.

- [Syntax checker](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/syntax_checker.py): agent · Validates generated source syntax. · `agents/syntax_checker.py`
- [Static checker](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/agents/static_checker.py): agent · Identifies imports and dependencies. · `agents/static_checker.py`

### Local Runtime

Shared local model and diagnostics services.

- [Runtime configuration](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/config.py): python module · Centralizes model and runtime defaults. · `config.py`
- [Progress logging](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/utils/logger.py): python module · `utils/logger.py`
- [LLM client](https://github.com/muhammadtalha-prog/local-multi-agent-code-generator/blob/main/utils/llm_client.py): python client · Centralized access to local inference. · `utils/llm_client.py`
- **Ollama service**: local LLM service · Runs the selected local coder model.

## Connections

- User request → CLI supervisor: interactive input or --prompt
- Runtime configuration → CLI supervisor: defaults
- CLI supervisor → Progress logging: progress and diagnostics
- CLI supervisor → Interpreter: standard mode
- Interpreter → Planner: technical specification
- Planner → Generator: implementation plan
- CLI supervisor → Generator: fast mode: direct request
- Generator → Reviewer: generated source
- Reviewer → Generator: accumulated review feedback
- Generator → Syntax checker: candidate source
- Syntax checker → Static checker: syntax-valid source
- Static checker → CLI supervisor: validation result and dependencies
- CLI supervisor → Generated Python script: persist accepted source
- Interpreter → LLM client: inference
- Planner → LLM client: inference
- Generator → LLM client: inference
- Reviewer → LLM client: inference
- Runtime configuration → LLM client: model defaults
- LLM client → Ollama service: local model requests
