# confluentinc/confluent-kafka-dotnet architecture

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

- Interactive diagram: https://gitdiagram.com/confluentinc/confluent-kafka-dotnet
- Repository: https://github.com/confluentinc/confluent-kafka-dotnet

## Overview

This repository is Confluent’s .NET client for Kafka and Schema Registry. The central workflow serializes application data (optionally registering and validating its schema), produces it to Kafka, then consumes and deserializes it. Separate capabilities manage Kafka resources, apply Schema Registry rules, and encrypt fields using DEKs and cloud KMS providers. The core client wraps librdkafka; Schema Registry access uses a REST client. The graph follows README-documented capabilities and the supplied source excerpts; unsampled subsystem wiring is shown only where documented.

Main entry points: [`src/Confluent.Kafka/Impl/LibRdKafka.cs`](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/Impl/LibRdKafka.cs) (librdkafka interop), [`src/Confluent.Kafka/Producer.cs`](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/Producer.cs) (Producer API), [`src/Confluent.Kafka/Consumer.cs`](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/Consumer.cs) (Consumer API), [`src/Confluent.SchemaRegistry.Serdes.Json/JsonSerializer.cs`](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Serdes.Json/JsonSerializer.cs) (Format serdes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_kafka["Kafka client"]
  node_producer["Producer API<br/>[Producer.cs]"]
  node_consumer["Consumer API<br/>[Consumer.cs]"]
  node_admin["Admin API<br/>[AdminClient.cs]"]
  node_native["librdkafka interop<br/>[LibRdKafka.cs]"]
end

subgraph group_schemas["Schema Registry"]
  node_serializers["Format serdes<br/>[JsonSerializer.cs]"]
  node_deserializers["Format deserds"]
  node_registryclient["Registry client"]
  node_rest["Registry REST<br/>[RestService.cs]"]
end

subgraph group_governance["Rules and transforms"]
  node_rules["Rule execution<br/>[CelExecutor.cs]"]
  node_jsonata["JSONata rules<br/>[JsonataExecutor.cs]"]
end

subgraph group_encryption["Field encryption"]
  node_encryption["Field encryption"]
  node_dekcache[("DEK registry cache")]
  node_dekrest["DEK REST service<br/>[DekRestService.cs]"]
  node_kms["KMS providers<br/>[AwsKmsClient.cs]"]
end

subgraph group_auth["Authentication"]
  node_aws_oauth["AWS OAuth handler"]
end

node_application(("Application"))
node_broker(("Kafka cluster"))
node_registry[("Schema Registry")]
node_sts(("AWS STS"))

node_application -->|"produces with"| node_producer
node_application -->|"consumes with"| node_consumer
node_application -->|"administers"| node_admin
node_producer -->|"serializes via"| node_serializers
node_serializers -->|"registers schema"| node_registryclient
node_serializers -->|"returns bytes"| node_producer
node_producer -->|"dispatches records"| node_native
node_consumer -->|"polls records"| node_native
node_native -->|"Kafka protocol"| node_broker
node_native -->|"returns records"| node_consumer
node_consumer -->|"deserializes via"| node_deserializers
node_deserializers -->|"looks up schema"| node_registryclient
node_admin -->|"dispatches admin requests"| node_native
node_registryclient -->|"sends requests"| node_rest
node_rest -->|"REST requests"| node_registry
node_rules -.->|"supports migration rules"| node_jsonata
node_encryption -->|"resolves DEKs"| node_dekcache
node_dekcache -->|"requests DEKs"| node_dekrest
node_dekrest -->|"DEK REST requests"| node_registry
node_encryption -->|"wraps field keys"| node_kms
node_aws_oauth -->|"resolves token"| node_sts

click node_producer "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/Producer.cs"
click node_consumer "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/Consumer.cs"
click node_admin "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/AdminClient.cs"
click node_native "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/Impl/LibRdKafka.cs"
click node_serializers "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Serdes.Json/JsonSerializer.cs"
click node_deserializers "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Serdes.Json/JsonDeserializer.cs"
click node_registryclient "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry/CachedSchemaRegistryClient.cs"
click node_rest "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry/Rest/RestService.cs"
click node_rules "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Rules/CelExecutor.cs"
click node_jsonata "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Rules/JsonataExecutor.cs"
click node_encryption "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Encryption/FieldEncryptionExecutor.cs"
click node_dekcache "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Encryption/CachedDekRegistryClient.cs"
click node_dekrest "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Encryption/Rest/DekRestService.cs"
click node_kms "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Encryption.Aws/AwsKmsClient.cs"
click node_aws_oauth "https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka.OAuthBearer.Aws/Internal/AwsOAuthBearerHandler.cs"

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_producer,node_consumer,node_admin,node_native toneBlue
class node_serializers,node_deserializers,node_registryclient,node_rest,node_registry toneAmber
class node_rules,node_jsonata toneMint
class node_encryption,node_dekcache,node_dekrest,node_kms toneRose
class node_aws_oauth,node_application,node_broker,node_sts toneIndigo
```

## Components

### Kafka client

- [Producer API](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/Producer.cs): `src/Confluent.Kafka/Producer.cs`
- [Consumer API](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/Consumer.cs): `src/Confluent.Kafka/Consumer.cs`
- [Admin API](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/AdminClient.cs): `src/Confluent.Kafka/AdminClient.cs`
- [librdkafka interop](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka/Impl/LibRdKafka.cs): `src/Confluent.Kafka/Impl/LibRdKafka.cs`

### Schema Registry

- [Format serdes](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Serdes.Json/JsonSerializer.cs): `src/Confluent.SchemaRegistry.Serdes.Json/JsonSerializer.cs`
- [Format deserds](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Serdes.Json/JsonDeserializer.cs): `src/Confluent.SchemaRegistry.Serdes.Json/JsonDeserializer.cs`
- [Registry client](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry/CachedSchemaRegistryClient.cs): `src/Confluent.SchemaRegistry/CachedSchemaRegistryClient.cs`
- [Registry REST](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry/Rest/RestService.cs): `src/Confluent.SchemaRegistry/Rest/RestService.cs`

### Rules and transforms

- [Rule execution](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Rules/CelExecutor.cs): `src/Confluent.SchemaRegistry.Rules/CelExecutor.cs`
- [JSONata rules](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Rules/JsonataExecutor.cs): `src/Confluent.SchemaRegistry.Rules/JsonataExecutor.cs`

### Field encryption

- [Field encryption](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Encryption/FieldEncryptionExecutor.cs): `src/Confluent.SchemaRegistry.Encryption/FieldEncryptionExecutor.cs`
- [DEK registry cache](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Encryption/CachedDekRegistryClient.cs): `src/Confluent.SchemaRegistry.Encryption/CachedDekRegistryClient.cs`
- [DEK REST service](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Encryption/Rest/DekRestService.cs): `src/Confluent.SchemaRegistry.Encryption/Rest/DekRestService.cs`
- [KMS providers](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.SchemaRegistry.Encryption.Aws/AwsKmsClient.cs): `src/Confluent.SchemaRegistry.Encryption.Aws/AwsKmsClient.cs`

### Authentication

- [AWS OAuth handler](https://github.com/confluentinc/confluent-kafka-dotnet/blob/master/src/Confluent.Kafka.OAuthBearer.Aws/Internal/AwsOAuthBearerHandler.cs): `src/Confluent.Kafka.OAuthBearer.Aws/Internal/AwsOAuthBearerHandler.cs`

### Other components

- **Application**
- **Kafka cluster**
- **Schema Registry**
- **AWS STS**

## Connections

- Application → Producer API: produces with
- Application → Consumer API: consumes with
- Application → Admin API: administers
- Producer API → Format serdes: serializes via
- Format serdes → Registry client: registers schema
- Format serdes → Producer API: returns bytes
- Producer API → librdkafka interop: dispatches records
- Consumer API → librdkafka interop: polls records
- librdkafka interop → Kafka cluster: Kafka protocol
- librdkafka interop → Consumer API: returns records
- Consumer API → Format deserds: deserializes via
- Format deserds → Registry client: looks up schema
- Admin API → librdkafka interop: dispatches admin requests
- Registry client → Registry REST: sends requests
- Registry REST → Schema Registry: REST requests
- Rule execution → JSONata rules: supports migration rules
- Field encryption → DEK registry cache: resolves DEKs
- DEK registry cache → DEK REST service: requests DEKs
- DEK REST service → Schema Registry: DEK REST requests
- Field encryption → KMS providers: wraps field keys
- AWS OAuth handler → AWS STS: resolves token
