Battle-tested, schema-first data models for Internet Computer canisters. Built for Dragginz, now open to everyone.
Make It [ Matter ] on the Internet Computer
Magical
Modular
Multiplayer
Monetisable
Mainstream
Mimic is a Rust framework for building strongly-typed, queryable data models on the Internet Computer.
- Entity macros β define entities declaratively with schema attributes.
- Query builder β type-safe filters, sorting, offsets, limits.
- Stable storage β powered by
ic-stable-structuresB-Trees with predictable costs. - Automatic endpoints β
mimic_buildgeneratesmimic_query_load,mimic_query_save,mimic_query_deletehandlers. - Observability endpoints β
mimic_snapshot,mimic_logs,mimic_metrics,mimic_metrics_resetship automatically. - Text casing toolkit β sanitizers/validators for snake/kebab/title/camel cases that work across lists, maps, sets.
- Integration with IC canisters β ergonomic
mimic_start!andmimic_build!macros. - Testability β fixtures, query validation, index testing utilities.
- Install Rust 1.91.1+ (workspace uses edition 2024).
- Add Mimic to your
Cargo.tomlusing the latest tag:[dependencies] mimic = { git = "https://github.com/dragginzgame/mimic.git", tag = "v0.29.0" }
- Declare an entity with the
#[entity]macro and a primary key. - Query your data via
db!().load::<Entity>()....
See INTEGRATION.md for pinning strategies, feature flags, and troubleshooting tips.
/// Rarity
/// Affects the chance of an item dropping or an event occurring.
#[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"))),
field(ident = "order", value(item(is = "game::Order"))),
field(ident = "color", value(item(is = "types::color::RgbHex"))),
),
)]
pub struct Rarity {}#[query]
pub fn rarities() -> Result<Vec<RarityView>, mimic::Error> {
let query = mimic::db::query::load()
.filter(|f| {
// (level >= 2 AND level <= 4) OR (name CONTAINS "ncon")
(f.gte("level", 2) & f.lte("level", 4)) | f.contains("name", "ncon")
})
.sort(|s| s.desc("level"))
.limit(100);
let rows = db().load::<Rarity>().debug().execute(&query)?;
Ok(rows.views())
}crates/mimicβ core framework (entities, queries, schema, stores, types).crates/mimic_buildβ canister codegen (build.rsβactor.rs).crates/mimic_commonβ shared utilities.crates/mimic_schemaβ schema definitions and types.crates/mimic_declareβ proc-macros for schema/traits.crates/mimic_testsβ integration + design tests.assets/β artwork and documentation assets.scripts/β release/version helpers.
mimic_snapshot()β liveStorageReportwith data/index/state breakdowns.mimic_logs()β in-memory log buffer (oldest β newest).mimic_metrics()βEventReportfor counters sincesince_ms.mimic_metrics_reset()β clears metrics state.
Examples:
dfx canister call <canister> mimic_snapshot
dfx canister call <canister> mimic_logs
dfx canister call <canister> mimic_metrics
dfx canister call <canister> mimic_metrics_resetWorkspace commands (see Makefile):
make check # type-check workspace
make clippy # lint with warnings denied
make test # run all unit + integration tests
make fmt # format the workspace (or fmt-check to verify)
make build # release buildPre-commit hooks run cargo fmt -- --check, cargo sort --check, and cargo sort-derives --check. Run any of the make fmt*, make clippy, or make check targets once to auto-install and enable them.
- Prefer
?+ typed errors (thiserror) instead of panics in library code. - Keep functions focused; extract helpers when logic grows.
- Import ergonomically: group paths per crate (e.g.,
use crate::{db, design};). - Use saturating arithmetic for counters and totals.
- Co-locate small unit tests; integration/design tests live in
crates/mimic_tests. - No backward-compatibility promise yetβdocument breaking changes in the changelog.
We welcome issues, discussions, and pull requests now that the repository is public. To contribute:
- Fork and clone the repo.
- Install the toolchain (
rustup toolchain install 1.91.1). - Run
make fmt-check && make clippy && make check && make testbefore opening a PR. - Document user-visible changes in CHANGELOG.md under the latest heading.
Need help? Start with INTEGRATION.md, VERSIONING.md, or open a GitHub issue.
- Expanding documentation and runnable examples.
- Improving error modeling (
MimicError+ nested domain errors). - Deepening test coverage across entity indexes and query paths.
- Tracking store statistics & memory usage in production deployments.
- Reducing WASM size produced by
mimic_build.
Licensed under either of:
- Apache License, Version 2.0 (
LICENSE-APACHE) - MIT license (
LICENSE-MIT)
at your option.

