Original Summary

I just published a technical deep-dive on how I solved complex, nested offline sync in Nitivakya (Kotlin Multiplatform + SQLDelight + Supabase). When Nitivakya was just a daily wisdom quote app, tracking sync state directly on database entity tables using a localState flag worked fine. However, when I introduced Actions (a nested hierarchy: Action ➔ Levels ➔ Items), row-level sync flags completely broke down: \> 2 separate table REST calls caused foreign-key 500 errors over shaky connections. \> Full-snapshot uploads risked overwriting server-calculated streak progress. \> Row-level flags couldn't express a simultaneous "Create Level A + Update Level B + Delete Level C" edit. To fix this, I moved to a Hybrid Outbox Architecture: Local Entity State: Kept purely for instant Jetpack Compose UI status indicators. Outbox Queue: Captures sparse JSON payload DTOs carrying only exact deltas. Supabase PostgreSQL RPC: Executes all level creations, updates, and deletions in a single atomic server transaction. In Kotlin, my withSync helper deep-merges consecutive offline edits and automatically cancels out offline create + delete actions resulting in zero unnecessary network calls. Read the full writeup with my SQLDelight schema, Kotlin withSync transaction code, and Supabase RPC function here: I just published a technical deep-dive on how I solved complex, nested offline sync in Nitivakya (Kotlin Multiplatform + SQLDelight + Supabase). When Nitivakya was just a daily wisdom quote app, tracking sync state directly on database entity tables using a localState flag worked fine. However, when I introduced Actions (a nested hierarchy: Action ➔ Levels ➔ Items), row-level sync flags completely broke down: > 2 separate table REST calls caused foreign-key 500 errors over shaky connections. > Full-snapshot uploads risked overwriting server-calculated streak progress. > Row-level flags couldn't express a simultaneous "Create Level A + Update Level B + Delete Level C" edit. To fix this, I moved to a Hybrid Outbox Architecture: Local Entity State: Kept purely for instant Jetpack Compose UI status indicators. Outbox Queue: Captures sparse JSON payload DTOs carrying only exact deltas. Supabase PostgreSQL RPC: Executes all level creations, updates, and deletions in a single atomic server transaction. In Kotlin, my withSync helper deep-merges consecutive offline edits and automatically cancels out offline create + delete actions resulting in zero unnecessary network calls. Read the full writeup with my SQLDelight schema, Kotlin withSync transaction code, and Supabase RPC function here: https://medium.com/@premjitchowdhury/when-offline-sync-relying-only-on-local-state-breaks-and-how-i-fixed-it-in-nitivakya-kmp-245e05892ac3 Would love to hear your thoughts or how you handle complex offline sync in KMP!   submitted by   /u/premjitdevelops [link]   [comments]


  • 情报分类:综合情报
  • 分类依据:内容未命中明确的垂直分类规则,归入综合情报
  • 信息来源:Reddit · SideProject
  • 发布时间:2026/9/27 15:18:51