# swagatamsarkar2026/openapi-playwright-agent architecture

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

- Interactive diagram: https://gitdiagram.com/swagatamsarkar2026/openapi-playwright-agent
- Repository: https://github.com/swagatamsarkar2026/openapi-playwright-agent

## Overview

OpenAPI Playwright Agent is a TypeScript CLI that turns Swagger/OpenAPI contracts into reviewable API test plans and generated Playwright tests. Its main path is analyze a spec, review and approve a plan, generate tests, run only an approved artifact against an explicitly authorized API, then summarize recorded outcomes. Optional OpenAI drafts remain non-executable proposals unless separately grounded and approved. The graph also includes spec-safety, approval metadata, audit, and reporting responsibilities. Some implementation files were not excerpted; README-documented links are identified, and uncertain links are omitted.

Main entry points: [`src/cli.ts`](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/cli.ts) (Command CLI), [`src/guided-workflow.ts`](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/guided-workflow.ts) (Guided review), [`src/openapi.ts`](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/openapi.ts) (OpenAPI analyzer), [`src/generator.ts`](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/generator.ts) (Generated tests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["CLI workflow"]
  node_cli["Command CLI<br/>[cli.ts]"]
end

subgraph group_planning["Spec planning"]
  node_spec["OpenAPI analyzer<br/>[openapi.ts]"]
  node_safety["Spec safety<br/>[spec-safety.ts]"]
  node_domain["Plan and case model<br/>[model.ts]"]
end

subgraph group_approval["Review and approval"]
  node_guided["Guided review<br/>[guided-workflow.ts]"]
  node_audit["Workflow audit<br/>[guided-workflow.ts]"]
end

subgraph group_execution["Test execution"]
  node_generator["Test generator<br/>[generator.ts]"]
  node_execution["Approval validation<br/>[execution.ts]"]
  node_playwright["Generated tests<br/>[generator.ts]"]
end

subgraph group_insights["Drafts and results"]
  node_runreport["Run reporting<br/>[run-reporter.ts]"]
  node_results["Recorded results"]
  node_summary["Run summary<br/>[run-summary.ts]"]
  node_draftworkflow["AI draft workflow<br/>[cli.ts]"]
  node_provider["Draft validation<br/>[model-provider.ts]"]
  node_openai["OpenAI provider<br/>[openai-provider.ts]"]
  node_draftreport["Draft report<br/>[ai-draft-report.ts]"]
  node_redaction["Sensitive-data redaction<br/>[redaction.ts]"]
end

node_user(("CLI user"))
node_api{{"Target API"}}

node_user -->|"invokes"| node_cli
node_cli -->|"analyzes spec"| node_spec
node_spec -->|"checks safety"| node_safety
node_spec -->|"builds plan"| node_domain
node_cli -->|"starts review"| node_guided
node_guided -->|"builds plan"| node_spec
node_guided -->|"records events"| node_audit
node_guided -->|"generates approved tests"| node_generator
node_cli -->|"writes plan"| node_generator
node_cli -->|"validates approval"| node_execution
node_cli -->|"launches tests"| node_playwright
node_playwright -->|"sends requests"| node_api
node_playwright -.->|"records outcomes"| node_runreport
node_runreport -.->|"writes results"| node_results
node_runreport -.->|"refreshes HTML report"| node_results
node_cli -->|"summarizes results"| node_summary
node_cli -->|"requests drafts"| node_draftworkflow
node_draftworkflow -->|"requests proposals"| node_openai
node_openai -->|"validates drafts"| node_provider
node_draftworkflow -->|"renders proposals"| node_draftreport
node_openai -->|"redacts inputs"| node_redaction
node_draftreport -->|"redacts report text"| node_redaction

click node_cli "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/cli.ts"
click node_spec "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/openapi.ts"
click node_safety "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/spec-safety.ts"
click node_domain "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/model.ts"
click node_guided "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/guided-workflow.ts"
click node_audit "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/guided-workflow.ts"
click node_generator "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/generator.ts"
click node_execution "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/execution.ts"
click node_playwright "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/generator.ts"
click node_runreport "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/run-reporter.ts"
click node_summary "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/run-summary.ts"
click node_draftworkflow "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/cli.ts"
click node_provider "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/model-provider.ts"
click node_openai "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/openai-provider.ts"
click node_draftreport "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/ai-draft-report.ts"
click node_redaction "https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/redaction.ts"

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_user toneBlue
class node_spec,node_safety,node_domain toneAmber
class node_guided,node_audit,node_api toneMint
class node_generator,node_execution,node_playwright toneRose
class node_runreport,node_results,node_summary,node_draftworkflow,node_provider,node_openai,node_draftreport,node_redaction toneIndigo
```

## Components

### CLI workflow

- [Command CLI](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/cli.ts): `src/cli.ts`

### Spec planning

- [OpenAPI analyzer](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/openapi.ts): `src/openapi.ts`
- [Spec safety](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/spec-safety.ts): `src/spec-safety.ts`
- [Plan and case model](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/model.ts): `src/model.ts`

### Review and approval

- [Guided review](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/guided-workflow.ts): `src/guided-workflow.ts`
- [Workflow audit](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/guided-workflow.ts): `src/guided-workflow.ts`

### Test execution

- [Test generator](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/generator.ts): `src/generator.ts`
- [Approval validation](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/execution.ts): `src/execution.ts`
- [Generated tests](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/generator.ts): `src/generator.ts`

### Drafts and results

- [Run reporting](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/run-reporter.ts): `src/run-reporter.ts`
- **Recorded results**
- [Run summary](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/run-summary.ts): `src/run-summary.ts`
- [AI draft workflow](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/cli.ts): `src/cli.ts`
- [Draft validation](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/model-provider.ts): `src/model-provider.ts`
- [OpenAI provider](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/openai-provider.ts): `src/openai-provider.ts`
- [Draft report](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/ai-draft-report.ts): `src/ai-draft-report.ts`
- [Sensitive-data redaction](https://github.com/swagatamsarkar2026/openapi-playwright-agent/blob/main/src/redaction.ts): `src/redaction.ts`

### Other components

- **CLI user**
- **Target API**

## Connections

- CLI user → Command CLI: invokes (evidence: `README.md`)
- Command CLI → OpenAPI analyzer: analyzes spec (evidence: `src/cli.ts`)
- OpenAPI analyzer → Spec safety: checks safety (evidence: `src/openapi.ts`)
- OpenAPI analyzer → Plan and case model: builds plan (evidence: `src/openapi.ts`)
- Command CLI → Guided review: starts review (evidence: `src/cli.ts`)
- Guided review → OpenAPI analyzer: builds plan (evidence: `src/guided-workflow.ts`)
- Guided review → Workflow audit: records events (evidence: `src/guided-workflow.ts`)
- Guided review → Test generator: generates approved tests (evidence: `src/guided-workflow.ts`)
- Command CLI → Test generator: writes plan (evidence: `src/cli.ts`)
- Command CLI → Approval validation: validates approval (evidence: `src/cli.ts`)
- Command CLI → Generated tests: launches tests (evidence: `src/cli.ts`)
- Generated tests → Target API: sends requests (evidence: `README.md`)
- Generated tests → Run reporting: records outcomes
- Run reporting → Recorded results: writes results
- Run reporting → Recorded results: refreshes HTML report
- Command CLI → Run summary: summarizes results (evidence: `src/cli.ts`)
- Command CLI → AI draft workflow: requests drafts (evidence: `src/cli.ts`)
- AI draft workflow → OpenAI provider: requests proposals (evidence: `src/openai-provider.ts`)
- OpenAI provider → Draft validation: validates drafts (evidence: `src/openai-provider.ts`)
- AI draft workflow → Draft report: renders proposals (evidence: `src/cli.ts`)
- OpenAI provider → Sensitive-data redaction: redacts inputs (evidence: `src/openai-provider.ts`)
- Draft report → Sensitive-data redaction: redacts report text (evidence: `src/ai-draft-report.ts`)
