Maryk is a Kotlin Multiplatform framework for defining, validating, serializing, and storing data models consistently across multiple platforms, including iOS, macOS, Linux, Windows, Android, JVM, and JavaScript. 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.
Note: While Maryk’s data modeling and serialization are cross-platform, its persistant storage layer currently only runs on the JVM.
-
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/HBase) and leverage versioning to request historical states, compare past values, and minimize bandwidth by fetching only changed fields.
-
Data Aggregations & Insights: Perform aggregations (count, sum, average, min/max, grouped by time intervals or enums) for richer analytics and decision-making.
- Add Maryk Core Dependency:
In yourbuild.gradle.kts
:
implementation("io.maryk:maryk-core:<version>")
- 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)
}
- Create and Validate Instances:
val johnSmith = Person.run { create(
firstName with "John",
lastName with "Smith",
dateOfBirth with LocalDate(2017, 12, 5),
) }
// Validate the object
Person.validate(johnSmith)
- Serialize Your Data Objects:
// Serialize to JSON
val json = Person.writeJson(johnSmith)
// Deserialize from JSON
val personFromJson = Person.readJson(json)
- Choose a Data Store:
- In-memory store (non-persistent, suitable for testing)
- RocksDB-based store (persistent, efficient for local storage)
- HBase-based store (persistent and scalable store)
For detailed information, check out:
- Core – Data models, queries, parsers, readers.
- Library – Shared utilities for things like Strings and ByteArrays.
- 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.
- Stores:
We welcome contributions through feature requests, issue reports, and pull requests.
Your involvement helps Maryk grow and improve!