
Maryk: Kotlin Multiplatform Data Modeling and Storage
Maryk lets you define a strongly typed data model once, then use that same model for validation, serialization, querying, storage, tooling, and sync across Kotlin Multiplatform targets.
Use Maryk when you want:
- One schema shared by clients, servers, tools, and tests.
- Stable binary-compatible property indexes instead of reflection-heavy runtime mapping.
- Version-aware storage: historic reads, change queries, update streams, and efficient sync.
- Typed queries and mutations, atomic change sets, and serializable transaction scopes over the same models.
- One request API across in-memory, browser IndexedDB, embedded RocksDB, distributed FoundationDB, and remote stores.
- Portable JSON, YAML, and ProtoBuf serialization built from the same model definitions.
Maryk is a good fit for local-first apps, cross-platform products, Kotlin-heavy backends, tools that need typed data files, and systems where schema evolution and incremental sync matter.
Start with the website for the best reading path. Source docs live in this repository and the website is maintained in website/.
Use the typed request API as your main API for application reads, writes, history, and sync. SQL is an optional layer for reporting, ad hoc queries, and tabular integrations; it is not required to use Maryk stores.
Getting Started
These docs describe the current source branch. When using a published artifact,
read the matching release tag and use the same version for every Maryk module.
Add the core dependency:
repositories {
mavenCentral()
}
dependencies {
implementation("io.maryk:maryk-core:<maryk-version>")
}
Define a model:
import maryk.core.models.RootDataModel
import maryk.core.properties.definitions.date
import maryk.core.properties.definitions.string
import kotlinx.datetime.LocalDate
Person : RootDataModel<Person>() {
firstName string(index = 1u)
lastName string(index = 2u)
dateOfBirth date(index = 3u)
}
johnSmith = Person.create {
firstName with
lastName with
dateOfBirth with LocalDate(, , )
}
Person.validate(johnSmith)
json = Person.Serializer.writeJson(johnSmith, pretty = )
fromJson = Person.Serializer.readJson(json)
For a complete model → store → query flow, read Getting Started or First Store Tutorial.
Storage Engines
- Memory: in-memory, non-persistent, best for tests and fast local feedback.
- IndexedDB: persistent browser storage for JS and WasmJS apps.
- RocksDB: embedded persistent storage for desktop, mobile, and single-node server use.
See store/README.md for the decision guide.
Platform Support
Maryk is Kotlin Multiplatform. Platform support depends on the module:
- Core modeling, validation, querying, SQL, JSON/YAML serialization, generator support, Memory Store, shared store logic, test models, and test helpers target JVM, Android, JS, WasmJS, Linux x64 and ARM64, Windows, iOS, macOS, watchOS, tvOS, and Android Native.
- IndexedDB Store targets JS browser and WasmJS browser for persistent browser storage.
Documentation Map
Repository Development
Requires JDK 21. Confirm with java -version before running Gradle.
Useful commands:
./gradlew jvmTest
./gradlew :store:memory:jvmTest
./gradlew :cli:jvmTest
cd website && yarn build
When editing website pages generated from repository docs, update the source file listed in website/README.md.
Contributing
Issues, discussions, docs fixes, examples, store improvements, and PRs are welcome. Good first contributions usually live in docs, examples, tests, CLI/App workflows, or store-specific edge cases.