# bbik52/crest architecture

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

- Interactive diagram: https://gitdiagram.com/bbik52/crest
- Repository: https://github.com/bbik52/crest

## Overview

@bitrix/crest is a small PHP SDK for calling Bitrix24 REST APIs through inbound webhooks or OAuth-backed local and public applications. The main workflow is a PHP entry point invoking CRest, which loads configuration, sends REST requests, and manages authorization settings; installation and server checks are separate entry points. The README also documents batch calls and encoding support. Internal responsibilities share src/crest.php; unsampled implementation details and their connections are not expanded.

Main entry points: [`src/crest.php`](https://github.com/bbik52/crest/blob/master/src/crest.php) (CRest client), [`src/checkserver.php`](https://github.com/bbik52/crest/blob/master/src/checkserver.php) (Server check), [`src/index.php`](https://github.com/bbik52/crest/blob/master/src/index.php) (Example request), [`src/install.php`](https://github.com/bbik52/crest/blob/master/src/install.php) (App installation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["PHP entry points"]
  node_index["Example request<br/>[index.php]"]
  node_installer["App installation<br/>[install.php]"]
  node_servercheck["Server check<br/>[checkserver.php]"]
end

subgraph group_sdk["REST SDK"]
  node_crest["CRest client<br/>[crest.php]"]
  node_restcall["REST calls<br/>[crest.php]"]
  node_auth["OAuth handling<br/>[crest.php]"]
  node_batch["Batch requests<br/>[crest.php]"]
  node_encoding["Encoding conversion<br/>[crest.php]"]
  node_diagnostics["Runtime diagnostics<br/>[crest.php]"]
end

subgraph group_configuration["Configuration and state"]
  node_settings["SDK settings<br/>[settings.php]"]
  node_state[("Auth settings storage<br/>[crest.php]")]
end

node_caller(("Application caller"))
node_bitrix["Bitrix24 REST and OAuth"]

node_caller -->|"opens example"| node_index
node_index -->|"invokes client"| node_crest
node_installer -->|"invokes install"| node_crest
node_servercheck -->|"loads client"| node_crest
node_crest -->|"loads config"| node_settings
node_crest -->|"dispatches request"| node_restcall
node_restcall -->|"sends REST request"| node_bitrix
node_auth -->|"requests OAuth token"| node_bitrix
node_crest -->|"reads and writes"| node_state
node_restcall -->|"refreshes on error"| node_auth
node_crest -.->|"supports batching"| node_batch
node_restcall -.->|"converts data"| node_encoding
node_servercheck -.->|"runs checks"| node_diagnostics

click node_index "https://github.com/bbik52/crest/blob/master/src/index.php"
click node_installer "https://github.com/bbik52/crest/blob/master/src/install.php"
click node_servercheck "https://github.com/bbik52/crest/blob/master/src/checkserver.php"
click node_crest "https://github.com/bbik52/crest/blob/master/src/crest.php"
click node_restcall "https://github.com/bbik52/crest/blob/master/src/crest.php"
click node_auth "https://github.com/bbik52/crest/blob/master/src/crest.php"
click node_batch "https://github.com/bbik52/crest/blob/master/src/crest.php"
click node_encoding "https://github.com/bbik52/crest/blob/master/src/crest.php"
click node_diagnostics "https://github.com/bbik52/crest/blob/master/src/crest.php"
click node_settings "https://github.com/bbik52/crest/blob/master/src/settings.php"
click node_state "https://github.com/bbik52/crest/blob/master/src/crest.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_index,node_installer,node_servercheck toneBlue
class node_crest,node_restcall,node_auth,node_batch,node_encoding,node_diagnostics toneAmber
class node_settings,node_state toneMint
class node_caller,node_bitrix toneIndigo
```

## Components

### PHP entry points

- [Example request](https://github.com/bbik52/crest/blob/master/src/index.php): `src/index.php`
- [App installation](https://github.com/bbik52/crest/blob/master/src/install.php): `src/install.php`
- [Server check](https://github.com/bbik52/crest/blob/master/src/checkserver.php): `src/checkserver.php`

### REST SDK

- [CRest client](https://github.com/bbik52/crest/blob/master/src/crest.php): `src/crest.php`
- [REST calls](https://github.com/bbik52/crest/blob/master/src/crest.php): `src/crest.php`
- [OAuth handling](https://github.com/bbik52/crest/blob/master/src/crest.php): `src/crest.php`
- [Batch requests](https://github.com/bbik52/crest/blob/master/src/crest.php): `src/crest.php`
- [Encoding conversion](https://github.com/bbik52/crest/blob/master/src/crest.php): `src/crest.php`
- [Runtime diagnostics](https://github.com/bbik52/crest/blob/master/src/crest.php): `src/crest.php`

### Configuration and state

- [SDK settings](https://github.com/bbik52/crest/blob/master/src/settings.php): `src/settings.php`
- [Auth settings storage](https://github.com/bbik52/crest/blob/master/src/crest.php): `src/crest.php`

### Other components

- **Application caller**
- **Bitrix24 REST and OAuth**

## Connections

- Application caller → Example request: opens example (evidence: `README.md`)
- Example request → CRest client: invokes client (evidence: `src/index.php`)
- App installation → CRest client: invokes install (evidence: `src/install.php`)
- Server check → CRest client: loads client (evidence: `src/checkserver.php`)
- CRest client → SDK settings: loads config (evidence: `src/crest.php`)
- CRest client → REST calls: dispatches request (evidence: `src/crest.php`)
- REST calls → Bitrix24 REST and OAuth: sends REST request (evidence: `src/crest.php`)
- OAuth handling → Bitrix24 REST and OAuth: requests OAuth token (evidence: `src/crest.php`)
- CRest client → Auth settings storage: reads and writes (evidence: `src/crest.php`)
- REST calls → OAuth handling: refreshes on error (evidence: `src/crest.php`)
- CRest client → Batch requests: supports batching (evidence: `src/crest.php`)
- REST calls → Encoding conversion: converts data (evidence: `src/crest.php`)
- Server check → Runtime diagnostics: runs checks (evidence: `src/checkserver.php`)
