# nidux/niduxrest architecture

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

- Interactive diagram: https://gitdiagram.com/nidux/niduxrest
- Repository: https://github.com/nidux/niduxrest

## Overview

NiduxRest is a lightweight, instance-based PHP HTTP client. A caller fluently configures a request, optionally prepares a body, and sends it to an external HTTP service; the client constructs a Response DTO for the result. Request configuration includes methods, headers, authentication, proxies, cookies, TLS verification, and custom cURL options. Source excerpts show the request-to-body, method, transport, and response construction relationships; README examples document the caller workflow and response capabilities.

Main entry points: [`src/Request.php`](https://github.com/nidux/niduxrest/blob/main/src/Request.php) (Fluent request), [`src/Request/Body.php`](https://github.com/nidux/niduxrest/blob/main/src/Request/Body.php) (Body preparation), [`src/Exception.php`](https://github.com/nidux/niduxrest/blob/main/src/Exception.php) (Client exception), [`src/Enum/Method.php`](https://github.com/nidux/niduxrest/blob/main/src/Enum/Method.php) (HTTP methods)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_requesting["Request building"]
  node_request["Fluent request<br/>[Request.php]"]
  node_method["HTTP methods<br/>[Method.php]"]
  node_exception["Client exception<br/>[Exception.php]"]
end

subgraph group_payloads["Payload handling"]
  node_body["Body preparation<br/>[Body.php]"]
end

subgraph group_results["Response handling"]
  node_response["Response DTO<br/>[Response.php]"]
end

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

node_caller -->|"configures"| node_request
node_request -->|"selects method"| node_method
node_request -->|"prepares body"| node_body
node_request -->|"sends cURL request"| node_api
node_request -->|"constructs response"| node_response
node_request -->|"throws on failure"| node_exception
node_body -->|"throws for missing file"| node_exception
node_request -->|"returns response"| node_caller

click node_request "https://github.com/nidux/niduxrest/blob/main/src/Request.php"
click node_method "https://github.com/nidux/niduxrest/blob/main/src/Enum/Method.php"
click node_body "https://github.com/nidux/niduxrest/blob/main/src/Request/Body.php"
click node_exception "https://github.com/nidux/niduxrest/blob/main/src/Exception.php"
click node_response "https://github.com/nidux/niduxrest/blob/main/src/Response.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_request,node_method,node_exception toneBlue
class node_body toneAmber
class node_response toneMint
class node_caller,node_api toneIndigo
```

## Components

### Request building

- [Fluent request](https://github.com/nidux/niduxrest/blob/main/src/Request.php): `src/Request.php`
- [HTTP methods](https://github.com/nidux/niduxrest/blob/main/src/Enum/Method.php): `src/Enum/Method.php`
- [Client exception](https://github.com/nidux/niduxrest/blob/main/src/Exception.php): `src/Exception.php`

### Payload handling

- [Body preparation](https://github.com/nidux/niduxrest/blob/main/src/Request/Body.php): `src/Request/Body.php`

### Response handling

- [Response DTO](https://github.com/nidux/niduxrest/blob/main/src/Response.php): `src/Response.php`

### Other components

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

## Connections

- PHP caller → Fluent request: configures (evidence: `README.md`)
- Fluent request → HTTP methods: selects method (evidence: `src/Request.php`)
- Fluent request → Body preparation: prepares body (evidence: `src/Request.php`)
- Fluent request → HTTP service: sends cURL request (evidence: `src/Request.php`)
- Fluent request → Response DTO: constructs response (evidence: `src/Request.php`)
- Fluent request → Client exception: throws on failure (evidence: `src/Request.php`)
- Body preparation → Client exception: throws for missing file (evidence: `src/Request/Body.php`)
- Fluent request → PHP caller: returns response (evidence: `README.md`)
