Architecture
The pieces of Hindsight and how an event travels from your editor to the dashboard.
Hindsight has four parts. A daemon on your computer collects events. A server keeps them and works out the time. A desktop app and a website show the result. Adapters are the small bits of glue that tell the daemon what an editor or agent is doing.
What lives where
The Rust workspace in Cargo.toml has four members. The adapters sit next to it.
| Path | What it is |
|---|---|
crates/hindsight-core |
Shared logic: the event schema, the privacy helpers, the hash chain, upload receipts, the attention rules that turn events into time, and the wire types the other crates share. |
crates/hindsight-daemon |
The hindsight-daemon binary: local API, SQLite store, presence, sync, and the connect command that hooks it into your tools. |
crates/hindsight-server |
The hindsight-server binary: HTTP API, Postgres migrations, the website dashboard, OAuth and API keys. It also serves the files in website/. |
apps/desktop |
The desktop app. Tauri (Rust) in src-tauri, SvelteKit in src. Tray icon, Byte’s popup, and the same dashboard pages as the website. |
adapters/claude-code, codex, cursor, antigravity |
A hooks.json each. The daemon merges it into the tool’s own config. |
adapters/opencode |
A TypeScript plugin that runs hindsight-daemon emit for OpenCode. |
adapters/vscode |
A TypeScript extension for VS Code, Cursor and VSCodium that reports your typing to the local API. |
adapters/zed |
A Rust extension (built by Zed for WebAssembly, outside the workspace) that starts hindsight-daemon lsp as a language server. |
The path of one event
An adapter reports something
A hook fires or an extension notices you typed. The adapter hands the daemon a small event: a kind, a time, a project name and a few counts. It never hands over text. See adding an adapter for the ways in.
The daemon checks it and stores it
Event::check_text in hindsight-core runs first. It refuses anything that carries text where text isn’t allowed. What passes goes into a SQLite file, hindsight.db, in the daemon’s data directory.
The daemon seals batches
Pending events are sealed into a batch whose hash covers the previous batch’s hash: blake3(prev_hash || canonical_json(events)). Change an old event and every hash after it breaks.
The daemon uploads
Once a minute it asks GET /api/v1/batches/head what the server already has, then sends the rest with POST /api/v1/batches. It only does this once the computer is signed in.
The server checks the chain and credits the time
The server checks that each batch links onto what it holds and that no event breaks the privacy rules. Then it works out the credited minutes itself with the same attention rules from hindsight-core. The daemon never reports totals. It does keep a local estimate for when the server isn’t reachable.
The server sends back a receipt
Each accepted upload returns a receipt: the server’s clock, signed with a key only the server has. The daemon records it as an event, so it’s sealed into the chain after everything before it. That’s how the server knows an event wasn’t back-dated: anything sealed after a receipt was recorded after the server issued it.
The dashboard draws it
The website’s pages (/today, /projects, /usage and the rest) are drawn on the server from the credited minutes. A WebSocket at /ws tells open pages when new events arrive.
The daemon
hindsight-daemon is one binary with a few jobs.
runstarts the local API on127.0.0.1:5292and the background loops: sync every 60 seconds, history, presence (which app has focus, how long you’ve been idle) and the watcher for Zed’s own agent.emit --source <name>is what agent hooks call. It reads a JSON payload on stdin, records events, prints nothing and always exits 0. A hook that crashed an agent would be worse than a missed event.connectanddisconnectadd and remove Hindsight from your tools. The installer runsconnect, and so does the desktop app every time it starts.login,sync,status,git-hook,install-git-hookandlspdo what they say.
The daemon talks to the desktop app over its local API. The app’s webview never sees the token: the Rust side of the app reads local-token from the data directory and makes the calls.
The server
hindsight-server is an axum app on Postgres. On startup it runs the migrations in crates/hindsight-server/migrations and then, in the background, redoes everyone’s stored time if the crediting rules changed (RULES_VERSION in hindsight-core, or the two windows in your settings).
Besides the daemon’s endpoints, it also serves:
- the dashboard and landing page, drawn on the server;
- Hack Club sign-in, API keys, and Hindsight as an OAuth provider;
- the Review API and signed claims, which review programs read;
- an optional pass-through to a private admin panel at
/admin.
The API page lists the parts outsiders can call.
One rule runs through all of it
Events never hold prompt text, code, file contents or file paths. The event metadata is a closed struct, so there’s no field to put them in, and unknown fields are rejected when an event is read. Text becomes a length, a typed-versus-pasted ratio or a keyed hash. The one exception is what you deliberately write to Byte. See contributing for how that shapes changes.