# testcraft-app/api-automation-agent architecture

> Architecture diagram of the GitHub repository testcraft-app/api-automation-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/testcraft-app/api-automation-agent
- Repository: https://github.com/testcraft-app/api-automation-agent

## Overview

API Automation Agent turns an OpenAPI/Swagger definition or Postman collection into a generated TypeScript automation framework. The main workflow is CLI configuration, source-specific parsing and endpoint modeling, then staged model/test generation with an LLM, file creation, and final checks. The README also documents endpoint selection, reuse of existing frameworks, incremental state, and Postman migration. The graph reflects sampled code and indexed references; some wiring is dependency-injected or unsampled, so uncertain links are omitted.

Main entry points: [`src/framework_generator.py`](https://github.com/testcraft-app/api-automation-agent/blob/main/src/framework_generator.py) (Generation orchestrator), [`src/processors/api_processor.py`](https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/api_processor.py) (API processing), [`main.py`](https://github.com/testcraft-app/api-automation-agent/blob/main/main.py) (Application entry), [`src/processors/postman_processor.py`](https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/postman_processor.py) (Postman migration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and configuration"]
  node_cli["CLI and configuration<br/>[cli.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_main["Application entry<br/>[main.py]"]
end

subgraph group_inputs["Definition processing"]
  node_swagger["Swagger processor"]
  node_swagger_parts["Spec preparation"]
  node_postman["Postman migration"]
  node_postman_utils["Collection utilities<br/>[postman_utils.py]"]
  node_api_processor["API processing<br/>[api_processor.py]"]
  node_api_models["Endpoint model<br/>[api_verb.py]"]
end

subgraph group_generation["Generation and state"]
  node_generator["Generation orchestrator"]
  node_llm["LLM generation<br/>[llm_service.py]"]
  node_ai_tools["File-generation tools"]
  node_file_spec["Generated file specs<br/>[file_spec.py]"]
  node_state["Incremental state"]
end

subgraph group_output["Framework output"]
  node_template["TypeScript framework<br/>[ServiceBase.ts]"]
  node_files["File operations<br/>[file_service.py]"]
  node_checks["Quality and test commands<br/>[command_service.py]"]
end

node_user(("API developer"))
node_model_provider{{"Model providers"}}

node_user -->|"runs agent"| node_main
node_main -->|"parses options"| node_cli
node_main -->|"sets options"| node_config
node_main -->|"starts generation"| node_generator
node_generator -->|"processes definition"| node_api_processor
node_api_processor -.->|"dispatches input"| node_swagger
node_api_processor -.->|"dispatches input"| node_postman
node_swagger -->|"uses spec handlers"| node_swagger_parts
node_postman -->|"uses utilities"| node_postman_utils
node_postman -->|"converts collection"| node_api_processor
node_generator -->|"requests generation"| node_llm
node_llm -->|"calls model"| node_model_provider
node_llm -->|"registers tools"| node_ai_tools
node_ai_tools -->|"creates files"| node_files
node_ai_tools -->|"accepts specifications"| node_file_spec
node_generator -->|"writes output"| node_files
node_files -->|"copies template"| node_template
node_generator -->|"persists progress"| node_state
node_generator -->|"runs final checks"| node_checks
node_checks -.->|"checks generated code"| node_template
node_api_processor -->|"builds endpoint models"| node_api_models

click node_cli "https://github.com/testcraft-app/api-automation-agent/blob/main/src/configuration/cli.py"
click node_config "https://github.com/testcraft-app/api-automation-agent/blob/main/src/configuration/config.py"
click node_main "https://github.com/testcraft-app/api-automation-agent/blob/main/main.py"
click node_swagger "https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/swagger_processor.py"
click node_swagger_parts "https://github.com/testcraft-app/api-automation-agent/tree/main/src/processors/swagger"
click node_postman "https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/postman_processor.py"
click node_postman_utils "https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/postman/postman_utils.py"
click node_api_processor "https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/api_processor.py"
click node_api_models "https://github.com/testcraft-app/api-automation-agent/blob/main/src/models/api_verb.py"
click node_generator "https://github.com/testcraft-app/api-automation-agent/blob/main/src/framework_generator.py"
click node_llm "https://github.com/testcraft-app/api-automation-agent/blob/main/src/services/llm_service.py"
click node_ai_tools "https://github.com/testcraft-app/api-automation-agent/blob/main/src/ai_tools/file_creation_tool.py"
click node_file_spec "https://github.com/testcraft-app/api-automation-agent/blob/main/src/ai_tools/models/file_spec.py"
click node_state "https://github.com/testcraft-app/api-automation-agent/blob/main/src/services/framework_state_manager.py"
click node_template "https://github.com/testcraft-app/api-automation-agent/blob/main/api-framework-template/src/base/ServiceBase.ts"
click node_files "https://github.com/testcraft-app/api-automation-agent/blob/main/src/services/file_service.py"
click node_checks "https://github.com/testcraft-app/api-automation-agent/blob/main/src/services/command_service.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_cli,node_config,node_main toneBlue
class node_swagger,node_swagger_parts,node_postman,node_postman_utils,node_api_processor,node_api_models toneAmber
class node_generator,node_llm,node_ai_tools,node_file_spec,node_state,node_user toneMint
class node_template,node_files,node_checks toneRose
class node_model_provider toneIndigo
```

## Components

### Entry and configuration

- [CLI and configuration](https://github.com/testcraft-app/api-automation-agent/blob/main/src/configuration/cli.py): `src/configuration/cli.py`
- [Runtime configuration](https://github.com/testcraft-app/api-automation-agent/blob/main/src/configuration/config.py): `src/configuration/config.py`
- [Application entry](https://github.com/testcraft-app/api-automation-agent/blob/main/main.py): `main.py`

### Definition processing

- [Swagger processor](https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/swagger_processor.py): `src/processors/swagger_processor.py`
- [Spec preparation](https://github.com/testcraft-app/api-automation-agent/tree/main/src/processors/swagger): `src/processors/swagger`
- [Postman migration](https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/postman_processor.py): `src/processors/postman_processor.py`
- [Collection utilities](https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/postman/postman_utils.py): `src/processors/postman/postman_utils.py`
- [API processing](https://github.com/testcraft-app/api-automation-agent/blob/main/src/processors/api_processor.py): `src/processors/api_processor.py`
- [Endpoint model](https://github.com/testcraft-app/api-automation-agent/blob/main/src/models/api_verb.py): `src/models/api_verb.py`

### Generation and state

- [Generation orchestrator](https://github.com/testcraft-app/api-automation-agent/blob/main/src/framework_generator.py): `src/framework_generator.py`
- [LLM generation](https://github.com/testcraft-app/api-automation-agent/blob/main/src/services/llm_service.py): `src/services/llm_service.py`
- [File-generation tools](https://github.com/testcraft-app/api-automation-agent/blob/main/src/ai_tools/file_creation_tool.py): `src/ai_tools/file_creation_tool.py`
- [Generated file specs](https://github.com/testcraft-app/api-automation-agent/blob/main/src/ai_tools/models/file_spec.py): `src/ai_tools/models/file_spec.py`
- [Incremental state](https://github.com/testcraft-app/api-automation-agent/blob/main/src/services/framework_state_manager.py): `src/services/framework_state_manager.py`

### Framework output

- [TypeScript framework](https://github.com/testcraft-app/api-automation-agent/blob/main/api-framework-template/src/base/ServiceBase.ts): `api-framework-template/src/base/ServiceBase.ts`
- [File operations](https://github.com/testcraft-app/api-automation-agent/blob/main/src/services/file_service.py): `src/services/file_service.py`
- [Quality and test commands](https://github.com/testcraft-app/api-automation-agent/blob/main/src/services/command_service.py): `src/services/command_service.py`

### Other components

- **API developer**
- **Model providers**

## Connections

- API developer → Application entry: runs agent (evidence: `README.md`)
- Application entry → CLI and configuration: parses options (evidence: `main.py`)
- Application entry → Runtime configuration: sets options (evidence: `main.py`)
- Application entry → Generation orchestrator: starts generation (evidence: `main.py`)
- Generation orchestrator → API processing: processes definition (evidence: `src/framework_generator.py`)
- API processing → Swagger processor: dispatches input (evidence: `src/processors/swagger_processor.py`)
- API processing → Postman migration: dispatches input (evidence: `src/processors/postman_processor.py`)
- Swagger processor → Spec preparation: uses spec handlers (evidence: `src/processors/swagger_processor.py`)
- Postman migration → Collection utilities: uses utilities (evidence: `src/processors/postman_processor.py`)
- Postman migration → API processing: converts collection (evidence: `src/processors/postman_processor.py`)
- Generation orchestrator → LLM generation: requests generation (evidence: `src/framework_generator.py`)
- LLM generation → Model providers: calls model (evidence: `src/services/llm_service.py`)
- LLM generation → File-generation tools: registers tools (evidence: `src/services/llm_service.py`)
- File-generation tools → File operations: creates files (evidence: `src/ai_tools/file_creation_tool.py`)
- File-generation tools → Generated file specs: accepts specifications (evidence: `src/ai_tools/file_creation_tool.py`)
- Generation orchestrator → File operations: writes output (evidence: `src/framework_generator.py`)
- File operations → TypeScript framework: copies template (evidence: `src/services/file_service.py`)
- Generation orchestrator → Incremental state: persists progress (evidence: `src/framework_generator.py`)
- Generation orchestrator → Quality and test commands: runs final checks (evidence: `src/framework_generator.py`)
- Quality and test commands → TypeScript framework: checks generated code (evidence: `README.md`)
- API processing → Endpoint model: builds endpoint models (evidence: `src/processors/api_processor.py`)
