# How an event gets from the SDK to a chart

Pug’s pipeline from SDK to dashboard: Connect RPC ingest, NATS and Go workers, and ClickHouse storage. Every part is open source and self-hostable under AGPL-3.0.

Source: https://pug.sh/platform

SDKs send batches to a Connect RPC endpoint, NATS queues them, Go workers write the events and resolve identity, and ClickHouse stores them for Live, Insights, and Profiles.

## How data flows

SDK: track() and identify()

API: Connect RPC ingest

NATS: Queues every event

Workers: Write events and profiles

ClickHouse: Stores the events

Dashboard: Insights and profiles

### Ingest

SDKs send events in batches to a Connect RPC endpoint, which adds location, device, and UTM properties and tags bots as $bot on arrival.

### Process

NATS hands each event to Go workers, which store it and apply identify() calls to profiles, so a traffic spike queues instead of dropping.

### Serve

Events land in ClickHouse, which Live, Insights, and Profiles query directly.

## Typed, programmatic access

Read profiles, query insights, and send events over Connect RPC, in Protobuf or JSON. The MCP server answers AI agents from the same API, so their numbers match the dashboard’s.

### Connect RPC

Typed services over HTTP, callable from any Connect or gRPC client, or with plain JSON.

### Protobuf

Schema-first payloads, binary on the wire, defined once in .proto files.

### Project keys

A public key for client SDKs and a private key for servers and reads, each scoped to one project.

- [API reference](https://docs.pug.sh/api)
- [How the MCP server works](https://pug.sh/mcp)

## Run the whole stack yourself

Pug is AGPL-3.0. Run the binary and its four stores on your own infrastructure, and events never leave it. On a small node, pug start runs the server and every worker in one process.

[Self-hosting guide](https://docs.pug.sh/self-hosting)

- pug: One Go binary: the API server and every worker
- Dragonfly or Redis 7+: The daily salt, kept off disk
- NATS JetStream: Queues every event
- ClickHouse: Every event
- PostgreSQL 15+: Accounts, boards, and profiles
