Skip to content

dragginzgame/icydb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2,312 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MSRV CI License: MIT/Apache-2.0

IcyDB β€” Data Model Framework for the Internet Computer

IcyDB logo 100% Certified Swamp-Free

Battle-tested, schema-first data models for Internet Computer canisters. Built for Dragginz, now open to everyone.


πŸ‘‹ Overview

IcyDB is a Rust framework for building strongly-typed, queryable data models inside Internet Computer canisters.

It provides:

  • declarative entity definitions,
  • typed query intent with explicit semantics,
  • deterministic planning and execution,
  • and stable-memory–backed storage with predictable behavior.

IcyDB is designed for single-message atomicity, explicit correctness guarantees, and mechanical enforcement of architectural boundaries.


✨ Highlights

  • Entity macros β€” define schema-first entities declaratively.
  • Typed query intent β€” build queries as Query<E> with explicit semantics.
  • Deterministic planning β€” validated, executor-safe plans only.
  • Stable storage β€” data is persisted in stable memory (not heap), backed by CanIC B-trees.
  • Path dispatch β€” icydb_build generates internal routing helpers.
  • Observability endpoints β€” icydb_snapshot, icydb_metrics, icydb_metrics_reset.
  • IC integration β€” ergonomic icydb::start! and icydb::build! macros.
  • Testability β€” fixtures, predicate validation, index testing utilities.

⚑ Quick Start

Toolchain

  • Rust 1.93 (edition 2024)
  • Install with:
    rustup toolchain install 1.93

Add IcyDB

Use a pinned git tag for reproducible builds:

[dependencies]
icydb = { git = "https://github.com/dragginzgame/icydb.git", tag = "v0.0.1" }

πŸš€ Example

Define an entity

use icydb::prelude::*;

#[entity(
    sk(field = "id"),
    fields(
        field(ident = "id", value(item(is = "types::Ulid"))),
        field(ident = "name", value(item(is = "text::Name"))),
        field(ident = "description", value(item(is = "text::Description"))),
    ),
)]
pub struct User {}

Build and execute a query

Queries are built as typed intent, explicitly planned, and then executed. For session-bound fluent queries, use db!().load::<User>() (returns SessionLoadQuery) or db!().delete::<User>() (returns SessionDeleteQuery).

use icydb::prelude::*;

#[query]
pub fn users_named_ann() -> Result<Vec<UserView>, icydb::Error> {
    let query = Query::<User>::new(ReadConsistency::MissingOk)
        .filter(eq("name", "ann"))
        .order_by("name")
        .offset(100)
        .limit(50);

    let plan = query.plan()?;
    let rows = db!().load_executor::<User>().execute(plan)?;

    Ok(rows.views())
}

Key properties:

  • Entity type is fixed at construction (Query<User>).
  • Missing-row behavior is explicit (ReadConsistency).
  • Executors only accept validated, executable plans.
  • Query semantics are API-surface dependent: FieldRef and FilterExpr use different coercion defaults for ordering. See docs/QUERY_BUILDER.md for the locked contract.

πŸ—οΈ Project Layout

  • icydb/ β€” meta crate re-exporting the public API.
  • crates/icydb-core β€” runtime (entities, traits, query engine, stores).
  • crates/icydb-schema-derive β€” proc-macros for schema, traits, and views.
  • crates/icydb-schema β€” schema AST, builder, and validation.
  • crates/icydb-build β€” build-time codegen for actors, queries, metrics.
  • crates/test, crates/test_design β€” integration and design tests.
  • assets/, scripts/, Makefile β€” docs, helpers, workspace tasks.

πŸ“Ÿ Observability & Tooling

The following endpoints are generated automatically:

  • icydb_snapshot() β†’ live StorageReport
  • icydb_metrics() β†’ metrics since a given timestamp
  • icydb_metrics_reset() β†’ clears metrics state

Example usage:

dfx canister call <canister> icydb_snapshot
dfx canister call <canister> icydb_metrics
dfx canister call <canister> icydb_metrics_reset

πŸ§‘β€πŸ’» Local Development

Workspace commands (see Makefile):

make check      # type-check workspace
make clippy     # lint (warnings denied)
make test       # unit + integration tests
make fmt        # format workspace
make build      # release build

Pre-commit hooks run:

  • cargo fmt -- --check
  • cargo sort --check
  • cargo sort-derives --check

Style & Conventions

  • Prefer typed errors (thiserror) over panics in library code.
  • Keep functions small and single-purpose.
  • Use explicit semantics over implicit defaults.
  • Co-locate unit tests; integration tests live under crates/test*.
  • No backward-compatibility guarantee yet β€” breaking changes are documented.

πŸ”’ Versioning & Security

  • Git tags are treated as immutable by project policy.
  • Production users should always pin to a specific tag.
  • Floating branches are not recommended for production.

Verify available tags:

git ls-remote --tags https://github.com/dragginzgame/icydb.git

πŸ“Š Current Focus

  • Expanding documentation and runnable examples.
  • Increasing test coverage across query and index paths.
  • Tracking memory usage and store statistics in production.
  • Reducing WASM size produced by icydb_build.

πŸ“„ License

Licensed under either of:

  • Apache License, Version 2.0 (LICENSE-APACHE)
  • MIT License (LICENSE-MIT)

at your option.

About

ic database

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages