OiMy — System Architecture

How the iOS app, on-device model, server, and cloud LLMs work together

📱
On-Device (iPhone 16+)
1 SwiftUI Chat App (Rork)
Watercolor UI · Vintage design
Chat bubbles · Quick-action chips
Voice mic input · Typing indicator
Download screen (lazy model load)
Always present Model: lazy download
2 LiteRT-LM · Gemma 4 E4B
Downloaded once on first launch
Source: cdn.oimyai.com (3.66 GB)
Format: .litertlm (single file)
Backend: Metal GPU (iPhone)
Speed: ~25 tok/s · MTP 2.2× speedup
Context: 8,192 tokens working budget
On-device inference 3.66 GB download
3 Intent Router (Layer 1)
Runs on-device via LiteRT-LM
temp=0 · suppress thinking token
~200 token prompt · 3–5 token output
Returns: { skill_id, confidence }
81 skills · 95% accuracy (tested)
Every message, ~200ms
confidence: high / low ?
4 On-Device Storage
SwiftData / SQLite
· Chat history (rolling 6 turns in context)
· Deep Profile snapshot (compressed, ~300 tok)
· Skillify scripts (zero-token action cache)
· learnings.jsonl (entity extractions)
· Session state + pending tasks
Private · Never leaves device*

Context Assembled Per Message
system: "You are OiMy, family AI…"
profile: compressed deep profile (~300 tok)
skill: active skill instructions (~150 tok)
history: last 6 turns (~1,000 tok)
user: current message (~100 tok)
——————————————————————
Total ≈ 1,750 tok / 8,192 budget
POST /chat
skill_id +
message
response
+ entities
low conf.
escalate
tall model
response
sync
learnings
every 5min
updated
profile +
entities
🖥
Server (Hetzner · 116.203.107.13)
A Infrastructure Layer
Traefik reverse proxy · SSL termination
22 Docker containers (OpenClaw gateway)
cdn.oimyai.com → nginx · serves .litertlm
Port 18800: Management API
Hetzner ARM64 · 62 GB RAM
B Skill Engine API (oimy-skill-engine)
POST /chat · GET /health · POST /reset
Receives: { message, skill_id, user_id }
Returns: { archetype.message, entities }
Streams via SSE when available
github: aahalife/oimy-skill-engine
C Layer 2: Workflow Archetypes
Routes by skill_id to correct archetype:
⚡ Action20 skills
Skillify → 0 tokens
🫂 Coach30 skills
patpat, relationship
🎓 Expert7 skills
OT, medical
🗺 Planner10 skills
travel, meal
👁 Monitor8 skills
elder, cron triggers
👤 Profile3 skills
deep profile build
Journey workflows Lobster typed pipelines
D LLM Routing (OpenRouter)
On-device Gemma 4 E4B
Router · action skills · 60–70% of calls
Claude Sonnet 4.6
Coach · Expert · workhorse · 20–25%
Claude Opus 4
Low-confidence escalation · 5%
DeepSeek V4 Flash
Classification · extraction · bulk
E Layer 3: Memory & Learning
Neon PostgreSQL — user profiles, entities
GBrain — knowledge graph, hybrid search
SQLite — skill results, learnings.jsonl
Deep Profile — BCT matrix (1,800 rows),
  Maslow level, Hughes needs, rapport,
  belief system, formative years

Dream Cycle (nightly cron):
Entity sweep → pattern detection →
profile update → skillify new scripts
Sync ← device every 5 min Journey sessions
Message Flow — Step by Step
① USER TYPES
SwiftUI captures message · assembles context (profile + history + skill) · sends to LiteRT-LM
② ON-DEVICE ROUTE
Gemma 4 E4B classifies intent in ~200ms · returns skill_id + confidence · zero server cost
③ DECISION FORK
Action skill + codified? → Skillify script (0 tokens, 200ms). Complex/low-conf → POST to server
④ SERVER EXECUTION
Skill engine picks archetype workflow · Lobster typed pipeline · calls appropriate LLM tier
⑤ RESPONSE + LEARN
Response streams back to app · entities extracted · learnings.jsonl updated · profile synced
⑥ NIGHTLY DREAM
Cron sweeps learnings → updates knowledge graph → codifies repeated actions → deepens profile
On-device (iPhone)
Server (Hetzner)
On-device LLM (free)
Cloud LLM (paid, escalation only)
Local storage (private)
Infrastructure
* profile syncs to server every 5 min for cross-device memory
OiMy Architecture · May 2026 · oimy-skill-engine + LiteRT-LM E4B + OpenRouter