# github/freno-client architecture

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

- Interactive diagram: https://gitdiagram.com/github/freno-client
- Repository: https://github.com/github/freno-client

## Overview

This gem provides a Faraday-backed Freno client and a higher-level write throttler. The main flow maps client operations to request types, sends HTTP requests, and turns responses into results; the throttler maps a workload context to stores, checks them through the client, retries when needed, then permits the work. README-described decorators and throttler collaborators are included. Unsampled request and instrumenter internals are represented only where documented or registered; edges without direct evidence are omitted.

Main entry points: [`lib/freno/throttler.rb`](https://github.com/github/freno-client/blob/main/lib/freno/throttler.rb) (Throttler), [`lib/freno/client.rb`](https://github.com/github/freno-client/blob/main/lib/freno/client.rb) (Client API), [`lib/freno/client/request.rb`](https://github.com/github/freno-client/blob/main/lib/freno/client/request.rb) (HTTP request base), [`lib/freno/client/requests/check.rb`](https://github.com/github/freno-client/blob/main/lib/freno/client/requests/check.rb) (Write check)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Freno client"]
  node_client_api["Client API<br/>[client.rb]"]
  node_decorators["Decorators<br/>[client.rb]"]
end

subgraph group_requests["Request and results"]
  node_check_request["Write check<br/>[check.rb]"]
  node_read_request["Read check<br/>[check_read.rb]"]
  node_delay_request["Replication delay"]
  node_request_base["HTTP request base<br/>[request.rb]"]
  node_preconditions["Preconditions<br/>[preconditions.rb]"]
  node_result["Response result<br/>[result.rb]"]
  node_client_errors["Client errors<br/>[errors.rb]"]
end

subgraph group_throttler["Throttling"]
  node_throttler["Throttler<br/>[throttler.rb]"]
  node_mapper["Store mapper<br/>[mapper.rb]"]
  node_instrumenter["Instrumenter<br/>[instrumenter.rb]"]
  node_circuit_breaker["Circuit breaker<br/>[circuit_breaker.rb]"]
  node_throttle_errors["Throttler errors<br/>[errors.rb]"]
end

node_application(("Application"))
node_faraday["Faraday HTTP client"]
node_freno_service{{"Freno service"}}
node_work["Work block"]

node_application -->|"calls"| node_client_api
node_application -->|"invokes"| node_throttler
node_client_api -->|"dispatches"| node_check_request
node_client_api -->|"dispatches"| node_read_request
node_client_api -->|"dispatches"| node_delay_request
node_client_api -->|"configures"| node_decorators
node_client_api -->|"performs"| node_request_base
node_check_request -->|"inherits"| node_request_base
node_delay_request -->|"inherits"| node_check_request
node_request_base -->|"uses"| node_preconditions
node_request_base -->|"builds"| node_result
node_request_base -->|"raises"| node_client_errors
node_request_base -->|"sends request"| node_faraday
node_faraday -->|"HTTP calls"| node_freno_service
node_throttler -->|"maps context"| node_mapper
node_throttler -->|"checks stores"| node_client_api
node_throttler -->|"emits events"| node_instrumenter
node_throttler -->|"checks circuit"| node_circuit_breaker
node_throttler -->|"raises"| node_throttle_errors
node_throttler -->|"yields work"| node_work

click node_client_api "https://github.com/github/freno-client/blob/main/lib/freno/client.rb"
click node_decorators "https://github.com/github/freno-client/blob/main/lib/freno/client.rb"
click node_check_request "https://github.com/github/freno-client/blob/main/lib/freno/client/requests/check.rb"
click node_read_request "https://github.com/github/freno-client/blob/main/lib/freno/client/requests/check_read.rb"
click node_delay_request "https://github.com/github/freno-client/blob/main/lib/freno/client/requests/replication_delay.rb"
click node_request_base "https://github.com/github/freno-client/blob/main/lib/freno/client/request.rb"
click node_preconditions "https://github.com/github/freno-client/blob/main/lib/freno/client/preconditions.rb"
click node_result "https://github.com/github/freno-client/blob/main/lib/freno/client/result.rb"
click node_client_errors "https://github.com/github/freno-client/blob/main/lib/freno/client/errors.rb"
click node_throttler "https://github.com/github/freno-client/blob/main/lib/freno/throttler.rb"
click node_mapper "https://github.com/github/freno-client/blob/main/lib/freno/throttler/mapper.rb"
click node_instrumenter "https://github.com/github/freno-client/blob/main/lib/freno/throttler/instrumenter.rb"
click node_circuit_breaker "https://github.com/github/freno-client/blob/main/lib/freno/throttler/circuit_breaker.rb"
click node_throttle_errors "https://github.com/github/freno-client/blob/main/lib/freno/throttler/errors.rb"

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_api,node_decorators,node_faraday toneBlue
class node_check_request,node_read_request,node_delay_request,node_request_base,node_preconditions,node_result,node_client_errors toneAmber
class node_throttler,node_mapper,node_instrumenter,node_circuit_breaker,node_throttle_errors toneMint
class node_application,node_freno_service,node_work toneIndigo
```

## Components

### Freno client

- [Client API](https://github.com/github/freno-client/blob/main/lib/freno/client.rb): `lib/freno/client.rb`
- [Decorators](https://github.com/github/freno-client/blob/main/lib/freno/client.rb): `lib/freno/client.rb`

### Request and results

- [Write check](https://github.com/github/freno-client/blob/main/lib/freno/client/requests/check.rb): `lib/freno/client/requests/check.rb`
- [Read check](https://github.com/github/freno-client/blob/main/lib/freno/client/requests/check_read.rb): `lib/freno/client/requests/check_read.rb`
- [Replication delay](https://github.com/github/freno-client/blob/main/lib/freno/client/requests/replication_delay.rb): `lib/freno/client/requests/replication_delay.rb`
- [HTTP request base](https://github.com/github/freno-client/blob/main/lib/freno/client/request.rb): `lib/freno/client/request.rb`
- [Preconditions](https://github.com/github/freno-client/blob/main/lib/freno/client/preconditions.rb): `lib/freno/client/preconditions.rb`
- [Response result](https://github.com/github/freno-client/blob/main/lib/freno/client/result.rb): `lib/freno/client/result.rb`
- [Client errors](https://github.com/github/freno-client/blob/main/lib/freno/client/errors.rb): `lib/freno/client/errors.rb`

### Throttling

- [Throttler](https://github.com/github/freno-client/blob/main/lib/freno/throttler.rb): `lib/freno/throttler.rb`
- [Store mapper](https://github.com/github/freno-client/blob/main/lib/freno/throttler/mapper.rb): `lib/freno/throttler/mapper.rb`
- [Instrumenter](https://github.com/github/freno-client/blob/main/lib/freno/throttler/instrumenter.rb): `lib/freno/throttler/instrumenter.rb`
- [Circuit breaker](https://github.com/github/freno-client/blob/main/lib/freno/throttler/circuit_breaker.rb): `lib/freno/throttler/circuit_breaker.rb`
- [Throttler errors](https://github.com/github/freno-client/blob/main/lib/freno/throttler/errors.rb): `lib/freno/throttler/errors.rb`

### Other components

- **Application**
- **Faraday HTTP client**
- **Freno service**
- **Work block**

## Connections

- Application → Client API: calls (evidence: `README.md`)
- Application → Throttler: invokes (evidence: `README.md`)
- Client API → Write check: dispatches (evidence: `lib/freno/client.rb`)
- Client API → Read check: dispatches (evidence: `lib/freno/client.rb`)
- Client API → Replication delay: dispatches (evidence: `lib/freno/client.rb`)
- Client API → Decorators: configures (evidence: `lib/freno/client.rb`)
- Client API → HTTP request base: performs (evidence: `lib/freno/client.rb`)
- Write check → HTTP request base: inherits (evidence: `lib/freno/client/requests/check.rb`)
- Replication delay → Write check: inherits (evidence: `lib/freno/client/requests/replication_delay.rb`)
- HTTP request base → Preconditions: uses (evidence: `lib/freno/client/request.rb`)
- HTTP request base → Response result: builds (evidence: `lib/freno/client/request.rb`)
- HTTP request base → Client errors: raises (evidence: `lib/freno/client/request.rb`)
- HTTP request base → Faraday HTTP client: sends request (evidence: `lib/freno/client/request.rb`)
- Faraday HTTP client → Freno service: HTTP calls (evidence: `README.md`)
- Throttler → Store mapper: maps context (evidence: `lib/freno/throttler.rb`)
- Throttler → Client API: checks stores (evidence: `lib/freno/throttler.rb`)
- Throttler → Instrumenter: emits events (evidence: `lib/freno/throttler.rb`)
- Throttler → Circuit breaker: checks circuit (evidence: `lib/freno/throttler.rb`)
- Throttler → Throttler errors: raises (evidence: `lib/freno/throttler.rb`)
- Throttler → Work block: yields work (evidence: `lib/freno/throttler.rb`)
