# go-kit/kit architecture

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

- Interactive diagram: https://gitdiagram.com/go-kit/kit
- Repository: https://github.com/go-kit/kit

## Overview

Go kit is a Go toolkit for building microservices and monoliths, not a standalone service. A typical RPC path adapts a business operation as an endpoint, then exposes it through a transport such as HTTP, gRPC, JSON-RPC, AMQP, NATS, or AWS Lambda. Separate packages provide discovery and load balancing, resilience and authentication, and operational instrumentation. The graph preserves these documented capability branches; only relationships visible in the supplied excerpts or source index are connected, so unsampled integrations are not inferred.

Main entry points: [`endpoint/endpoint.go`](https://github.com/go-kit/kit/blob/master/endpoint/endpoint.go) (Endpoint), [`metrics/metrics.go`](https://github.com/go-kit/kit/blob/master/metrics/metrics.go) (Metrics API), [`transport/http/server.go`](https://github.com/go-kit/kit/blob/master/transport/http/server.go) (HTTP transport), [`transport/grpc/server.go`](https://github.com/go-kit/kit/blob/master/transport/grpc/server.go) (gRPC transport)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_rpc["Endpoints and transports"]
  node_endpoint["Endpoint<br/>[endpoint.go]"]
  node_http["HTTP transport<br/>[server.go]"]
  node_grpc["gRPC transport<br/>[server.go]"]
  node_jsonrpc["JSON-RPC transport<br/>[server.go]"]
  node_amqp["AMQP transport<br/>[subscriber.go]"]
  node_nats["NATS transport<br/>[subscriber.go]"]
  node_lambda["Lambda handler<br/>[handler.go]"]
end

subgraph group_discovery["Service discovery"]
  node_discovery_api["Discovery API<br/>[instancer.go]"]
  node_consul["Consul integration<br/>[instancer.go]"]
  node_dns["DNS SRV integration<br/>[instancer.go]"]
  node_etcd["etcd integrations<br/>[instancer.go]"]
  node_etcdv3["etcd v3 integration<br/>[client.go]"]
  node_eureka["Eureka integration<br/>[instancer.go]"]
  node_zookeeper["ZooKeeper integration<br/>[client.go]"]
  node_balancing["Load balancing<br/>[balancer.go]"]
end

subgraph group_resilience["Resilience and security"]
  node_auth["Authentication middleware"]
  node_circuit["Circuit breakers"]
  node_ratelimit["Rate limiting<br/>[token_bucket.go]"]
end

subgraph group_observability["Operational instrumentation"]
  node_metrics["Metrics API<br/>[metrics.go]"]
  node_dogstatsd["DogStatsD backend<br/>[dogstatsd.go]"]
  node_influxstatsd["Influx StatsD backend<br/>[influxstatsd.go]"]
  node_metric_backends["Metrics exporters"]
  node_logging["Structured logging<br/>[log.go]"]
  node_tracing["Tracing integrations"]
  node_conn["Connection manager<br/>[manager.go]"]
end

node_caller(("Service consumer"))

node_http -->|"invokes"| node_endpoint
node_grpc -->|"invokes"| node_endpoint
node_jsonrpc -->|"uses transport"| node_http
node_amqp -->|"wraps endpoint"| node_endpoint
node_nats -->|"uses endpoint"| node_endpoint
node_lambda -->|"invokes"| node_endpoint
node_dogstatsd -->|"implements metrics"| node_metrics
node_influxstatsd -->|"implements metrics"| node_metrics
node_metric_backends -.->|"provides exporters"| node_metrics

click node_endpoint "https://github.com/go-kit/kit/blob/master/endpoint/endpoint.go"
click node_http "https://github.com/go-kit/kit/blob/master/transport/http/server.go"
click node_grpc "https://github.com/go-kit/kit/blob/master/transport/grpc/server.go"
click node_jsonrpc "https://github.com/go-kit/kit/blob/master/transport/http/jsonrpc/server.go"
click node_amqp "https://github.com/go-kit/kit/blob/master/transport/amqp/subscriber.go"
click node_nats "https://github.com/go-kit/kit/blob/master/transport/nats/subscriber.go"
click node_lambda "https://github.com/go-kit/kit/blob/master/transport/awslambda/handler.go"
click node_discovery_api "https://github.com/go-kit/kit/blob/master/sd/instancer.go"
click node_consul "https://github.com/go-kit/kit/blob/master/sd/consul/instancer.go"
click node_dns "https://github.com/go-kit/kit/blob/master/sd/dnssrv/instancer.go"
click node_etcd "https://github.com/go-kit/kit/blob/master/sd/etcd/instancer.go"
click node_etcdv3 "https://github.com/go-kit/kit/blob/master/sd/etcdv3/client.go"
click node_eureka "https://github.com/go-kit/kit/blob/master/sd/eureka/instancer.go"
click node_zookeeper "https://github.com/go-kit/kit/blob/master/sd/zk/client.go"
click node_balancing "https://github.com/go-kit/kit/blob/master/sd/lb/balancer.go"
click node_auth "https://github.com/go-kit/kit/tree/master/auth"
click node_circuit "https://github.com/go-kit/kit/tree/master/circuitbreaker"
click node_ratelimit "https://github.com/go-kit/kit/blob/master/ratelimit/token_bucket.go"
click node_metrics "https://github.com/go-kit/kit/blob/master/metrics/metrics.go"
click node_dogstatsd "https://github.com/go-kit/kit/blob/master/metrics/dogstatsd/dogstatsd.go"
click node_influxstatsd "https://github.com/go-kit/kit/blob/master/metrics/influxstatsd/influxstatsd.go"
click node_metric_backends "https://github.com/go-kit/kit/tree/master/metrics"
click node_logging "https://github.com/go-kit/kit/blob/master/log/log.go"
click node_tracing "https://github.com/go-kit/kit/tree/master/tracing"
click node_conn "https://github.com/go-kit/kit/blob/master/util/conn/manager.go"

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_endpoint,node_http,node_grpc,node_jsonrpc,node_amqp,node_nats,node_lambda toneBlue
class node_discovery_api,node_consul,node_dns,node_etcd,node_etcdv3,node_eureka,node_zookeeper,node_balancing toneAmber
class node_auth,node_circuit,node_ratelimit toneMint
class node_metrics,node_dogstatsd,node_influxstatsd,node_metric_backends,node_logging,node_tracing,node_conn toneRose
class node_caller toneIndigo
```

## Components

### Endpoints and transports

- [Endpoint](https://github.com/go-kit/kit/blob/master/endpoint/endpoint.go): `endpoint/endpoint.go`
- [HTTP transport](https://github.com/go-kit/kit/blob/master/transport/http/server.go): `transport/http/server.go`
- [gRPC transport](https://github.com/go-kit/kit/blob/master/transport/grpc/server.go): `transport/grpc/server.go`
- [JSON-RPC transport](https://github.com/go-kit/kit/blob/master/transport/http/jsonrpc/server.go): `transport/http/jsonrpc/server.go`
- [AMQP transport](https://github.com/go-kit/kit/blob/master/transport/amqp/subscriber.go): `transport/amqp/subscriber.go`
- [NATS transport](https://github.com/go-kit/kit/blob/master/transport/nats/subscriber.go): `transport/nats/subscriber.go`
- [Lambda handler](https://github.com/go-kit/kit/blob/master/transport/awslambda/handler.go): `transport/awslambda/handler.go`

### Service discovery

- [Discovery API](https://github.com/go-kit/kit/blob/master/sd/instancer.go): `sd/instancer.go`
- [Consul integration](https://github.com/go-kit/kit/blob/master/sd/consul/instancer.go): `sd/consul/instancer.go`
- [DNS SRV integration](https://github.com/go-kit/kit/blob/master/sd/dnssrv/instancer.go): `sd/dnssrv/instancer.go`
- [etcd integrations](https://github.com/go-kit/kit/blob/master/sd/etcd/instancer.go): `sd/etcd/instancer.go`
- [etcd v3 integration](https://github.com/go-kit/kit/blob/master/sd/etcdv3/client.go): `sd/etcdv3/client.go`
- [Eureka integration](https://github.com/go-kit/kit/blob/master/sd/eureka/instancer.go): `sd/eureka/instancer.go`
- [ZooKeeper integration](https://github.com/go-kit/kit/blob/master/sd/zk/client.go): `sd/zk/client.go`
- [Load balancing](https://github.com/go-kit/kit/blob/master/sd/lb/balancer.go): `sd/lb/balancer.go`

### Resilience and security

- [Authentication middleware](https://github.com/go-kit/kit/tree/master/auth): `auth`
- [Circuit breakers](https://github.com/go-kit/kit/tree/master/circuitbreaker): `circuitbreaker`
- [Rate limiting](https://github.com/go-kit/kit/blob/master/ratelimit/token_bucket.go): `ratelimit/token_bucket.go`

### Operational instrumentation

- [Metrics API](https://github.com/go-kit/kit/blob/master/metrics/metrics.go): `metrics/metrics.go`
- [DogStatsD backend](https://github.com/go-kit/kit/blob/master/metrics/dogstatsd/dogstatsd.go): `metrics/dogstatsd/dogstatsd.go`
- [Influx StatsD backend](https://github.com/go-kit/kit/blob/master/metrics/influxstatsd/influxstatsd.go): `metrics/influxstatsd/influxstatsd.go`
- [Metrics exporters](https://github.com/go-kit/kit/tree/master/metrics): `metrics`
- [Structured logging](https://github.com/go-kit/kit/blob/master/log/log.go): `log/log.go`
- [Tracing integrations](https://github.com/go-kit/kit/tree/master/tracing): `tracing`
- [Connection manager](https://github.com/go-kit/kit/blob/master/util/conn/manager.go): `util/conn/manager.go`

### Other components

- **Service consumer**

## Connections

- HTTP transport → Endpoint: invokes (evidence: `transport/http/server.go`)
- gRPC transport → Endpoint: invokes (evidence: `transport/grpc/server.go`)
- JSON-RPC transport → HTTP transport: uses transport (evidence: `transport/http/jsonrpc/server.go`)
- AMQP transport → Endpoint: wraps endpoint (evidence: `transport/amqp/subscriber.go`)
- NATS transport → Endpoint: uses endpoint (evidence: `transport/nats/subscriber.go`)
- Lambda handler → Endpoint: invokes (evidence: `transport/awslambda/handler.go`)
- DogStatsD backend → Metrics API: implements metrics (evidence: `metrics/dogstatsd/dogstatsd.go`)
- Influx StatsD backend → Metrics API: implements metrics (evidence: `metrics/influxstatsd/influxstatsd.go`)
- Metrics exporters → Metrics API: provides exporters
