Skip to content

Research archive · Experiment notes

Independent experiment2026

SatoriAI

Hybrid on-device + cloud LLM assistant for Android and iOS

Last updated
Aug 2026
Primary language
TypeScript

Overview

A mobile assistant that answers locally first. A quantized Gemma 3 1B (GGUF) runs on the phone through llama.rn; a rules-based router escalates harder requests to Claude or Gemini through Deno Edge Functions that normalise both providers into one SSE stream. Users can upload PDFs and ask questions over them: Gemini embeddings go into pgvector (HNSW, cosine) behind per-user row-level security, with daily cloud-spend caps and per-message token accounting.

Role
Independent experiment
Year
2026
Stack
React Native (Expo)llama.rn / llama.cppSupabase Edge FunctionsPostgreSQL + pgvectorClaude APIGemini API

The problem

Cloud LLM apps cost money on every message and stop working offline. I wanted an assistant that runs on the phone for most of the day and only reaches for a frontier model when the question needs one.

Decisions

  1. 01

    Local first, cloud on demand

    A rules-based router decides per message whether the on-device Gemma answer is enough or the request escalates to Claude or Gemini, so most chats cost nothing and work without a connection.

  2. 02

    One stream shape for every provider

    Edge Functions normalise Claude and Gemini into the same SSE format, so the client renders tokens the same way whatever produced them.

  3. 03

    Tenant isolation in the database, not the app

    Row-level security on every table and private storage buckets mean a bug in the client cannot leak another user's documents; spend caps are enforced per user, per day.

Outcome

Learning outcome: a signed Android build (v1.1.0) demonstrated the local-first model path, a normalized stream for cloud fallbacks, and server-enforced spend limits.

Status

Independent experiment; public MIT repository; Android build v1.1.0 released August 2026.

What it does

  • Quantized Gemma 3 1B runs fully on-device; no network needed for everyday chat
  • Rules-based router escalates to Claude or Gemini through Edge Functions, normalised into a single SSE stream
  • RAG over user PDFs: Gemini text-embedding-004 into pgvector with HNSW cosine search
  • Per-user row-level security on every table, private storage buckets, daily spend caps with per-message token accounting

Built with

React Native (Expo)llama.rn / llama.cppSupabase Edge FunctionsPostgreSQL + pgvectorClaude APIGemini API

Language mix

  • TypeScript93.0%
  • PLpgSQL4.7%
  • JavaScript2.4%

Sourced from the repository on GitHub.