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 project that allows developers to define, validate, serialize, and store data models across multiple platforms, including iOS, macOS, Android, JVM, and JavaScript. Currently storage is only supported on the JVM.

With Maryk, you can easily create complex data structures, enabling efficient and seamless cross-platform communication for your applications featuring a fully version-aware data store and query engine. Its powerful capabilities and ease of use make it an excellent choice for managing and storing data in Kotlin-based applications.

Features

  • Unified data modeling: Define your data models once and use them seamlessly across all supported platforms, making it easy to create cross-platform applications with consistent data structures.

  • Flexible data model inheritance: Maryk allows you to include properties of different types within a data model and create a generic root data model that can contain different varieties of data models. This enables you to design more complex and expressive data structures.

  • Built-in validation: Easily validate your data objects with a variety of constraints, such as required, unique, min/max values or sizes, and regular expressions. This ensures that your data is always accurate and consistent.

  • Cross-platform serialization: Supports JSON, YAML, and Protocol Buffers serialization formats for efficient data transportation of data objects between platforms, allowing your app to communicate with any platform with ease.

  • Data Model Serialization and compatibility check: Maryk also enables serialization of the data models themselves, making it easy to check compatibility between different models on different clients or storage. This also allows you to transport data models across platforms, ensuring that your application's data structures are compatible even when running against outdated clients.

  • NOSQL data stores: Store and query data efficiently using provided implementations for NOSQL data stores like the in-memory store or the RocksDb backed store.

  • Full versioning support: Maryk's data stores are built with full versioning in mind, allowing you to easily access older versions or the changes made to your data objects at any point in time. This makes it possible to maintain an audit trail and provides feature-rich data management capabilities for your application.

  • Efficient version-aware data querying: As Maryk supports full versioning, you can easily request only the changed values from a certain time frame or see the difference between two data objects. This allows for more efficient data transportation and reduces bandwidth usage when synchronizing data across platforms.

  • Aggregations and insights: Aggregate your data and gain valuable insights on your stored data with built-in functionalities like count, sum, average, min/max value, and other statistical aggregations. Group your data based on date units like hour/week/month/year or by enum value to gain a deeper understanding of your data.

Getting Started

To get started with Maryk, follow these steps:

  1. Add Maryk's core dependency to your Kotlin Multiplatform project Gradle configuration:
implementation "io.maryk:maryk-core:$version"
  1. Define your data models:
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 data objects:
val johnSmith = Person.run {
    create(
        firstName with "John",
        lastName with "Smith",
        dateOfBirth with LocalDate(2017, 12, 5),
    )
}

// Validate the object
Person.validate(johnSmith) 
  1. Serialize your data objects in your preferred format (e.g., JSON, YAML, or ProtoBuf) and deserialize them on another platform.
User.writeJson(user, jsonWriter)

val user = User.readJson(reader)
  1. Choose an appropriate data store to store and query your data objects efficiently. Available store implementations include:

Documentation

For more details on how to use Maryk, explore the documentation within the modules of the project repository.

All core projects are multi-platform kotlin projects, and most support JS, macOS, iOS, Android and the JVM. .

  • core - The core of Maryk, including models, properties, queries, parsers, and readers.
  • library - A set of multi-platform utilities, such as String, Hex, UUID, and more.
  • json - A streaming JSON parser and writer.
  • yaml - A streaming YAML parser and writer.
  • generator - A code generator for Kotlin and protobuf schemas from YAML Models.
  • test library - A library to assist with writing tests.
  • test models - Maryk Models useful in testing library code.
  • Stores
    • Shared - Shared code that is useful in building Maryk stores.
    • Memory - An in-memory store implementation, useful for testing purposes.
    • RocksDB - A RocksDB store implementation.
    • test - Common tests to validate the correctness of store implementations.

Contributing

We welcome any feature requests, issue reports, and merge requests from the community. Feel free to open issues or submit pull requests on the GitHub repository.

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

Languages