[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-111337":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":26,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":30,"discoverSource":31},111337,"tinytraffic","egoist\u002Ftinytraffic","egoist","self-host web analytics in a single binary","",null,"Go",243,11,59,1,0,2,7,184,6,60.74,"GNU Affero General Public License v3.0",false,"main",[],"2026-11-12 12:08:25","2026-11-23 14:12:13","# tinytraffic\n\nSimple, privacy-friendly web analytics for personal use. One binary, one\nDuckDB file, no cookies.\n\n- **Tracker**: ~1 KB gzipped. Pageviews (including SPA navigation), outbound\n  link clicks and custom events. Accepts Plausible's event format, so existing\n  Plausible integrations work.\n- **Privacy**: no cookies or storage. Visitors are identified by\n  `hash(daily salt, site, IP, user agent)`. The salt rotates at midnight in the\n  site's timezone, and the IP is never stored. Referrers keep their domain and path; query strings are\n  dropped.\n- **Dashboard**: visitors, visits, pageviews, bounce rate and visit duration\n  over time, plus sources, referrers, pages, locations, devices and goals.\n  Click any row to filter. Light and dark themes, works on phones. Make a\n  site's stats public to share its dashboard with anyone, no sign-in needed\n  (rate limited to 300 requests a minute per IP).\n- **API**: API keys for scripts and other apps. Read stats, manage sites, and\n  send events from your server. See [docs\u002Fapi.md](docs\u002Fapi.md).\n- **Stack**: Go + DuckDB backend. The dashboard is TanStack Start (SPA mode)\n  with Solid and shadcn-style components, embedded in the binary.\n\n## Quick start\n\nWith Docker:\n\n```sh\ndocker run -d --name tinytraffic -p 8080:8080 -v tinytraffic:\u002Fdata \\\n  -e TT_PASSWORD=change-me ghcr.io\u002Fegoist\u002Ftinytraffic:main\n```\n\nBehind a reverse proxy (Traefik, Caddy, nginx or Dokploy), add\n`-e TT_TRUST_PROXY=true` and drop `-p 8080:8080`, so the proxy is the only way\nin. Visitors are then located by their real IP. Without the flag, every visitor\nappears to come from the proxy and shows as \"Unknown\", and viewers of public\ndashboards share one rate limit. In Dokploy, add\n`TT_TRUST_PROXY=true` under the app's Environment tab.\n\nOr from source. You need [Go](https:\u002F\u002Fgo.dev) 1.26+, [Bun](https:\u002F\u002Fbun.sh)\n1.4+ and a C compiler (DuckDB is a C++ library, so the Go build uses cgo):\n\n```sh\nbun install                   # also fetches the GeoIP database\nbun run build                 # tracker + dashboard + bin\u002Ftinytraffic\n.\u002Fbin\u002Ftinytraffic             # http:\u002F\u002Flocalhost:8080\n```\n\nOn first visit you choose a dashboard password, unless `TT_PASSWORD` set one.\nThen add a site and paste its snippet into the site's `\u003Chead>`:\n\n```html\n\u003Cscript defer data-domain=\"example.com\" src=\"https:\u002F\u002Fstats.example.com\u002Fjs\u002Fscript.js\">\u003C\u002Fscript>\n```\n\n## Tracking\n\nCustom events show up under Goals:\n\n```js\ntinytraffic(\"Signup\", { props: { plan: \"pro\" } });\n```\n\nOutbound link clicks are tracked as `Outbound Link: Click` automatically.\n\nScript attributes:\n\n| Attribute | |\n|---|---|\n| `data-domain` | Site to record to. Defaults to the current hostname without `www.` |\n| `data-api` | Event endpoint. Defaults to the script's own origin |\n| `data-hash` | Count `#\u002Froutes` as separate pages |\n| `data-outbound=\"false\"` | Don't track outbound link clicks |\n\nIf a site moves, change its domain in the site's settings. Stats are kept,\nand the old domain keeps recording to the same site until you remove it, so\npages with the old snippet still count.\n\nVisits from localhost and automated browsers are ignored. To exclude your own\nvisits, run `localStorage.tinytraffic_ignore = \"true\"` in the console on your\nsite.\n\nTo send events from a backend instead, see\n[Sending events](docs\u002Fapi.md#sending-events) in the API docs.\n\n## Configuration\n\n| Flag | Env | Default | |\n|---|---|---|---|\n| `-addr` | `TT_ADDR` | `:8080` | Listen address |\n| `-data` | `TT_DATA_DIR` | `.\u002Fdata` | Holds `tinytraffic.duckdb` |\n| `-memory-limit` | `TT_MEMORY_LIMIT` | `1GB` | DuckDB memory cap |\n| `-clickhouse` | `TT_CLICKHOUSE_URL` | | Use ClickHouse instead of DuckDB, see [ClickHouse](#clickhouse) |\n| `-geoip` | `TT_GEOIP_DB` | see below | Comma-separated `.mmdb` files (MaxMind or DB-IP format, country or city) |\n| `-trust-proxy` | `TT_TRUST_PROXY=true` | off | Read client IPs from `CF-Connecting-IP` \u002F `X-Real-IP` \u002F `X-Forwarded-For`. Enable only behind a reverse proxy |\n| | `TT_PASSWORD` | | Sets the password on first start, so nobody else can claim the setup screen |\n\n### GeoIP\n\nLocations come from DB-IP's free city database (CC BY 4.0), installed from npm\nas [`@ip-location-db\u002Fdbip-city-mmdb`](https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002F@ip-location-db\u002Fdbip-city-mmdb).\nThe Docker image includes it, and a source build finds it in `.\u002Fnode_modules`\nwhen started from the repository. To use another database, e.g. MaxMind\nGeoLite2, put it at `DATA\u002Fgeo.mmdb` or pass `-geoip`. The Locations card shows\nthe credit line the database's license asks for.\n\nTo refresh it: `bun update @ip-location-db\u002Fdbip-city-mmdb`.\n\n### ClickHouse\n\nEverything can live in [ClickHouse](https:\u002F\u002Fclickhouse.com) instead of the\nDuckDB file: sites, settings, the password, API keys, salts and events. Use it\nfor more traffic than one DuckDB file handles comfortably, or for deploys\nwithout downtime: several tinytraffic processes can use one ClickHouse\ndatabase at once, so a new container can start before the old one stops.\n\n```sh\ntinytraffic -clickhouse clickhouse:\u002F\u002Fuser:password@host:9000\u002Ftinytraffic\n```\n\nThe URL is clickhouse-go's DSN: `clickhouse:\u002F\u002F` for the native protocol\n(port 9000) or `http:\u002F\u002F` \u002F `https:\u002F\u002F` (port 8123). Create the database first,\ne.g. `CREATE DATABASE tinytraffic`; tinytraffic creates its tables in it on\nstart. With ClickHouse, the data directory and `-memory-limit` aren't used,\nexcept to find `geo.mmdb`.\n\ntinytraffic expects a single ClickHouse server, not a cluster: its tables are\nplain `MergeTree` tables created without `ON CLUSTER`, so they aren't\nreplicated or sharded.\n\nTo move an existing install over, stop the server, copy everything, then\nstart it with the URL:\n\n```sh\ntinytraffic migrate-clickhouse -data .\u002Fdata -clickhouse clickhouse:\u002F\u002Fuser:password@host:9000\u002Ftinytraffic\ntinytraffic -clickhouse clickhouse:\u002F\u002Fuser:password@host:9000\u002Ftinytraffic\n```\n\n`migrate-clickhouse` copies sites, API keys, settings (so the password and\nsign-ins keep working), today's salt and all events. It's safe to run again:\nwhat ClickHouse already has is kept, and after an interruption it resumes\nwhere it stopped without copying an event twice. It stops with an error if a\nsite ID means a different site in ClickHouse, which happens if the server was\nstarted on the empty ClickHouse database and a site was added there first.\nNothing is removed from the DuckDB file, so you can switch back by dropping\nthe flag; changes made in ClickHouse in the meantime aren't copied back.\n\nWith Docker, run it with the image against the same volume (the image's data\ndirectory is `\u002Fdata`), then add the URL to the server container:\n\n```sh\ndocker stop tinytraffic\ndocker run --rm -v tinytraffic:\u002Fdata \\\n  -e TT_CLICKHOUSE_URL=clickhouse:\u002F\u002Fuser:password@clickhouse-host:9000\u002Ftinytraffic \\\n  ghcr.io\u002Fegoist\u002Ftinytraffic:main migrate-clickhouse\n# then start the server with -e TT_CLICKHOUSE_URL=... added to its other flags\n```\n\nThe ClickHouse host must be reachable from inside the container, so\n`localhost` won't work. If ClickHouse runs in Docker, put both containers on\none network and use its container name. If it runs on the host, use\n`host.docker.internal` (on Linux, also pass\n`--add-host=host.docker.internal:host-gateway`). In Dokploy, add\n`TT_CLICKHOUSE_URL` under the app's Environment tab. Once the server runs on\nClickHouse, the volume is no longer needed, unless you keep a custom\n`geo.mmdb` in it.\n\nWhile two processes overlap, each keeps its own visit sessions in memory, so\na visitor whose requests reach both in those seconds may be counted as two\nvisits. Sites, API keys and the password changed in one process show up in\nthe other within 10 seconds. That also means commands like `password` and\n`seed` work while the server runs.\n\n### Commands\n\nWith DuckDB, these need the server stopped, since DuckDB allows one process\nper database file. With ClickHouse, pass `-clickhouse` or set\n`TT_CLICKHOUSE_URL` so they use it:\n\n```sh\ntinytraffic password                    # set a new dashboard password\ntinytraffic seed -days 90 demo.local    # fill a site with demo traffic (-reset replaces it)\ntinytraffic migrate-clickhouse          # copy everything to ClickHouse (see above)\n```\n\nWith Docker, run them against the same volume:\n`docker run --rm -it -v tinytraffic:\u002Fdata ghcr.io\u002Fegoist\u002Ftinytraffic:main password`.\n\n## Deploying\n\nPut tinytraffic behind a TLS-terminating proxy, e.g. Caddy:\n\n```\nstats.example.com {\n  reverse_proxy localhost:8080\n}\n```\n\nand start it with `TT_TRUST_PROXY=true`, so visitors aren't all seen as the\nproxy's IP.\n\n**Docker images** are published to GHCR by `.github\u002Fworkflows\u002Fdocker.yml`, for\namd64 and arm64. Pushes to `main` publish `:main`; version tags (`v1.2.3`)\npublish `:1.2.3`, `:1.2` and `:latest`. Data lives in the `\u002Fdata` volume. To\nbuild the image yourself: `docker build -t tinytraffic .`.\n\n**Dokploy and Docker Swarm**: the database file is locked by one process at a\ntime, so the new container can't open `\u002Fdata` while the old one still runs.\nDokploy updates services start-first by default, which makes the new container\nfail with a DuckDB lock error, yet Dokploy still reports the deploy as done. In\nthe app's Swarm settings, set the Update Config and Rollback Config order to\n`stop-first`. Each deploy then has a short outage. With\n[ClickHouse](#clickhouse) there is no lock, so keep the default start-first\norder and deploys have no outage.\n\n**Backups**: stop the server and copy the data directory, or export to Parquet\nwith the DuckDB CLI:\n`duckdb data\u002Ftinytraffic.duckdb \"EXPORT DATABASE 'backup' (FORMAT parquet)\"`.\nWith ClickHouse, back up its database instead, e.g. with `BACKUP DATABASE`.\n\n## Development\n\n```sh\nbun run demo         # optional: a demo site with 90 days of fake traffic\nbun dev              # everything; open http:\u002F\u002Flocalhost:3000\nbun run test         # Go tests\nTT_TEST_CLICKHOUSE=clickhouse:\u002F\u002Flocalhost:9000 bun run test   # also against ClickHouse\nbun run typecheck\n```\n\n`bun dev` runs three processes with prefixed output:\n\n- the tracker, rebuilt on save\n- the Go server on :8080, rebuilt and restarted when a `.go` file changes,\n  using `.\u002Fdata`\n- the Vite dashboard on :3000 with hot reload, proxying `\u002Fapi` and `\u002Fjs` to\n  the Go server\n\nCtrl-C stops all three.\n\n`bun run demo` (re)creates `demo.tinytraffic.local` in `.\u002Fdata`, replacing its\nprevious stats, so it's safe to run again. Pass a domain or options with\n`bun run demo -- --days 365 --visitors 5000 my-demo.test`. Stop `bun dev`\nfirst.\n\nLayout:\n\n```\ncmd\u002Ftinytraffic      entrypoint and subcommands\ninternal\u002Fingest      \u002Fapi\u002Fevent: bot filter, UA\u002Fgeo\u002Freferrer parsing, visitor hash, sessions\ninternal\u002Fstore       sites, API keys, settings, salts and events in DuckDB or ClickHouse; batched writer; migration\ninternal\u002Fstats       dashboard queries (DuckDB and ClickHouse SQL)\ninternal\u002Fserver      HTTP routes: dashboard API, public API (\u002Fapi\u002Fv1), auth, static files\ninternal\u002Fseed        demo traffic generator\nweb\u002F                 embedded build output (dashboard + tracker)\napps\u002Fdashboard       TanStack Start + Solid SPA\npackages\u002Ftracker     tracker script\nscripts\u002F             bun dev and bun run demo\ndocs\u002Fapi.md          public API reference\n```\n\n## Performance and scaling\n\nEvents go into one append-only table. Ingest is buffered in memory and flushed\nonce a second with DuckDB's appender, so a traffic spike costs one bulk insert\nper second. Session metrics (bounce rate, duration, entry and exit pages) are\nderived from events at query time.\n\nMeasured on an Apple Silicon laptop with 25M events (about a year at ~30K\nvisitors a day), the database is 555 MB:\n\n- 30-day dashboard queries take 10–100 ms.\n- 12-month queries take 0.3–0.6 s.\n- Entry\u002Fexit pages over 12 months take ~1 s.\n\nExpect a small VPS to be a few times slower.\n\nTime buckets are computed with integer math, using UTC offsets precomputed in\nGo, instead of `date_trunc`\u002F`timezone()`. DuckDB's ICU timezone functions were\nabout 20× slower than the scan itself. A test checks the results against them\nacross DST changes.\n\nIf you outgrow one machine, move to [ClickHouse](#clickhouse). Several\ntinytraffic processes can share it, but each keeps visit sessions in memory,\nso send a visitor's requests to the same process (e.g. sticky sessions by\nIP) when running more than one for long.\n","tinytraffic 是一个轻量级、可自托管的隐私优先网页分析工具，以单二进制文件形式提供完整功能。核心功能包括无 Cookie 的页面浏览（支持 SPA）、外链点击与自定义事件追踪，采用哈希匿名化访客（基于每日盐值、站点、IP 和 User Agent），不存储原始 IP；内置响应式仪表盘，支持时间趋势、来源、设备、地理位置及目标转化分析，并提供公开共享链接与 API 集成能力。技术栈基于 Go + DuckDB 后端，前端为嵌入式 Solid SPA。适用于个人博客、小型网站或对数据主权有要求的独立开发者与团队。","2026-11-24 04:40:51","CREATED_QUERY"]