Skip to content
/ maryk Public

Maryk is a Kotlin Multiplatform library which helps you to store, query and send data in a structured way over multiple platforms. The data store stores any value with a version, so it is possible to request only the changed data or live listen for updates.

License

Notifications You must be signed in to change notification settings

marykdb/maryk

Repository files navigation

GitHub license Download

Maryk: Cross-Platform Data Modeling and Storage

Maryk is a Kotlin Multiplatform framework for defining, validating, serializing, and storing data models consistently across multiple platforms, including iOS, macOS, watchOS, tvOS, Linux, Windows, Android, JVM, JavaScript and Wasm. With a fully version-aware data store and flexible querying, Maryk makes it easy to maintain complex data structures while ensuring backward compatibility and efficient data handling.

The RocksDB persistence layer is available for the JVM, iOS, macOS, tvOS, watchOS, Android, Android Native, Windows and Linux. The FoundationDB persistence layer is available on supported platforms that have the FoundationDB client library (libfdb_c) present (JVM, macOS, linux).

Check the Website for more context and documentation. It is maintained in the website folder.

Key Features

  • Unified Data Modeling: Define your data models once and use them everywhere, ensuring a single source of truth across platforms.

  • Flexible Property Types and Inheritance: Create models with a variety of property types, and reuse model structures to build complex data hierarchies.

  • Built-in Validation: Enforce data quality with validations such as required fields, uniqueness, min/max constraints, and regex checks.

  • Cross-Platform Serialization: Seamlessly serialize and deserialize data as JSON, YAML, or Protocol Buffers, facilitating easy communication between clients and services.

  • Model Serialization & Compatibility: Serialize your schemas themselves and run compatibility checks across different clients, ensuring smooth upgrades and migrations.

  • Version-Aware Storage and Queries: Store data in NoSQL data stores (in-memory/RocksDB/FoundationDB) and leverage versioning to request historical states, compare past values, and minimize bandwidth by fetching only changed fields.

  • Sensitive Field Protection: Mark simple value properties with sensitive = true to encrypt stored payloads (sensitive+unique supported with token provider; sensitive+indexed not supported).

  • Data Aggregations & Insights: Perform aggregations (count, sum, average, min/max, grouped by time intervals or enums) for richer analytics and decision-making.

  • CLI tooling: Browse and edit records in a terminal via the Maryk CLI.

  • Desktop App: Browse models and edit records in a desktop UI with the Maryk App.

Getting Started

  1. Add Maryk Core Dependency:
    In your build.gradle.kts:
implementation("io.maryk:maryk-core:<version>")
  1. Define Your Data Models:
    Create a Kotlin data model:
object Person : RootDataModel<Person>() {
   val firstName by string(index = 1u)
   val lastName by string(index = 2u)
   val dateOfBirth by date(index = 3u)
}
  1. Create and Validate Instances:
val johnSmith = Person.create {
   firstName with "John"
   lastName with "Smith"
   dateOfBirth with LocalDate(2017, 12, 5)
}

// Validate the object
Person.validate(johnSmith)
  1. Serialize Your Data Objects:
// Serialize to JSON
val json = Person.writeJson(johnSmith)

// Deserialize from JSON
val personFromJson = Person.readJson(json)
  1. Choose a Data Store:
  • Memory — in‑memory, non‑persistent, fastest feedback for dev/tests.
  • RocksDB — embedded, persistent, high performance on a single node across desktop/mobile/server.
  • FoundationDB — distributed, transactional persistence with strong consistency and time‑travel support (JVM bundled; native targets require libfdb_c).
  • Remote Store — expose a local store over HTTP/SSH and connect with RemoteDataStore.

See the overview and guidance in store/README.md for when to pick each engine.

Documentation

For detailed information, check out:

  • Core – Data models, queries, parsers, readers.
  • Library – Shared utilities for things like Strings and ByteArrays.
  • File – Minimal cross-platform file IO layer used by tooling and stores.
  • JSON & YAML – Streaming parsers and writers.
  • Generator – Code generation from YAML and JSON models.
  • Test Library – Testing utilities and helpers.
  • DataFrame Integration – DataFrame helper functions for Maryk objects.
  • CLI – Interactive terminal client for browsing and editing stores.
  • App – Desktop UI for browsing and editing stores.
  • Stores:
    • Shared – Shared logic for building stores.
    • Memory – In-memory store (non-persistent).
    • RocksDB – Persistent, high-performance store.
    • FoundationDB – Persistent, scalable transactional store (multiplatform where libfdb_c is available).
    • Remote – HTTP/SSH gateway and client for remote access.
    • Tests – Common tests to ensure store reliability.

Contributing

We welcome contributions through feature requests, issue reports, and pull requests.

Your involvement helps Maryk grow and improve!

About

Maryk is a Kotlin Multiplatform library which helps you to store, query and send data in a structured way over multiple platforms. The data store stores any value with a version, so it is possible to request only the changed data or live listen for updates.

Topics

Resources

License

Stars

Watchers

Forks

Contributors