Introducing SplitSync
SplitSync is for a group that pays for things on a trip and settles up later. Someone pays for the villa. Someone else pays for the cab. Four people split dinner, and only three of them have drinks.
The app has two screens. A dashboard shows the total, each person's balance, suggested settlements, a category breakdown and recent expenses. An editor adds or changes an expense and previews the split.
The app has a few hard requirements:
| Requirement | What goes wrong without it |
|---|---|
| Exact money | Floats drift. ₹100 split three ways must add back up to ₹100. |
| One source of truth | An edit on one card and a stale total on another. |
| Works offline | Beach shacks don't have good Wi-Fi. |
| Stays fast as data grows | A trip with a thousand expenses freezes the dashboard on every save. |
There's a fifth problem. It's a finance app, so the telemetry must not carry amounts, expense titles or people's names. Writing a privacy rule is easy. Checking what actually leaves the phone is harder.
The stack
- React Native 0.81 + Expo SDK 54, with the New Architecture and Expo Router. I used SDK 54 on purpose.
@livestore/adapter-expo@0.5.1needsexpo-sqlite ^16, and SDK 54 is the last release that ships it. - LiveStore 0.5.1 with its Expo adapter. It's a local-first data layer: events go into an eventlog, materializers project them into SQLite, and queries are reactive.
- Measure:
@measuresh/react-native0.6.0, which bundles the Android SDK 0.24.0. It's an open-source mobile observability platform, and you can self-host it. - Claude Code with the Measure MCP server.
You need a development build. Both SDKs ship native code, so Expo Go can't run them.

NOTE: Sync is optional in SplitSync. LiveStore can sync through a Cloudflare Worker, and the repo includes one. I left it off. We already covered offline sync with Turso, so this demo focuses on event sourcing, reactive queries and performance.
Storing expenses as events with LiveStore
LiveStore separates what happened from what the app shows. Every user intent is an event. Events are versioned and never edited:
// src/livestore/schema.ts (simplified) export const events = { expenseCreated: Events.synced({ name: 'v1.ExpenseCreated', schema: Schema.Struct({ id: Schema.String, title: Schema.String, category: Schema.String, amountMinor: Schema.Number, paidBy: Schema.String, participants: Schema.Array(Schema.String), createdAt: Schema.Number, isSeed: Schema.Boolean, }), }), expenseUpdated: /* … */, expenseDeleted: /* … */, settlementRecorded: /* … */, } Amounts are integer paise (₹1 = 100 paise). Floats never touch the ledger.
A materializer turns each event into rows. This is where the equal split happens:
// src/livestore/schema.ts (simplified) 'v1.ExpenseCreated': ({ id, amountMinor, participants, ...rest }) => [ tables.expenses.insert({ id, amountMinor, participants, ...rest }).onConflict('id', 'ignore'), ...splitEqually(amountMinor, participants).map((share) => tables.expenseShares.insert({ id: `${id}:${share.memberId}`, expenseId: id, ...share }), ), ], splitEqually hands the leftover paise to participants in a fixed member order. ₹100.00 split three ways is always 3,334 + 3,333 + 3,333 paise, on every device that replays the same events.
The dashboard reads the tables through reactive queries. A component subscribes with store.useQuery(query$). When a commit touches a table, LiveStore re-runs the queries that depend on it, and only those components re-render.

