# bpaulraj/api-tests-generator architecture

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

- Interactive diagram: https://gitdiagram.com/bpaulraj/api-tests-generator
- Repository: https://github.com/bpaulraj/api-tests-generator

## Overview

Apigen is a portable AI-agent framework for REST API test automation. Its workflow analyzes a target test repository, normalizes an API contract, measures test coverage, plans missing tests or journey scenarios, and—after human approval—generates and verifies tests in the repository’s conventions. The README documents these stages and artifacts; sampled source confirms the repo scanner and spec normalizer share common utilities. Several tool implementations were not sampled, so their internal calls are shown only where the README documents them.

Main entry points: [`AGENTS.md`](https://github.com/bpaulraj/api-tests-generator/blob/master/AGENTS.md) (Workflow orchestrator), [`framework/agents/test-writer.md`](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/test-writer.md) (Test writer), [`framework/agents/journey-composer.md`](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/journey-composer.md) (Journey composer), [`framework/tools/repo_scan.py`](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/repo_scan.py) (Repo scan and inventory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Agent workflow"]
  node_orchestrator["Workflow orchestrator<br/>[AGENTS.md]"]
  node_repo_analyst["Repository analyst<br/>[repo-analyst.md]"]
  node_spec_ingestor["Spec ingestor<br/>[spec-ingestor.md]"]
  node_coverage_analyst["Coverage analyst"]
  node_scenario_designer["Scenario designer"]
  node_journey_composer["Journey composer"]
  node_test_writer["Test writer<br/>[test-writer.md]"]
  node_verifier["Test verifier<br/>[verifier.md]"]
end

subgraph group_tools["Deterministic tools"]
  node_cli["CLI and mode entry<br/>[apigen.py]"]
  node_repo_scan["Repo scan and inventory<br/>[repo_scan.py]"]
  node_spec_normalize["Contract normalization<br/>[spec_normalize.py]"]
  node_common["Shared matching and IO<br/>[common.py]"]
  node_coverage_tool["Coverage calculation<br/>[coverage.py]"]
  node_journey_tool["Journey validation<br/>[journeys.py]"]
  node_plan_tool["Plan candidates<br/>[plan.py]"]
end

subgraph group_artifacts["Models and outputs"]
  node_schemas["Versioned artifact schemas"]
  node_outputs["Profiles, reports, plans"]
  node_generated_tests["Generated test code"]
end

subgraph group_guides["Stack and journey guidance"]
  node_adapters["Stack adapters"]
  node_journey_format["Journey templates"]
end

node_agent(("Agent runtime"))
node_target["Target test repo"]
node_contract["API contract"]
node_journey_input["Journey mapping"]

node_agent -->|"invokes modes"| node_orchestrator
node_orchestrator -->|"runs tools"| node_cli
node_target -->|"provides conventions"| node_repo_analyst
node_repo_analyst -->|"scans repository"| node_repo_scan
node_contract -->|"provides API spec"| node_spec_ingestor
node_spec_ingestor -->|"normalizes contract"| node_spec_normalize
node_journey_input -->|"provides mapping"| node_journey_composer
node_journey_composer -->|"validates journeys"| node_journey_tool
node_repo_scan -->|"uses helpers"| node_common
node_spec_normalize -->|"uses helpers"| node_common
node_repo_analyst -->|"writes repo profile"| node_outputs
node_spec_ingestor -->|"writes API model"| node_outputs
node_repo_scan -->|"produces inventory"| node_outputs
node_coverage_analyst -->|"enriches inventory"| node_repo_scan
node_coverage_analyst -->|"calculates coverage"| node_coverage_tool
node_coverage_tool -->|"writes coverage report"| node_outputs
node_scenario_designer -->|"builds candidates"| node_plan_tool
node_scenario_designer -->|"produces test plan"| node_outputs
node_journey_composer -->|"designs scenarios"| node_outputs
node_test_writer -->|"uses stack guidance"| node_adapters
node_test_writer -->|"imitates repo style"| node_target
node_test_writer -->|"writes tests"| node_generated_tests
node_verifier -->|"compiles and runs"| node_generated_tests
node_verifier -->|"reruns coverage"| node_coverage_tool
node_schemas -->|"defines artifact formats"| node_outputs
node_journey_format -->|"guides mappings"| node_journey_composer
node_orchestrator -->|"coordinates analysis"| node_coverage_analyst
node_orchestrator -->|"coordinates planning"| node_scenario_designer
node_orchestrator -->|"starts after approval"| node_test_writer
node_orchestrator -->|"coordinates verification"| node_verifier

click node_orchestrator "https://github.com/bpaulraj/api-tests-generator/blob/master/AGENTS.md"
click node_repo_analyst "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/repo-analyst.md"
click node_spec_ingestor "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/spec-ingestor.md"
click node_coverage_analyst "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/coverage-analyst.md"
click node_scenario_designer "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/scenario-designer.md"
click node_journey_composer "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/journey-composer.md"
click node_test_writer "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/test-writer.md"
click node_verifier "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/verifier.md"
click node_cli "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/apigen.py"
click node_repo_scan "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/repo_scan.py"
click node_spec_normalize "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/spec_normalize.py"
click node_common "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/common.py"
click node_coverage_tool "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/coverage.py"
click node_journey_tool "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/journeys.py"
click node_plan_tool "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/plan.py"
click node_schemas "https://github.com/bpaulraj/api-tests-generator/tree/master/framework/schemas"
click node_adapters "https://github.com/bpaulraj/api-tests-generator/tree/master/framework/adapters"
click node_journey_format "https://github.com/bpaulraj/api-tests-generator/blob/master/framework/templates/journeys.template.yaml"

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_orchestrator,node_repo_analyst,node_spec_ingestor,node_coverage_analyst,node_scenario_designer,node_journey_composer,node_test_writer,node_verifier toneBlue
class node_cli,node_repo_scan,node_spec_normalize,node_common,node_coverage_tool,node_journey_tool,node_plan_tool toneAmber
class node_schemas,node_outputs,node_generated_tests,node_contract toneMint
class node_adapters,node_journey_format toneRose
class node_agent,node_target,node_journey_input toneIndigo
```

## Components

### Agent workflow

- [Workflow orchestrator](https://github.com/bpaulraj/api-tests-generator/blob/master/AGENTS.md): `AGENTS.md`
- [Repository analyst](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/repo-analyst.md): `framework/agents/repo-analyst.md`
- [Spec ingestor](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/spec-ingestor.md): `framework/agents/spec-ingestor.md`
- [Coverage analyst](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/coverage-analyst.md): `framework/agents/coverage-analyst.md`
- [Scenario designer](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/scenario-designer.md): `framework/agents/scenario-designer.md`
- [Journey composer](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/journey-composer.md): `framework/agents/journey-composer.md`
- [Test writer](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/test-writer.md): `framework/agents/test-writer.md`
- [Test verifier](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/agents/verifier.md): `framework/agents/verifier.md`

### Deterministic tools

- [CLI and mode entry](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/apigen.py): `framework/tools/apigen.py`
- [Repo scan and inventory](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/repo_scan.py): `framework/tools/repo_scan.py`
- [Contract normalization](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/spec_normalize.py): `framework/tools/spec_normalize.py`
- [Shared matching and IO](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/common.py): `framework/tools/common.py`
- [Coverage calculation](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/coverage.py): `framework/tools/coverage.py`
- [Journey validation](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/journeys.py): `framework/tools/journeys.py`
- [Plan candidates](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/tools/plan.py): `framework/tools/plan.py`

### Models and outputs

- [Versioned artifact schemas](https://github.com/bpaulraj/api-tests-generator/tree/master/framework/schemas): `framework/schemas`
- **Profiles, reports, plans**
- **Generated test code**

### Stack and journey guidance

- [Stack adapters](https://github.com/bpaulraj/api-tests-generator/tree/master/framework/adapters): `framework/adapters`
- [Journey templates](https://github.com/bpaulraj/api-tests-generator/blob/master/framework/templates/journeys.template.yaml): `framework/templates/journeys.template.yaml`

### Other components

- **Agent runtime**
- **Target test repo**
- **API contract**
- **Journey mapping**

## Connections

- Agent runtime → Workflow orchestrator: invokes modes (evidence: `README.md`)
- Workflow orchestrator → CLI and mode entry: runs tools (evidence: `README.md`)
- Target test repo → Repository analyst: provides conventions (evidence: `README.md`)
- Repository analyst → Repo scan and inventory: scans repository (evidence: `README.md`)
- API contract → Spec ingestor: provides API spec (evidence: `README.md`)
- Spec ingestor → Contract normalization: normalizes contract (evidence: `README.md`)
- Journey mapping → Journey composer: provides mapping (evidence: `README.md`)
- Journey composer → Journey validation: validates journeys (evidence: `README.md`)
- Repo scan and inventory → Shared matching and IO: uses helpers (evidence: `framework/tools/repo_scan.py`)
- Contract normalization → Shared matching and IO: uses helpers (evidence: `framework/tools/spec_normalize.py`)
- Repository analyst → Profiles, reports, plans: writes repo profile (evidence: `README.md`)
- Spec ingestor → Profiles, reports, plans: writes API model (evidence: `README.md`)
- Repo scan and inventory → Profiles, reports, plans: produces inventory (evidence: `README.md`)
- Coverage analyst → Repo scan and inventory: enriches inventory (evidence: `README.md`)
- Coverage analyst → Coverage calculation: calculates coverage (evidence: `README.md`)
- Coverage calculation → Profiles, reports, plans: writes coverage report (evidence: `README.md`)
- Scenario designer → Plan candidates: builds candidates (evidence: `README.md`)
- Scenario designer → Profiles, reports, plans: produces test plan (evidence: `README.md`)
- Journey composer → Profiles, reports, plans: designs scenarios (evidence: `README.md`)
- Test writer → Stack adapters: uses stack guidance (evidence: `README.md`)
- Test writer → Target test repo: imitates repo style (evidence: `README.md`)
- Test writer → Generated test code: writes tests (evidence: `README.md`)
- Test verifier → Generated test code: compiles and runs (evidence: `README.md`)
- Test verifier → Coverage calculation: reruns coverage (evidence: `README.md`)
- Versioned artifact schemas → Profiles, reports, plans: defines artifact formats (evidence: `README.md`)
- Journey templates → Journey composer: guides mappings (evidence: `README.md`)
- Workflow orchestrator → Coverage analyst: coordinates analysis (evidence: `README.md`)
- Workflow orchestrator → Scenario designer: coordinates planning (evidence: `README.md`)
- Workflow orchestrator → Test writer: starts after approval (evidence: `README.md`)
- Workflow orchestrator → Test verifier: coordinates verification (evidence: `README.md`)
