# Architecture

The services, the stores and how an event moves through them.

Ultanimus runs as a few services. This page maps them and follows an event from the browser to a chart.

## Services

| Service | What it does |
|---|---|
| Caddy | TLS and routing to the services below. |
| web | The Next.js dashboard and this site. |
| api | The Go API: accounts, sites, settings and the query engine. |
| ingest | The Go service on the hot path. It answers in under 20 ms at p99. |
| worker | Background jobs: alerts, reports, AI, retention and usage. |
| ClickHouse | Events, sessions and rollups. |
| Postgres | Users, organizations, sites, dashboards, goals, funnels, alerts and keys. |
| Valkey | The event stream, sessions, live presence, rate limits, cache and jobs. |

Ingest runs as its own process, so deploying the dashboard never drops an event.

## The path of an event

### Accept

The script sends `POST /api/e` with a plain-text body, so the browser skips the preflight request. Server code uses the [Events API](/docs/install/server) with a key.

### Check

Ingest validates the shape and size, checks the site's allowed hostnames, and applies the rate limit and the plan quota.

### Enrich

It reads the country, region and city, the user agent, the source, the channel and UTM tags, then drops bots and spam and counts them by reason.

### Identify

It builds the daily visitor ID, drops the IP address, attaches the 30-minute session and removes duplicate event IDs.

### Store

The event joins a Valkey stream and the request is answered. Flushers write the stream to ClickHouse in batches of 10,000 rows or one second. If ClickHouse is down, events wait in Valkey and retry with backoff.
