testing local-first datastores

CLAUDE.md#

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview#

Node.js/TypeScript benchmark suite comparing local datastore performance (TinyBase, LevelGraph, SQLite) with ~1GB test data. Each benchmark runs 10 iterations, discards high/low scores, and reports the median.

Commands#

npm install          # Install dependencies
npm run generate     # Generate test data (~1GB) to test-data/
npm run bench        # Run benchmarks on all stores (10 iterations each)
npm run bench:store tinybase    # Benchmark single store
npm run bench:store levelgraph
npm run bench:store sqlite
npm run charts       # Regenerate charts from latest results

Architecture#

  • src/generator/ - Test data generation (URLs, images, documents, metadata)
  • src/harness/ - Benchmark runner, timing, and result reporting
  • src/stores/ - Datastore adapters implementing DatastoreAdapter interface
  • src/runner.ts - Main CLI entry point

Adding a New Datastore#

  1. Create src/stores/yourstore.ts implementing DatastoreAdapter from src/harness/types.ts
  2. Register in src/stores/index.ts

The adapter interface requires: init(), cleanup(), addUrls(), addImage(), addDocument(), addMetadata(), getRecentUrls(), getImages(), getDocuments(), getDiskUsage()