In-browser key–value database with durable IndexedDB persistence, with a metadata layer for images (meta in JSON, binary in IndexedDB). Designed as a Rust workspace with a clean separation of core engine traits, storage backends, and a wasm-bindgen public API.
- Simple async KV API: put/get/delete
- Namespaces for logical separation (default, images_meta, images_blob)
- Image support: store JSON metadata and raw bytes separately
- IndexedDB backend (wasm32) for persistence in browsers
- Pure-Rust in-memory backend for tests
crakendb
├── core/ # Pure Rust storage engine interfaces + in-memory engine
├── storage/ # IndexedDB backend (wasm32), no-ops on non-wasm
├── wasm/ # wasm-bindgen public API
├── web/ # Minimal JS demo / integration
└── Cargo.toml # workspace
Prerequisites:
- Rust toolchain
- wasm-pack (for building the wasm package):
cargo install wasm-pack
Build and test Rust core:
cargo test -p crakendb-core
cargo check
Build wasm package for the demo:
wasm-pack build wasm --target web --out-dir ../web/pkg --out-name crakendb_wasm
Run the demo:
cd web
python3 -m http.server
# Open http://localhost:8000 in your browser
On the demo page:
- Init DB to create/open the IndexedDB database
- Put/Get Key to store and retrieve a simple value
- Use the file input and Put/Get Image to round-trip image data
- Delete Key to remove an entry
- Delete Image to remove stored image by filename
- List Images to print metadata list in the console
Core types and helpers live in crakendb-core:
- Engine trait:
put(ns,key,bytes),get(ns,key),delete(ns,key),scan_prefix(ns,prefix) - Namespaces:
defaultfor generic KVimages_metafor JSON-encodedImageMetaimages_blobfor raw image bytes
- Helpers:
put_kv/get_kv/delete_kvput_image/get_image
See: core/src/lib.rs
Exposed by crakendb-wasm:
init(db_name: string)put(key: string, value: Uint8Array)get(key: string) -> Uint8Array | nullput_image_rs(meta: {id,content_type,width,height,size,created_at_ms}, data: number[])get_image_rs(id: string) -> { meta, data } | null
Demo usage in: web/main.js
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT) at your option.
Please see SECURITY.md for details on our security policy and how to report vulnerabilities.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in crakendb by you shall be licensed as above, without any additional terms or conditions. See CONTRIBUTING.md and CODE_OF_CONDUCT.md.