Skip to content

Getting Started

Maryk runs on Kotlin Multiplatform and ships as modular artifacts. This guide shows the shortest path from model → value → validation → serialization → storage.

Add the core dependency to your target source set:

repositories {
mavenCentral()
}
dependencies {
implementation("io.maryk:maryk-core:<maryk-version>")
}

For stores, add one engine:

// In-memory (tests/dev)
implementation("io.maryk:maryk-memory:<maryk-version>")
// Embedded RocksDB (apps/servers)
implementation("io.maryk:maryk-rocksdb:<maryk-version>")
// FoundationDB (JVM server)
implementation("io.maryk:maryk-foundationdb:<maryk-version>")
import maryk.core.models.RootDataModel
import maryk.core.properties.definitions.date
import maryk.core.properties.definitions.string
import maryk.lib.time.LocalDate
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:

val john = Person.create {
firstName with "John"
lastName with "Smith"
dateOfBirth with LocalDate(2017, 12, 5)
}
Person.validate(john)

Property indexes are stable field IDs. Keep them forever once data has been written or serialized. Add new property indexes for new fields; do not reuse old ones. These are different from secondary ordered indexes and search indexes used for query access paths.

val json = Person.Serializer.writeJson(john, pretty = true)
val fromJson = Person.Serializer.readJson(json)

Also see YAML/ProtoBuf in Serialization.

Use in‑memory for tests:

import kotlinx.coroutines.runBlocking
import maryk.core.query.requests.add
import maryk.datastore.memory.InMemoryDataStore
fun main() = runBlocking {
InMemoryDataStore.open(
keepAllVersions = true,
keepUpdateHistoryIndex = true,
dataModelsById = mapOf(1u to Person)
).use {
execute(Person.add(john))
}
}

dataModelsById is the model registry for the store. Keep IDs stable for persistent stores. ID 0u is reserved.

Then advance to the First Store Tutorial for a complete add/get/history example, or Stores for engine selection.

Use the CLI to explore models and records, run scans, and edit values without writing code.

Use the Maryk App for a desktop UI to browse models and edit records.

Terminal window
./gradlew :app:run