Personal project · 2026

Cura

Offline-first desktop clinic-management application built for medical offices operating under intermittent internet connectivity.

SQLite
sync engine
Supabase
Tauri·Rust·SQLite·Supabase·Next.js

Problem

Medical clinics require reliable daily operations—patient registration, intake, treatment logging, billing—in regions where internet connectivity is intermittent or unavailable.

Approach

Architected an offline-first desktop app: a Rust core executes SQLite operations via a connection pool with WAL mode enabled, wrapped inside a Tauri shell containing a static Next.js UI.

Built a change-data-capture sync engine. SQLite AFTER triggers serialize mutations into JSON changelogs. Background workers push deduplicated, dependency-ordered batches with exponential backoff, pull remote cursor updates, and resolve conflicts using last-write-wins with device-id tiebreaks.

Implemented a custom Phoenix-protocol WebSocket client for realtime pull triggers, non-coordinative daily visit codes (YYYYMMDD-DEV-001), WAL checkpoints before rotating backups, and 54 unit tests.

Technical Decisions

  1. SQLite AFTER triggers for change data capture

    Serialized row mutations to JSON within SQLite AFTER triggers, guaranteeing that local modifications cannot bypass the sync changelog.

  2. Echo cancellation via local device-id filtering

    Tagged synced rows with device IDs and dropped local changelog records post-pull, preventing infinite replication feedback loops.

  3. Device-local table isolation

    Excluded settings, print queues, and schema version tables from cloud replication to prevent local workstation state corruption.

  4. Atomic visit code generation without central server

    Generated unique daily visit codes using date-device composite keys and atomic UPSERT queries inside transactions, eliminating central server dependencies.

  5. WAL truncating checkpoints before automated backups

    Executed PRAGMA wal_checkpoint(TRUNCATE) prior to file copies, ensuring database backups remain uncorrupted.

Key Achievements

  • Built complete offline-first desktop app solo in 3 calendar days across 48 domain commands.
  • Engineered trigger-based SQLite changelog sync engine pushing deduplicated batches to Supabase.
  • Implemented custom Phoenix-protocol WebSocket client for realtime cross-workstation updates.
  • Authored 54 backend unit tests covering DDL migrations, conflict resolution, and backup validation.
  • Configured automated rotating daily backups with pre-backup WAL checkpointing.

Outcome

A cross-platform desktop application handling clinic workflows offline, maintaining realtime synchronization when connected, and validated by 54 unit tests.