Examples

Three runnable applications demonstrating merkql's core patterns, integrity verification, and event sourcing capabilities.

Self-contained Temp directory No setup

Running the examples

Each example is a standalone Cargo project that runs end-to-end in a temporary directory. No external services, no configuration, no cleanup.

cargo run -p merkql-sensor-pipeline
cargo run -p merkql-audit-trail
cargo run -p merkql-event-sourced-cart
Feature coverage matrix: which example demonstrates which feature Sensor Pipeline Audit Trail Event-Sourced Cart Producer / Consumer Compression (LZ4) Retention policy Merkle proofs Consumer groups Event sourcing

Sensor pipeline

A complete IoT data pipeline: ingest 1,000 sensor readings with keyed records, consume with two independent consumer groups for analytics and alerting, exercise LZ4 compression and retention policies, and verify that committed offsets survive a full broker restart.

Producer send_batch Consumer groups LZ4 Retention Restart
Read the walkthrough →

Audit trail

Demonstrates merkql's cryptographic integrity guarantees: generate and verify SHA-256 merkle inclusion proofs, observe root hash progression as records are appended, confirm that earlier proofs remain valid after growth, and detect on-disk data tampering through hash comparison.

Merkle proofs Verification Root progression Tamper detection SHA-256
Read the walkthrough →

Event-sourced cart

Implements event sourcing and CQRS: a stream of shopping cart domain events is replayed by two independent consumer groups, each building a different materialized view—one for cart state, one for revenue reporting. Then demonstrates incremental projection updates without full replay.

Event sourcing CQRS Projections Keyed records Incremental
Read the walkthrough →

Project structure

Each example is a standalone Cargo project with a path dependency on merkql.

examples/
├── sensor-pipeline/
   ├── Cargo.toml
   └── src/main.rs         # 249 lines
├── audit-trail/
   ├── Cargo.toml
   └── src/main.rs         # 234 lines
└── event-sourced-cart/
    ├── Cargo.toml
    └── src/main.rs         # 321 lines
# Build all examples
cargo build -p merkql-sensor-pipeline \
            -p merkql-audit-trail \
            -p merkql-event-sourced-cart

# Run individually
cargo run -p merkql-sensor-pipeline
cargo run -p merkql-audit-trail
cargo run -p merkql-event-sourced-cart