# shaneisraeln/ai-engineer architecture

> Architecture diagram of the GitHub repository shaneisraeln/ai-engineer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shaneisraeln/ai-engineer
- Repository: https://github.com/shaneisraeln/ai-engineer

## Overview

AI Software Engineer accepts a repository and issue through its API, then coordinates repository analysis, retrieval and localization, root-cause investigation, patching, and sandbox validation. Failed attempts can be retried; successful work is reviewed and reported with evidence, with pull-request creation gated by human approval. The repository also includes a neural localization training and evaluation capability. Some stages are documented but their implementation was not sampled, so those links cite the README; other relationships are limited to shown calls and SOURCE INDEX references.

Main entry points: [`agents/orchestrator.py`](https://github.com/shaneisraeln/ai-engineer/blob/master/agents/orchestrator.py) (Task Orchestrator), [`apps/api/main.py`](https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/main.py) (API Application), [`apps/api/routes/tasks.py`](https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/routes/tasks.py) (Task Routes), [`agents/autonomous_pipeline.py`](https://github.com/shaneisraeln/ai-engineer/blob/master/agents/autonomous_pipeline.py) (Autonomous Pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["API and Tasks"]
  node_api["API Application<br/>[main.py]"]
  node_repo_routes["Repository Routes<br/>[repositories.py]"]
  node_issue_routes["Issue Routes<br/>[issues.py]"]
  node_task_routes["Task Routes<br/>[tasks.py]"]
  node_eval_routes["Evaluation Routes<br/>[evaluation.py]"]
  node_task_store[("Task Records<br/>[models.py]")]
end

subgraph group_resolution["Issue Resolution"]
  node_orchestrator["Task Orchestrator<br/>[orchestrator.py]"]
  node_autonomous["Autonomous Pipeline"]
  node_agents["Specialized Agents"]
  node_llm["LLM Providers"]
end

subgraph group_repo_intel["Repository Intelligence"]
  node_compatibility["Compatibility Check<br/>[compatibility.py]"]
  node_indexer["Repository Indexer<br/>[indexer.py]"]
  node_parser["Python AST Parser<br/>[python_parser.py]"]
  node_call_graph["Call Graph<br/>[call_graph.py]"]
  node_retriever["Hybrid Retrieval"]
end

subgraph group_validation["Patch and Validation"]
  node_patching["Structured Patching"]
  node_edit_engine["Edit Engine<br/>[edit_engine.py]"]
  node_patch_schema["Patch Schema<br/>[schema.py]"]
  node_target_resolver["Target Resolver<br/>[target_resolver.py]"]
  node_sandbox["Repository Sandbox<br/>[repo_sandbox.py]"]
  node_docker["Docker Executor<br/>[docker_executor.py]"]
end

subgraph group_learning["Localization Learning"]
  node_localizer["Neural Localization"]
  node_evaluation["Evaluation Framework"]
  node_metrics["Localization Metrics"]
  node_training_data["Training Data Builder"]
end

node_engineer(("Engineer"))

node_engineer -->|"submits issue"| node_api
node_api -->|"routes requests"| node_repo_routes
node_api -->|"routes requests"| node_issue_routes
node_api -->|"routes requests"| node_task_routes
node_api -->|"routes requests"| node_eval_routes
node_api -->|"initializes database"| node_task_store
node_task_routes -->|"reads and writes"| node_task_store
node_task_routes -.->|"starts resolution"| node_orchestrator
node_orchestrator -.->|"checks compatibility"| node_compatibility
node_orchestrator -.->|"indexes repository"| node_indexer
node_orchestrator -.->|"retrieves candidates"| node_retriever
node_orchestrator -.->|"ranks candidates"| node_localizer
node_orchestrator -.->|"coordinates stages"| node_agents
node_orchestrator -->|"requests completion"| node_llm
node_autonomous -->|"builds index"| node_indexer
node_indexer -->|"parses files"| node_parser
node_retriever -->|"expands context"| node_call_graph
node_orchestrator -.->|"generates patch"| node_patching
node_patching -->|"uses schema"| node_patch_schema
node_autonomous -->|"applies edit"| node_edit_engine
node_edit_engine -->|"accepts plan"| node_patch_schema
node_edit_engine -->|"resolves targets"| node_target_resolver
node_orchestrator -.->|"validates patch"| node_sandbox
node_autonomous -->|"runs validation"| node_docker
node_sandbox -->|"executes tests"| node_docker
node_orchestrator -.->|"reports results"| node_evaluation
node_evaluation -.->|"computes metrics"| node_metrics
node_training_data -.->|"trains model"| node_localizer
node_task_routes -.->|"returns evidence"| node_engineer
node_engineer -->|"approves PR"| node_task_routes

click node_api "https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/main.py"
click node_repo_routes "https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/routes/repositories.py"
click node_issue_routes "https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/routes/issues.py"
click node_task_routes "https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/routes/tasks.py"
click node_eval_routes "https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/routes/evaluation.py"
click node_task_store "https://github.com/shaneisraeln/ai-engineer/blob/master/database/models.py"
click node_orchestrator "https://github.com/shaneisraeln/ai-engineer/blob/master/agents/orchestrator.py"
click node_autonomous "https://github.com/shaneisraeln/ai-engineer/blob/master/agents/autonomous_pipeline.py"
click node_agents "https://github.com/shaneisraeln/ai-engineer/tree/master/agents"
click node_llm "https://github.com/shaneisraeln/ai-engineer/tree/master/core/llm"
click node_compatibility "https://github.com/shaneisraeln/ai-engineer/blob/master/repository/compatibility.py"
click node_indexer "https://github.com/shaneisraeln/ai-engineer/blob/master/repository/indexer.py"
click node_parser "https://github.com/shaneisraeln/ai-engineer/blob/master/repository/parsers/python_parser.py"
click node_call_graph "https://github.com/shaneisraeln/ai-engineer/blob/master/repository/graph/call_graph.py"
click node_retriever "https://github.com/shaneisraeln/ai-engineer/blob/master/repository/retrieval/hybrid_retriever.py"
click node_localizer "https://github.com/shaneisraeln/ai-engineer/blob/master/ml/models/bug_localization.py"
click node_patching "https://github.com/shaneisraeln/ai-engineer/blob/master/agents/coder/structured_coder.py"
click node_edit_engine "https://github.com/shaneisraeln/ai-engineer/blob/master/patch/edit_engine.py"
click node_patch_schema "https://github.com/shaneisraeln/ai-engineer/blob/master/patch/schema.py"
click node_target_resolver "https://github.com/shaneisraeln/ai-engineer/blob/master/patch/target_resolver.py"
click node_sandbox "https://github.com/shaneisraeln/ai-engineer/blob/master/sandbox/repo_sandbox.py"
click node_docker "https://github.com/shaneisraeln/ai-engineer/blob/master/sandbox/executor/docker_executor.py"
click node_evaluation "https://github.com/shaneisraeln/ai-engineer/tree/master/evaluation"
click node_metrics "https://github.com/shaneisraeln/ai-engineer/blob/master/evaluation/metrics/localization_metrics.py"
click node_training_data "https://github.com/shaneisraeln/ai-engineer/blob/master/ml/preprocessing/build_training_data.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_api,node_repo_routes,node_issue_routes,node_task_routes,node_eval_routes,node_task_store toneBlue
class node_orchestrator,node_autonomous,node_agents,node_llm toneAmber
class node_compatibility,node_indexer,node_parser,node_call_graph,node_retriever toneMint
class node_patching,node_edit_engine,node_patch_schema,node_target_resolver,node_sandbox,node_docker toneRose
class node_localizer,node_evaluation,node_metrics,node_training_data,node_engineer toneIndigo
```

## Components

### API and Tasks

- [API Application](https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/main.py): `apps/api/main.py`
- [Repository Routes](https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/routes/repositories.py): `apps/api/routes/repositories.py`
- [Issue Routes](https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/routes/issues.py): `apps/api/routes/issues.py`
- [Task Routes](https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/routes/tasks.py): `apps/api/routes/tasks.py`
- [Evaluation Routes](https://github.com/shaneisraeln/ai-engineer/blob/master/apps/api/routes/evaluation.py): `apps/api/routes/evaluation.py`
- [Task Records](https://github.com/shaneisraeln/ai-engineer/blob/master/database/models.py): `database/models.py`

### Issue Resolution

- [Task Orchestrator](https://github.com/shaneisraeln/ai-engineer/blob/master/agents/orchestrator.py): `agents/orchestrator.py`
- [Autonomous Pipeline](https://github.com/shaneisraeln/ai-engineer/blob/master/agents/autonomous_pipeline.py): `agents/autonomous_pipeline.py`
- [Specialized Agents](https://github.com/shaneisraeln/ai-engineer/tree/master/agents): `agents`
- [LLM Providers](https://github.com/shaneisraeln/ai-engineer/tree/master/core/llm): `core/llm`

### Repository Intelligence

- [Compatibility Check](https://github.com/shaneisraeln/ai-engineer/blob/master/repository/compatibility.py): `repository/compatibility.py`
- [Repository Indexer](https://github.com/shaneisraeln/ai-engineer/blob/master/repository/indexer.py): `repository/indexer.py`
- [Python AST Parser](https://github.com/shaneisraeln/ai-engineer/blob/master/repository/parsers/python_parser.py): `repository/parsers/python_parser.py`
- [Call Graph](https://github.com/shaneisraeln/ai-engineer/blob/master/repository/graph/call_graph.py): `repository/graph/call_graph.py`
- [Hybrid Retrieval](https://github.com/shaneisraeln/ai-engineer/blob/master/repository/retrieval/hybrid_retriever.py): `repository/retrieval/hybrid_retriever.py`

### Patch and Validation

- [Structured Patching](https://github.com/shaneisraeln/ai-engineer/blob/master/agents/coder/structured_coder.py): `agents/coder/structured_coder.py`
- [Edit Engine](https://github.com/shaneisraeln/ai-engineer/blob/master/patch/edit_engine.py): `patch/edit_engine.py`
- [Patch Schema](https://github.com/shaneisraeln/ai-engineer/blob/master/patch/schema.py): `patch/schema.py`
- [Target Resolver](https://github.com/shaneisraeln/ai-engineer/blob/master/patch/target_resolver.py): `patch/target_resolver.py`
- [Repository Sandbox](https://github.com/shaneisraeln/ai-engineer/blob/master/sandbox/repo_sandbox.py): `sandbox/repo_sandbox.py`
- [Docker Executor](https://github.com/shaneisraeln/ai-engineer/blob/master/sandbox/executor/docker_executor.py): `sandbox/executor/docker_executor.py`

### Localization Learning

- [Neural Localization](https://github.com/shaneisraeln/ai-engineer/blob/master/ml/models/bug_localization.py): `ml/models/bug_localization.py`
- [Evaluation Framework](https://github.com/shaneisraeln/ai-engineer/tree/master/evaluation): `evaluation`
- [Localization Metrics](https://github.com/shaneisraeln/ai-engineer/blob/master/evaluation/metrics/localization_metrics.py): `evaluation/metrics/localization_metrics.py`
- [Training Data Builder](https://github.com/shaneisraeln/ai-engineer/blob/master/ml/preprocessing/build_training_data.py): `ml/preprocessing/build_training_data.py`

### Other components

- **Engineer**

## Connections

- Engineer → API Application: submits issue
- API Application → Repository Routes: routes requests (evidence: `apps/api/main.py`)
- API Application → Issue Routes: routes requests (evidence: `apps/api/main.py`)
- API Application → Task Routes: routes requests (evidence: `apps/api/main.py`)
- API Application → Evaluation Routes: routes requests (evidence: `apps/api/main.py`)
- API Application → Task Records: initializes database (evidence: `apps/api/main.py`)
- Task Routes → Task Records: reads and writes (evidence: `apps/api/routes/tasks.py`)
- Task Routes → Task Orchestrator: starts resolution
- Task Orchestrator → Compatibility Check: checks compatibility
- Task Orchestrator → Repository Indexer: indexes repository
- Task Orchestrator → Hybrid Retrieval: retrieves candidates
- Task Orchestrator → Neural Localization: ranks candidates
- Task Orchestrator → Specialized Agents: coordinates stages (evidence: `agents/orchestrator.py`)
- Task Orchestrator → LLM Providers: requests completion (evidence: `agents/orchestrator.py`)
- Autonomous Pipeline → Repository Indexer: builds index (evidence: `agents/autonomous_pipeline.py`)
- Repository Indexer → Python AST Parser: parses files (evidence: `repository/indexer.py`)
- Hybrid Retrieval → Call Graph: expands context (evidence: `repository/retrieval/hybrid_retriever.py`)
- Task Orchestrator → Structured Patching: generates patch
- Structured Patching → Patch Schema: uses schema (evidence: `agents/coder/structured_coder.py`)
- Autonomous Pipeline → Edit Engine: applies edit (evidence: `agents/autonomous_pipeline.py`)
- Edit Engine → Patch Schema: accepts plan (evidence: `patch/edit_engine.py`)
- Edit Engine → Target Resolver: resolves targets (evidence: `patch/edit_engine.py`)
- Task Orchestrator → Repository Sandbox: validates patch
- Autonomous Pipeline → Docker Executor: runs validation (evidence: `agents/autonomous_pipeline.py`)
- Repository Sandbox → Docker Executor: executes tests (evidence: `sandbox/repo_sandbox.py`)
- Task Orchestrator → Evaluation Framework: reports results
- Evaluation Framework → Localization Metrics: computes metrics (evidence: `evaluation/runners/retrieval_evaluation.py`)
- Training Data Builder → Neural Localization: trains model
- Task Routes → Engineer: returns evidence
- Engineer → Task Routes: approves PR (evidence: `apps/api/routes/tasks.py`)
