Architecture & Traffic Model
Why quarkd runs in ~6 MiB of RAM, how it separates humans from AI crawlers without cookies, and where its boundaries are.
Why three traffic buckets?
JS-only analytics tools miss AI crawlers and 15–40% of ad-blocked browsers. Raw server-log analyzers swing the other way and inflate "visitors" with scrapers, uptime probes, and cloud bots.
Because quarkd can observe both Nginx/Caddy logs and an 813-byte first-party beacon, it separates every request into three explicit buckets:
- Browser-verified (Pageviews, Visitors, Sessions): Confirmed by
/_q.js(or/q.js). When a server log hit and a browser beacon arrive for the same visitor and path withindedup_window_secs(default 10s), they merge into onehybridview instead of double-counting. - Verified AI crawlers & AI referrals: Requests claiming to be
GPTBot,OAI-SearchBot,ChatGPT-User,ClaudeBot,PerplexityBot, orPerplexity-Userare checked against 454+ daily-synced official IP CIDRs. Matches are markedverified; mismatched IPs are flagged as spoofed. Human clicks arriving from ChatGPT, Perplexity, or Claude are tracked separately as AI referrals. - Server requests: Unverified HTTP requests that never fired a browser beacon, split into
unverifiedvs.automatedusing the offline DB-IP ASN datacenter list.
Privacy by architecture
- Zero cookies, zero localStorage: Unique visitors are computed using a SHA-256 hash of
(daily_salt, site_id, client_ip, user_agent). The salt rotates automatically at UTC midnight and is never persisted to disk. - Raw IPs stay on your web server: In First-Party Agent mode (
Vector #4), the agent hashes visitor IPs locally using the hub's daily salt and resolves GeoIP/ASN locally before shipping zstd-compressed batches. Raw visitor IPs never cross the wire to the hub.
Why server.toml stays read-only
Operational tools that rewrite their own config files break gitops and leave half-edited files on disk. quarkd splits ownership cleanly: boot, bind, and auth tokens live in read-only server.toml, while Day-2 catalog changes (sites, goals, webhooks) persist atomically in WAL SQLite and hot-reload in memory.
Known limitations & edge cases
Every architecture makes trade-offs. Here are ours, stated plainly:
- Single-node SQLite write ceiling: WAL SQLite comfortably handles tens of millions of monthly events on a single small VPS, but
quarkdis intentionally not a distributed cluster database. If you need petabyte-scale multi-region sharding, ClickHouse is the right tool. - Free GeoIP accuracy: Auto-updating DB-IP City Lite is accurate at country level and solid at metro/city level, but less granular than paid commercial MaxMind GeoIP2 Enterprise feeds.
- Cross-midnight sessions: Because visitor salts rotate at UTC midnight for privacy, a single visitor browsing across 23:59 → 00:01 UTC counts as a fresh anonymous visitor on the new day.
- Single-player vs. multiplayer: Self-hosted
quarkd(AGPL-3.0) is designed for single-operator / developer teams sharing an admin token. Multi-tenant client portals, shareable read-only links, and team RBAC are planned for the optional Hosted Cloud offering.