Project

bun-packrat

active

Self-hosted web archive that stores Chromium MHTML in SQLite and derives safe offline reading and export views.

Overview

bun-packrat is a self-hosted archive for rendered web pages, designed as a compact successor to a large ArchiveBox deployment. Each fresh capture stores canonical Chromium MHTML in SQLite alongside its metadata, tags, job history and FTS5 search index.

Full-page HTML, simplified articles, Markdown, EPUB and PDF are derived from the stored snapshot when requested instead of being retained as duplicate files. The service runs on Bun with no external queue, database or search daemon.

How it works

Capture requests arrive through the server-rendered web interface, HTTP API, bookmarklet or Bun CLI. The server normalises each URL, applies SSRF checks and records a job in SQLite. An in-process worker opens an isolated Chromium context through Playwright, applies a bounded readiness wait, materialises lazy content and stores the resulting MHTML, SHA-256 hash and derived Readability metadata in one transaction.

Reader routes decode the canonical snapshot into sanitised standalone HTML with captured resources embedded locally. Full-page and Article views use a restrictive Content Security Policy and make no external requests. FTS5 supplies search and filtering, while the same stored capture can produce Markdown ZIP, EPUB 3 and PDF exports on demand.

Features
🗄️
Single-database archive

Captures, canonical MHTML, metadata, tags, queue state and search indexes live in one SQLite database that supports consistent online backup and integrity verification.

🌐
Browser-based capture

Playwright drives Chromium to render pages, dismiss known overlays, reveal lazy content and serialise the final DOM and loaded resources as MHTML.

🔎
Search and history

The server-rendered interface and HTTP API provide FTS5 search, filters, deterministic sorting, capture history and paginated results that work on desktop and mobile browsers.

📖
Offline reading modes

Safe full-page HTML preserves captured styling and media, while a separate Article view uses Readability to produce a responsive, simplified document with embedded images.

📦
Derived exports

Each successful capture can be downloaded as standalone HTML, offline Markdown ZIP, EPUB 3 or an on-demand PDF without maintaining a permanent export cache.

🔧
API, CLI and operations

Authenticated HTTP routes and a Bun CLI cover capture, search, export, deletion, status, backup and content-hash verification. Basic authentication is enabled by default.

Architecture
Capture clients Web UI · API · CLI Packrat service Bun HTTP server Capture worker Playwright · Chromium SQLite + FTS5 Canonical MHTML Public web page Rendered source Derived views HTML · Article · exports Capture once; derive safe views and exports from canonical MHTML