# da-francesco/apiwithplaywright architecture

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

- Interactive diagram: https://gitdiagram.com/da-francesco/apiwithplaywright
- Repository: https://github.com/da-francesco/apiwithplaywright

## Overview

This is a Playwright/TypeScript API automation framework for testing the Restful Booker API. Its main workflow is scenario tests using reusable fixtures and API clients to call the service, then checking responses with shared assertions and Zod schemas. The graph also preserves authentication, test data, environment configuration, and the documented positive, negative, and CRUD testing branches. Source excerpts show client and configuration details; several test and fixture relationships are based on the README, since those implementations were not sampled.

Main entry points: [`tests/api/booking`](https://github.com/da-francesco/apiwithplaywright/tree/main/tests/api/booking) (API scenarios), [`clients/auth.client.ts`](https://github.com/da-francesco/apiwithplaywright/blob/main/clients/auth.client.ts) (Auth client), [`clients/booking.client.ts`](https://github.com/da-francesco/apiwithplaywright/blob/main/clients/booking.client.ts) (Booking client), [`fixtures/api.fixture.ts`](https://github.com/da-francesco/apiwithplaywright/blob/main/fixtures/api.fixture.ts) (API fixture)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_scenarios["Test scenarios"]
  node_scenarios["API scenarios"]
  node_positive["Positive tests"]
  node_negative["Negative tests"]
  node_authneg["Auth-negative tests"]
  node_crud["CRUD workflow"]
end

subgraph group_runtime["API runtime"]
  node_fixture["API fixture<br/>[api.fixture.ts]"]
  node_authclient["Auth client<br/>[auth.client.ts]"]
  node_bookingclient["Booking client<br/>[booking.client.ts]"]
end

subgraph group_validation["Response validation"]
  node_schemas["Booking schemas<br/>[booking.schema.ts]"]
  node_assertions["API assertions<br/>[api.assertions.ts]"]
end

subgraph group_support["Test support"]
  node_config["Environment config<br/>[environment.ts]"]
  node_data["Booking test data<br/>[booking.data.ts]"]
  node_pwconfig["Playwright config"]
end

node_engineer(("Test author"))
node_service{{"Restful Booker API"}}

node_engineer -->|"defines scenarios"| node_scenarios
node_scenarios -->|"uses fixtures"| node_fixture
node_fixture -->|"provides client"| node_authclient
node_fixture -->|"provides client"| node_bookingclient
node_authclient -->|"reads credentials"| node_config
node_pwconfig -->|"reads settings"| node_config
node_bookingclient -->|"uses booking type"| node_data
node_authclient -->|"requests token"| node_service
node_bookingclient -->|"sends booking requests"| node_service
node_positive -->|"covers positive cases"| node_scenarios
node_negative -->|"covers invalid cases"| node_scenarios
node_authneg -->|"checks authentication"| node_authclient
node_crud -->|"runs operations"| node_bookingclient
node_scenarios -->|"validates responses"| node_schemas
node_scenarios -->|"checks responses"| node_assertions

click node_scenarios "https://github.com/da-francesco/apiwithplaywright/tree/main/tests/api/booking"
click node_positive "https://github.com/da-francesco/apiwithplaywright/tree/main/tests/api/booking"
click node_negative "https://github.com/da-francesco/apiwithplaywright/tree/main/tests/api/booking/negative"
click node_authneg "https://github.com/da-francesco/apiwithplaywright/tree/main/tests/api/booking/negative"
click node_crud "https://github.com/da-francesco/apiwithplaywright/blob/main/tests/api/booking/workflows/booking-crud.spec.ts"
click node_fixture "https://github.com/da-francesco/apiwithplaywright/blob/main/fixtures/api.fixture.ts"
click node_authclient "https://github.com/da-francesco/apiwithplaywright/blob/main/clients/auth.client.ts"
click node_bookingclient "https://github.com/da-francesco/apiwithplaywright/blob/main/clients/booking.client.ts"
click node_schemas "https://github.com/da-francesco/apiwithplaywright/blob/main/schemas/booking.schema.ts"
click node_assertions "https://github.com/da-francesco/apiwithplaywright/blob/main/utils/api.assertions.ts"
click node_config "https://github.com/da-francesco/apiwithplaywright/blob/main/config/environment.ts"
click node_data "https://github.com/da-francesco/apiwithplaywright/blob/main/data/booking.data.ts"
click node_pwconfig "https://github.com/da-francesco/apiwithplaywright/blob/main/playwright.config.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_scenarios,node_positive,node_negative,node_authneg,node_crud toneBlue
class node_fixture,node_authclient,node_bookingclient toneAmber
class node_schemas,node_assertions,node_service toneMint
class node_config,node_data,node_pwconfig toneRose
class node_engineer toneIndigo
```

## Components

### Test scenarios

- [API scenarios](https://github.com/da-francesco/apiwithplaywright/tree/main/tests/api/booking): `tests/api/booking`
- [Positive tests](https://github.com/da-francesco/apiwithplaywright/tree/main/tests/api/booking): `tests/api/booking`
- [Negative tests](https://github.com/da-francesco/apiwithplaywright/tree/main/tests/api/booking/negative): `tests/api/booking/negative`
- [Auth-negative tests](https://github.com/da-francesco/apiwithplaywright/tree/main/tests/api/booking/negative): `tests/api/booking/negative`
- [CRUD workflow](https://github.com/da-francesco/apiwithplaywright/blob/main/tests/api/booking/workflows/booking-crud.spec.ts): `tests/api/booking/workflows/booking-crud.spec.ts`

### API runtime

- [API fixture](https://github.com/da-francesco/apiwithplaywright/blob/main/fixtures/api.fixture.ts): `fixtures/api.fixture.ts`
- [Auth client](https://github.com/da-francesco/apiwithplaywright/blob/main/clients/auth.client.ts): `clients/auth.client.ts`
- [Booking client](https://github.com/da-francesco/apiwithplaywright/blob/main/clients/booking.client.ts): `clients/booking.client.ts`

### Response validation

- [Booking schemas](https://github.com/da-francesco/apiwithplaywright/blob/main/schemas/booking.schema.ts): `schemas/booking.schema.ts`
- [API assertions](https://github.com/da-francesco/apiwithplaywright/blob/main/utils/api.assertions.ts): `utils/api.assertions.ts`

### Test support

- [Environment config](https://github.com/da-francesco/apiwithplaywright/blob/main/config/environment.ts): `config/environment.ts`
- [Booking test data](https://github.com/da-francesco/apiwithplaywright/blob/main/data/booking.data.ts): `data/booking.data.ts`
- [Playwright config](https://github.com/da-francesco/apiwithplaywright/blob/main/playwright.config.ts): `playwright.config.ts`

### Other components

- **Test author**
- **Restful Booker API**

## Connections

- Test author → API scenarios: defines scenarios (evidence: `README.md`)
- API scenarios → API fixture: uses fixtures (evidence: `README.md`)
- API fixture → Auth client: provides client (evidence: `README.md`)
- API fixture → Booking client: provides client (evidence: `README.md`)
- Auth client → Environment config: reads credentials (evidence: `clients/auth.client.ts`)
- Playwright config → Environment config: reads settings (evidence: `playwright.config.ts`)
- Booking client → Booking test data: uses booking type (evidence: `clients/booking.client.ts`)
- Auth client → Restful Booker API: requests token (evidence: `clients/auth.client.ts`)
- Booking client → Restful Booker API: sends booking requests (evidence: `clients/booking.client.ts`)
- Positive tests → API scenarios: covers positive cases (evidence: `README.md`)
- Negative tests → API scenarios: covers invalid cases (evidence: `README.md`)
- Auth-negative tests → Auth client: checks authentication (evidence: `README.md`)
- CRUD workflow → Booking client: runs operations (evidence: `README.md`)
- API scenarios → Booking schemas: validates responses (evidence: `README.md`)
- API scenarios → API assertions: checks responses (evidence: `README.md`)
