⚡ Jarvis OS

Complete System Architecture — All 10 Phases + Phase 13 System Health Manager
① User Interface Layer
🎤 Voice Input
Whisper STT · local · offline · CPU-capable
openai/whisper
📱 Phone PWA
Glassmorphic UI · voice button · visual viewport · tap-to-correct · telemetry overlays · correction popover · Web Speech API
phone/index.html
🔊 Voice Output
Kokoro TTS · WAV chunks · Web Audio API · GainNode fade on interrupt · sub-800ms first chunk
Kokoro / Coqui
↕   ↕   ↕
② Hermes Protocol Bridge — Phone ↔ Machine
🌐 Hermes WebSocket Server
FastAPI + Uvicorn · asyncio.Queue per connection · voice · corrective_action · visual_interaction · telemetry · audio_interrupt · slowapi rate limiting · auth header · CORS locked to tunnel domain
server.py
☁️↔💻 Sync Engine
watcher.py · 30s heartbeat · local machine detection · robocopy on wake · gbrain migrate --to pglite · seamless handoff to cloud fallback
watcher.py · migrate.py
🔐 Cloudflare Tunnel
Stable public WSS URL · no port forwarding · no NAT issues · free · auto-reconnect · TLS · phone always reaches machine
cloudflared
↕   ↕   ↕
③ Gemma4 Local Brain — Always-On, Free, Private
🧠 Gemma4 26B-A4B (MoE)
Ollama · 4B active params · 18GB RAM · 256K context · native tool calling · multimodal · offline · zero API cost · fully private · Apache 2.0
gemma4:26b
⚙️ Tool Call Loop
gemma4_loop.py · user input → Gemma4 reasons → JSON tool call → dispatcher → result → loop until final answer · temperature 0.3
gemma4_loop.py
📊 System Health Manager
psutil 5-min heartbeat · CPU/RAM/disk monitoring · proactive cleanup alerts · process kill-on-idle · startup app audit · morning briefings (Phase 13)
system_monitor.py
↕   ↕   ↕
④ Orchestrator — Task Router · DAG Engine · Context Compiler
🔀 Model Router
Deterministic rule table · no LLM overhead · frontend→Gemini · backend/db→Claude · QA→GPT-5.4 · local→Gemma4 · env-var model strings · fallback chain on rate limit
router.py
📊 DAG Engine
Topological sort · dependency graph · dynamic subtask injection · FAILED_BY_USER_INTERRUPT · STALE rollback · 3-case handler · cross-agent conflict detection · git-committed on every write
dag.py
🔗 Context Compiler
compile_converged_context() · last 5 visual taps · telemetry cost snapshot · AGENTS.md state · evaluated fresh every dispatch · injected as prefix to all agent calls
context_sync.py
📈 Telemetry Dashboard
JSON log per call · timestamp · model · latency · tokens · cost USD (estimated) · RotatingFileHandler 10MB/5 files · correlation ID per DAG run · /telemetry endpoint · glassmorphic UI
telemetry.json
⟷   AGENTS.md COORDINATION BUS — each agent reads on start · writes after every task · git committed on every write · file-lock prevents concurrent writes · archived to GBrain nightly   ⟷
⑤ Specialized Agent Layer — Right Model Per Task
🎨 Frontend Agent
Components · CSS · layout · responsive design · Figma MCP · reads Backend API contract from AGENTS.md · max 3 visual verification iterations · corrective rollback on tap
gemini-3.1-pro-preview
⚙️ Backend Agent
API routes · auth · business logic · security · GitHub MCP · reads DB schema from AGENTS.md · dynamic FastAPI route loader via glob importlib · SIGTERM+drain graceful shutdown
claude-sonnet-4-6
🗄️ Database Agent
SQL migrations · RLS policies · Supabase MCP · jarvis_test schema · anon key only (never service role) · writes table contracts to AGENTS.md · schema-first in DAG
claude-sonnet-4-6
🧪 QA Agent
Playwright browser automation · test generation · screenshot diff · visual layout check · gemini-2.5-flash-lite as verifier · corrective rollback trigger · JARVIS_CI=true mock mode
gpt-5.4
↕   ↕   ↕
⑥ Tool Layer — Jarvis Hands (dispatcher.py routes all JSON tool calls)
📁 Filesystem
read_file · write_file · list_dir · search_files · move · delete · scoped per agent sandbox
filesystem.py
💻 Shell
run_command · list_processes · kill_process · cron_add · startup apps · unload_ollama · Docker via compose exec -T sandbox
shell.py
🌐 Browser
Playwright · navigate · click · extract_text · screenshot · elementFromPoint → CSS selector · persistent headless Chromium · lazy init
browser.py
📱 Native Apps
send_email · add_calendar_event · slack_message · desktop notify · Spotify · explicit permission required per tool before first use
apps.py
🎤 Sensors
transcribe_mic (Whisper) · capture_screen (PIL) · capture_cam (OpenCV) · get_location (geocoder) · brain_query · brain_write
sensors.py
↕   ↕   ↕
⑦ Memory Layer — GBrain (Persistent Knowledge Across Sessions)
🧠 GBrain Core
github.com/garrytan/gbrain · pgvector hybrid search · 29 built-in skills · self-wiring entity links · queried before every Gemma4 response · nightly gbrain dream consolidation · gbrain doctor health check
Bun runtime
☁️ Cloud Replica
Supabase Postgres · pgvector · RLS on every table · user_id scoped · jarvis_test schema · active when local machine offline · free tier 500MB
Supabase
💻 Local Replica
PGLite · activates when machine wakes · synced via gbrain migrate --to pglite · never raw file copy · zero network latency · primary when local is online
PGLite
↕   ↕   ↕
⑧ Execution Sandbox — Docker Containers Per Agent
🐳 jarvis-sandbox
Python 3.12-slim-bookworm · Playwright + Chromium · all agent runtimes · /workspace bind mount in WSL2 ext4 (not C:/ — avoids 9P slowdown) · JARVIS_SANDBOX_MODE=docker routes all shell calls here
docker-compose.yml
🟢 gbrain container
Isolated Bun server · GBrain memory endpoints · persistent volume · separate from agent runtime to avoid dependency conflicts
docker-compose.yml
🐧 WSL2 Ubuntu 24.04
Primary dev runtime · .venv_wsl · all scripts run here · project at /home/hasinrahman/jarvis (not /mnt/c/) · systemd units for prod · Podman Desktop as Docker Desktop alternative
Ubuntu-24.04
🔒 Security Hardening
WS token in Authorization header (not URL) · slowapi rate limiting · payload size caps · default_secret removed · CORS locked · env_file injection (not volume mount) · .env in .dockerignore
Phase 11
↕   ↕   ↕
⑨ Cloud Infrastructure — Fallback Only · Provider-Agnostic · All via .env
🟢 Render
OpenClaw (AlphaClaw template) · 512MB free · cloud agent fallback when local offline · $0–7/mo
Tier 1 · Free
🚂 Railway
Hermes Agent relay · WS bridge · $5 credit/mo free · same HERMES_SECRET auth · persistent sessions
Tier 1 · Free
⚡ GPU On Demand
vast.ai ~$0.30/hr A100 · RunPod serverless ~$0.00015/token · Vertex AI for Gemma4 (Google TPU advantage) · activated only when local offline
Tier 2 · As-needed
🟠 Cloudflare
Tunnel (free) · R2 file storage (no egress fees) · stable WSS URL · no port forwarding needed · Workers for edge auth
Tier 1 · Free
User Interface
Hermes Bridge
Gemma4 Brain (local, free)
Orchestrator
Agents (multi-model)
Tool Layer
GBrain Memory
Docker Sandbox
Cloud Infra (fallback)
— — — AGENTS.md coordination bus
Total estimated cloud cost: $0–12/month during development