# lcobucci/kafka architecture

> Architecture diagram of the GitHub repository lcobucci/kafka, 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/lcobucci/kafka
- Repository: https://github.com/lcobucci/kafka

## Overview

This is a PHP library for Kafka protocol communication, but the shown runtime implements protocol encoding and schema handling—not a Kafka connection or request/response workflow. The visible path is callers supplying structured values to a schema, which delegates fields to typed codecs and a byte buffer. The graph covers the core protocol and its errors; it does not infer transport or other unsampled behavior.

Main entry points: [`src/Protocol/Schema.php`](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Schema.php) (Message schema), [`src/Protocol/Buffer.php`](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Buffer.php) (Byte buffer), [`src/Protocol/SchemaValidationFailure.php`](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/SchemaValidationFailure.php) (Schema validation error), [`src/Protocol/Schema/Field.php`](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Schema/Field.php) (Schema fields)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["Protocol encoding"]
  node_schema["Message schema<br/>[Schema.php]"]
  node_field["Schema fields<br/>[Field.php]"]
  node_types["Typed codecs"]
  node_buffer["Byte buffer<br/>[Buffer.php]"]
  node_base_type["Codec base type<br/>[Type.php]"]
end

subgraph group_errors["Protocol errors"]
  node_exception["Exception interface<br/>[Exception.php]"]
  node_bounds_error["Buffer errors"]
  node_range_error["Range error"]
  node_validation_error["Schema validation error"]
end

node_caller(("Library caller"))

node_schema -->|"delegates fields"| node_field
node_field -->|"uses codec"| node_base_type
node_types -->|"reads and writes"| node_buffer
node_schema -->|"reads and writes"| node_buffer
node_caller -.->|"supplies values"| node_schema
node_bounds_error -->|"implements"| node_exception
node_range_error -->|"implements"| node_exception
node_validation_error -->|"implements"| node_exception
node_buffer -->|"throws"| node_bounds_error
node_buffer -->|"throws"| node_range_error
node_schema -->|"throws"| node_validation_error
node_field -->|"throws"| node_validation_error
node_base_type -->|"throws"| node_validation_error

click node_schema "https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Schema.php"
click node_field "https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Schema/Field.php"
click node_types "https://github.com/lcobucci/kafka/tree/0.1.x/src/Protocol/Type"
click node_buffer "https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Buffer.php"
click node_base_type "https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Type.php"
click node_exception "https://github.com/lcobucci/kafka/blob/0.1.x/src/Exception.php"
click node_bounds_error "https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/NotEnoughBytesAllocated.php"
click node_range_error "https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/ValueOutOfAllowedRange.php"
click node_validation_error "https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/SchemaValidationFailure.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_schema,node_field,node_types,node_buffer,node_base_type toneBlue
class node_exception,node_bounds_error,node_range_error,node_validation_error toneAmber
class node_caller toneIndigo
```

## Components

### Protocol encoding

- [Message schema](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Schema.php): `src/Protocol/Schema.php`
- [Schema fields](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Schema/Field.php): `src/Protocol/Schema/Field.php`
- [Typed codecs](https://github.com/lcobucci/kafka/tree/0.1.x/src/Protocol/Type): `src/Protocol/Type`
- [Byte buffer](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Buffer.php): `src/Protocol/Buffer.php`
- [Codec base type](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/Type.php): `src/Protocol/Type.php`

### Protocol errors

- [Exception interface](https://github.com/lcobucci/kafka/blob/0.1.x/src/Exception.php): `src/Exception.php`
- [Buffer errors](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/NotEnoughBytesAllocated.php): `src/Protocol/NotEnoughBytesAllocated.php`
- [Range error](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/ValueOutOfAllowedRange.php): `src/Protocol/ValueOutOfAllowedRange.php`
- [Schema validation error](https://github.com/lcobucci/kafka/blob/0.1.x/src/Protocol/SchemaValidationFailure.php): `src/Protocol/SchemaValidationFailure.php`

### Other components

- **Library caller**

## Connections

- Message schema → Schema fields: delegates fields (evidence: `src/Protocol/Schema.php`)
- Schema fields → Codec base type: uses codec (evidence: `src/Protocol/Schema/Field.php`)
- Typed codecs → Byte buffer: reads and writes (evidence: `src/Protocol/Type/NullableString.php`)
- Message schema → Byte buffer: reads and writes (evidence: `src/Protocol/Schema.php`)
- Library caller → Message schema: supplies values
- Buffer errors → Exception interface: implements (evidence: `src/Protocol/NotEnoughBytesAllocated.php`)
- Range error → Exception interface: implements (evidence: `src/Protocol/ValueOutOfAllowedRange.php`)
- Schema validation error → Exception interface: implements (evidence: `src/Protocol/SchemaValidationFailure.php`)
- Byte buffer → Buffer errors: throws (evidence: `src/Protocol/Buffer.php`)
- Byte buffer → Range error: throws (evidence: `src/Protocol/Buffer.php`)
- Message schema → Schema validation error: throws (evidence: `src/Protocol/Schema.php`)
- Schema fields → Schema validation error: throws (evidence: `src/Protocol/Schema/Field.php`)
- Codec base type → Schema validation error: throws (evidence: `src/Protocol/Type.php`)
