Architecture
HookLens is small on purpose. The main seams are the CLI, the HTTP server, storage, and the verifier interface.
Flow
hooklens listenbuilds a verifier from CLI flags- The server binds to
127.0.0.1 - Incoming requests are buffered into a
WebhookEvent - The event is saved to SQLite
- The verifier runs, if configured
- The terminal UI prints the result
- The request is optionally forwarded downstream
The event shape
The in-memory event contract is:
{
id: string
timestamp: string
method: string
path: string
headers: Record<string, string>
body: string
}On disk, headers are stored as a JSON string and parsed back into the event shape on read.
Storage
Storage uses the built-in node:sqlite module and writes to:
~/.hooklens/events.dbThe storage layer exposes six operations:
save(event)load(id)list(limit?)delete(id)removes a single event, returns whether it existedclear()removes all events, returns the count deletedclose()closes the SQLite handle during shutdown and cleanup
Verifier seam
The server is intentionally provider-agnostic. It receives an optional Verifier and only asks it to validate { headers, body }.
That keeps provider logic out of the transport layer and makes new providers cheap to add.
Forwarding seam
Forwarding is implemented separately from request capture and is also reused by hooklens replay.
The exported forwardEvent() helper is responsible for:
- building the trusted destination URL
- stripping forwarding headers
- applying the timeout
- returning downstream status and body
Terminal UI seam
The CLI commands call a small TerminalUI interface for output. That keeps the long-running runtime code testable without having to inspect raw stdout everywhere.