Skip to content

shayyz-code/crakendb

CrakenDB

logo-crakendb

License: Apache-2.0 License: MIT Target: wasm32-unknown-unknown Storage: IndexedDB Status: alpha Edition: 2021

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.

Features

  • 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

Workspace Layout

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

Quick Start

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

Rust API (core)

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:
    • default for generic KV
    • images_meta for JSON-encoded ImageMeta
    • images_blob for raw image bytes
  • Helpers:
    • put_kv / get_kv / delete_kv
    • put_image / get_image

See: core/src/lib.rs

Wasm API (browser)

Exposed by crakendb-wasm:

  • init(db_name: string)
  • put(key: string, value: Uint8Array)
  • get(key: string) -> Uint8Array | null
  • put_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

License

Licensed under either of

Security

Please see SECURITY.md for details on our security policy and how to report vulnerabilities.

Contribution

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.

About

Local in-browser Database, with persistence, and a metadata layer for images (meta in JSON, binary in IndexedDB)

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors