Getting Started
Maryk runs on Kotlin Multiplatform and ships as modular artifacts. This guide shows the shortest path from model → value → validation → serialization → storage.
Dependency
Section titled “Dependency”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>")Define a model
Section titled “Define a model”import maryk.core.models.RootDataModelimport maryk.core.properties.definitions.dateimport maryk.core.properties.definitions.stringimport 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.
Serialize
Section titled “Serialize”val json = Person.Serializer.writeJson(john, pretty = true)val fromJson = Person.Serializer.readJson(json)Also see YAML/ProtoBuf in Serialization.
Pick a datastore
Section titled “Pick a datastore”Use in‑memory for tests:
import kotlinx.coroutines.runBlockingimport maryk.core.query.requests.addimport 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.
./gradlew :app:runNext steps
Section titled “Next steps”- Run the complete First Store Tutorial.
- See In Practice for CLI and App workflows.
- Learn how models and properties work in Data design.
- Learn how indexes are composed in Index design.
- Learn how to change existing models in Changing Models Safely.
- Understand fit and tradeoffs in Tradeoffs.
- Explore queries, filters, and aggregations in Querying.
- Check out how to persist data in Stores.
- Browse and edit data interactively with the CLI.