Saving is one line in the app:
store.commit(events.expenseCreated({ id, title, category, amountMinor, paidBy, participants, createdAt: Date.now(), isSeed: false })) The bug LiveStore had on a fresh install
The first launch on a clean emulator crashed with:
TypeError: importing from an existing database is not yet supported in expo My first guess was the LiveStore devtools bridge. That was wrong, and turning devtools off didn't help. So I added a log line inside the adapter. It showed what import() was actually receiving: another database object, not bytes.
On first boot, LiveStore core resets the state database by calling dbState.import(emptyDb) with a database instance. The Expo adapter's import() only accepts a Uint8Array. Every fresh install hits that path.
The fix is four lines. If import() gets a database, serialize it with its own export() first. I applied it with patch-package, so it survives npm install.
Two smaller setup issues are worth knowing about:
- LiveStore depends on
nanoid@5, which only exposes abrowserexport besides its Node build. I added a Metro resolver rule fornanoidand acrypto.getRandomValuespolyfill backed byexpo-crypto. - My project folder had a
&in its name. Android's native C++ link step runs throughcmd.exe, which treats&as a command separator, so the build failed. Building from a path without&or spaces fixed it.
Adding observability with Measure.sh
Measure ships an Expo config plugin. The API keys come from the environment, so they never end up in the repo:
// app.config.ts plugins: [ ['@measuresh/react-native', { androidApiKey: process.env.MEASURE_ANDROID_API_KEY, androidApiUrl: process.env.MEASURE_ANDROID_API_URL, }], ], Then one call when the app starts:
await Measure.init({ config: new MeasureConfig({ enableLogging: __DEV__ }) }) What I track
Spans. Seven of them, each around a real operation boundary: livestore_initialization, expense_commit, expense_query, balance_calculation, reactive_update, dataset_generation and sync_recovery. I don't estimate LiveStore's internal timings. I time what the app can see: a commit call, a query, a render.
reactive_update is the one I care about most. It starts just before a commit and ends in a useEffect after React has rendered the new data. That's the latency a user actually feels.
One detail took a while to find. Spans started before Measure.init() resolves are no-ops. So my trace helper records its own timestamps and emits the span through startSpanWithTimestamp once the SDK is ready. Without that, livestore_initialization would never show up.
Events. expense_created, expense_updated, expense_deleted, dataset_generated, benchmark_completed, query_mode_changed, sync_completed, sync_failed. They carry category, counts, durations and query mode. Never amounts.
A privacy filter. Every attribute goes through one function. It keeps only primitives, truncates strings to Measure's 256-character limit, and drops keys that look sensitive, even if I pass them by mistake:
// src/instrumentation/attributes.ts (simplified) const BLOCKED_KEY = /(amount|price|cost|total_minor|title|description|name|email|phone|note)/i Handled errors. I re-send them with the message replaced by a category ([commit_failed]). Error messages can contain SQL bind values or user input. The stack stays.
Testing on an Android emulator
I ran a debug build on an Android 12 (API 31) emulator. The starter data is seven Goa Trip expenses.
1. Reactive updates
I added an expense: ₹777.77 for drinks, paid by Kabir. The total, the expense count, all four balances, the settlement suggestions and the category bar updated from that single commit. The expense_commit span took 67.7 ms.
2. A larger dataset
The developer panel generates deterministic data: the same size always produces the same expenses. Events are committed in batches of 250. Each store.commit({ skipRefresh: true }, ...batch) is one SQLite transaction, followed by a single store.manualRefresh() at the end.
1,000 events took 28.5 s end to end. Only 5.9 s of that was inside commit, and the final refresh took 13.9 ms. The other ~22 s happened between batches, while the UI yielded. My guess is that LiveStore was persisting the eventlog on the JS thread, but I didn't confirm it. Either way, commit time alone understates the cost of bulk writes on React Native.
3. Optimized vs unoptimized queries
This is the main experiment. The app can build the dashboard two ways, and you can switch between them at runtime.
Unoptimized is a pattern I've seen in real apps. It subscribes to every expense row, including soft-deleted ones and the JSON participants column. Then it computes the total, categories, splits and balances in JavaScript, and sorts the whole list to show 20 rows.
Optimized uses four focused queries. SQLite does the aggregation on indexed columns. One query returns everything the balances need:
SELECT 'paid' AS kind, paidBy AS memberId, SUM(amountMinor) AS amountMinor FROM expenses WHERE deletedAt IS NULL GROUP BY paidBy UNION ALL SELECT 'owed', memberId, SUM(shareMinor) FROM expense_shares GROUP BY memberId UNION ALL … Both modes feed the same ledger functions, so they have to produce the same numbers. The benchmark checks that: it fingerprints both results and shows Results identical only if they match. Separately, I ran the optimized SQL against node:sqlite at 100, 1,000 and 10,000 rows. The results were identical, and EXPLAIN QUERY PLAN showed covering indexes on every aggregate.
Event commit is 6.5× slower in unoptimized mode, even though the write itself is identical. In LiveStore, commit is synchronous and refreshes every subscribed query before it returns. A heavy subscription makes every save slower, not just every read.
Then I used the app normally in unoptimized mode. The reactive_update spans for adding and deleting an expense took 461 ms and 577 ms. In optimized mode they took about 21 ms.
That's from a handful of runs on one emulator in a debug build, so read it as a comparison, not a benchmark. The README explains how to repeat it on a release build.
Debugging with Claude Code and the Measure MCP server
Measure's MCP server lets an agent query sessions, traces, errors and metrics directly. Setup is one command:
claude mcp add --transport http measure https://agent.measure.sh/mcp The prompt I gave to Claude Code:
Test Measure MCP against the app. Check that Measure is not tracking internal LiveStore data and only sees in-app data. Then give me an analysis, and tell me what Measure MCP returned and how you found the issues. How it worked
Claude Code started by producing data. It drove the emulator with adb taps. It added an expense titled CANARYTITLE9431 for ₹777.77: two values that should never appear in Measure. Then it generated 1,000 events, ran the benchmark, switched to unoptimized mode, added and deleted an expense, and sent a handled error. Sending the app to the background flushed Measure's batch.
Then it queried Measure:
-
list_appsfound SplitSync by its bundle ID. -
get_sessionsreturned the two sessions from the run. -
get_root_span_nameslisted all seven custom spans, plus Measure's ownActivity TTIDandFragment TTIDscreen-load spans. -
get_sessionreturned the raw event stream: 181 events in the main session and 71 in the unoptimized one.
The session JSON was 316 KB, too big to read in one go. So Claude Code wrote a short script that counted events by type and searched every payload for 25 strings: the canary title and amount, member names, SQL keywords, LiveStore table and event names, and the localhost ports.
My own telemetry was clean. Events and spans carried only allowlisted attributes like duration_ms, query_mode and expense_count, and nothing from LiveStore internals appeared.
Measure's automatic tap tracking gave useful context too. Each gesture_click event includes the visible text of what was tapped as its label, which makes sessions easy to follow:
{ "target": "ReactViewGroup", "label": "Late-night pizza #997" } { "target": "ReactViewGroup", "label": "KA" } Those are an expense title and a member's initials. In most apps that's exactly what you want to see. In a finance app, I'd rather keep titles out. Claude Code checked the measure-android SDK to see how labels are chosen: the label is the first TextView text inside the tapped view. That made the change simple. Rows now render their text as plain views, with a transparent Pressable on top:
<View style={styles.row}> <Pressable accessibilityLabel="Expense" onPress={() => onEdit(expense.id)} style={StyleSheet.absoluteFill} /> {/* icon, title, payer, amount */} </View> The next MCP check found zero titles, amounts or names, and navigation still shows up through screen_view events.
Comparing the two modes through MCP
I also wanted Measure's own view of the numbers. Measure's natural-language agent, ask_question, wasn't available during this run, so I used the structured tools. get_span_metrics_over_time gave a reactive_update p50 of 239 ms in unoptimized mode and 21 ms in optimized mode.
get_errors showed a rough edge. The demo error is grouped as handled, but its raw event says "handled": false. It's a small mismatch, but an agent reading raw data through MCP would come to the wrong conclusion.
If you love my content ❤️ Follow me on LinkedIn
~ Kathank Raithatha







