Monko

Type-safe MongoDB repositories for Kotlin. Typed queries, KSP-generated property paths, and the same entity model as Karango.

Why Monko?

MongoDB's Kotlin driver works. But you write string-based field paths everywhere:

// Without Monko
collection.find(Filters.eq("address.city", "Berlin"))
collection.find(Filters.gt("age", 18))
// Rename a field? Find-and-replace across the codebase. Miss one? Silent runtime failure.

Monko gives you type-safe property paths generated by KSP at compile time:

// With Monko
repo.find { r ->
    filter(r.address.city.eq("Berlin"))
    filter(r.age.gt(18))
    sort(r.name.asc)
}
Rename a field? The compiler tells you every query that needs updating. No silent breakage, no runtime surprises.

What you get

Type-Safe Queries

KSP generates property paths for every @Vault entity. Filter, sort, and index by field name with compile-time checks.

Repository Pattern

Full CRUD with lifecycle hooks, batch operations, and atomic read-modify-write.

Index DSL

Define persistent, unique, sparse, and TTL indexes with the same type-safe property paths.

Shared Entity Model

Uses the same Stored<T>, New<T>, Ref<T> wrappers as Karango. Switch databases without changing domain code.

Slumber Integration

Serialization via Slumber. Sealed classes, nullable types, and custom codecs just work.

Funktor Integration

Pluggable backend for Funktor modules. Auth, logging, cluster, and messaging can all use Monko.

How it compares to Karango

Monko and Karango share the same architecture — entity wrappers, repository pattern, lifecycle hooks, KSP code generation, and Kontainer integration. The difference is the database underneath:

Aspect Karango Monko
Database ArangoDB MongoDB
Query language AQL DSL (FOR, FILTER, SORT) MongoDB filter/sort DSL
Entity model Stored, New, Ref Same (shared via Vault)
KSP codegen AQL property paths MongoDB property paths
Lifecycle hooks OnBeforeSave, OnAfterSave, OnAfterDelete Same (shared via Vault)
Choose your database. Keep your domain code. Monko and Karango are interchangeable at the repository layer.