# ngawidev/nethttp architecture

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

- Interactive diagram: https://gitdiagram.com/ngawidev/nethttp
- Repository: https://github.com/ngawidev/nethttp

## Overview

NetHttp is a fluent PHP HTTP client: callers configure a Client, build a Request, send it to an HTTP service, then consume a parsed Response. Client owns execution and cURL configuration; Request holds method, URL, headers, body, and per-request options. Separate documented branches cover concurrent/async execution and browser mimicry. README capabilities are represented, but some details (including middleware, logging, and retry internals) are based on documentation because their implementations were not sampled.

Main entry points: [`src/Client.php`](https://github.com/ngawidev/nethttp/blob/main/src/Client.php) (Client), [`src/Request.php`](https://github.com/ngawidev/nethttp/blob/main/src/Request.php) (Request builder), [`src/Promise.php`](https://github.com/ngawidev/nethttp/blob/main/src/Promise.php) (Promise), [`src/Response.php`](https://github.com/ngawidev/nethttp/blob/main/src/Response.php) (Response value)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_config["Client configuration"]
  node_client["Client<br/>[Client.php]"]
  node_browser["Browser profiles<br/>[BrowserProfile.php]"]
  node_proxy["Proxy settings<br/>[Proxy.php]"]
  node_cookies["Cookie settings<br/>[Cookie.php]"]
  node_middleware["Middleware and logs<br/>[Client.php]"]
end

subgraph group_requesting["Request and transport"]
  node_request["Request builder<br/>[Request.php]"]
  node_curl["cURL execution<br/>[Client.php]"]
  node_exception["Request errors"]
end

subgraph group_response["Response handling"]
  node_response["Response value<br/>[Response.php]"]
  node_download["File download<br/>[Client.php]"]
end

subgraph group_concurrency["Concurrent execution"]
  node_promise["Promise<br/>[Promise.php]"]
  node_pool["Promise pool<br/>[PromisePool.php]"]
  node_multi["Concurrent requests<br/>[Client.php]"]
end

node_caller(("PHP caller"))
node_http(("HTTP service"))

node_caller -->|"creates"| node_client
node_client -->|"generates profile"| node_browser
node_client -->|"configures"| node_proxy
node_client -->|"configures"| node_cookies
node_caller -->|"builds request"| node_request
node_client -->|"creates"| node_request
node_request -->|"creates async handle"| node_promise
node_request -->|"sends through"| node_client
node_client -->|"uses hooks and logs"| node_middleware
node_client -->|"executes request"| node_curl
node_curl -->|"sends HTTP"| node_http
node_http -->|"returns data"| node_curl
node_curl -->|"builds"| node_response
node_curl -->|"raises errors"| node_exception
node_curl -->|"writes response"| node_download
node_caller -->|"reads result"| node_response
node_promise -->|"awaits request"| node_client
node_promise -->|"resolves with"| node_response
node_client -->|"runs pool"| node_multi
node_multi -->|"sends concurrently"| node_http
node_multi -->|"builds results"| node_response
node_pool -->|"collects"| node_promise
node_pool -->|"executes concurrently"| node_multi
node_caller -->|"awaits async pool"| node_pool

click node_client "https://github.com/ngawidev/nethttp/blob/main/src/Client.php"
click node_browser "https://github.com/ngawidev/nethttp/blob/main/src/BrowserProfile.php"
click node_proxy "https://github.com/ngawidev/nethttp/blob/main/src/Proxy.php"
click node_cookies "https://github.com/ngawidev/nethttp/blob/main/src/Cookie.php"
click node_middleware "https://github.com/ngawidev/nethttp/blob/main/src/Client.php"
click node_request "https://github.com/ngawidev/nethttp/blob/main/src/Request.php"
click node_curl "https://github.com/ngawidev/nethttp/blob/main/src/Client.php"
click node_exception "https://github.com/ngawidev/nethttp/blob/main/src/Exception/RequestException.php"
click node_response "https://github.com/ngawidev/nethttp/blob/main/src/Response.php"
click node_download "https://github.com/ngawidev/nethttp/blob/main/src/Client.php"
click node_promise "https://github.com/ngawidev/nethttp/blob/main/src/Promise.php"
click node_pool "https://github.com/ngawidev/nethttp/blob/main/src/PromisePool.php"
click node_multi "https://github.com/ngawidev/nethttp/blob/main/src/Client.php"

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_client,node_browser,node_proxy,node_cookies,node_middleware toneBlue
class node_request,node_curl,node_exception toneAmber
class node_response,node_download toneMint
class node_promise,node_pool,node_multi toneRose
class node_caller,node_http toneIndigo
```

## Components

### Client configuration

- [Client](https://github.com/ngawidev/nethttp/blob/main/src/Client.php): `src/Client.php`
- [Browser profiles](https://github.com/ngawidev/nethttp/blob/main/src/BrowserProfile.php): `src/BrowserProfile.php`
- [Proxy settings](https://github.com/ngawidev/nethttp/blob/main/src/Proxy.php): `src/Proxy.php`
- [Cookie settings](https://github.com/ngawidev/nethttp/blob/main/src/Cookie.php): `src/Cookie.php`
- [Middleware and logs](https://github.com/ngawidev/nethttp/blob/main/src/Client.php): `src/Client.php`

### Request and transport

- [Request builder](https://github.com/ngawidev/nethttp/blob/main/src/Request.php): `src/Request.php`
- [cURL execution](https://github.com/ngawidev/nethttp/blob/main/src/Client.php): `src/Client.php`
- [Request errors](https://github.com/ngawidev/nethttp/blob/main/src/Exception/RequestException.php): `src/Exception/RequestException.php`

### Response handling

- [Response value](https://github.com/ngawidev/nethttp/blob/main/src/Response.php): `src/Response.php`
- [File download](https://github.com/ngawidev/nethttp/blob/main/src/Client.php): `src/Client.php`

### Concurrent execution

- [Promise](https://github.com/ngawidev/nethttp/blob/main/src/Promise.php): `src/Promise.php`
- [Promise pool](https://github.com/ngawidev/nethttp/blob/main/src/PromisePool.php): `src/PromisePool.php`
- [Concurrent requests](https://github.com/ngawidev/nethttp/blob/main/src/Client.php): `src/Client.php`

### Other components

- **PHP caller**
- **HTTP service**

## Connections

- PHP caller → Client: creates
- Client → Browser profiles: generates profile
- Client → Proxy settings: configures
- Client → Cookie settings: configures
- PHP caller → Request builder: builds request
- Client → Request builder: creates
- Request builder → Promise: creates async handle
- Request builder → Client: sends through
- Client → Middleware and logs: uses hooks and logs
- Client → cURL execution: executes request
- cURL execution → HTTP service: sends HTTP
- HTTP service → cURL execution: returns data
- cURL execution → Response value: builds
- cURL execution → Request errors: raises errors
- cURL execution → File download: writes response
- PHP caller → Response value: reads result
- Promise → Client: awaits request
- Promise → Response value: resolves with
- Client → Concurrent requests: runs pool
- Concurrent requests → HTTP service: sends concurrently
- Concurrent requests → Response value: builds results
- Promise pool → Promise: collects
- Promise pool → Concurrent requests: executes concurrently
- PHP caller → Promise pool: awaits async pool
