Local-First System

Omni-AI Workstation

An Offline-First dashboard that consolidates productivity, fitness trackers, and CRM databases locally on SQLite and Drizzle ORM, connected reactively via WebSockets.

Bun.jsSQLiteDrizzle ORMWebSocketsReact

Code Specs

Bundle Size 18.5 KB
Est. LOC 2,840 lines
Deps 6 npm packages
Languages
TypeScript 65%
Javascript 25%
SQL 10%

Experiment Objective

To develop a private, low-latency station that completely decouples personal data and task schedules from cloud services through a reactive local-first architecture.

Telemetry & Metrics

≤ 1.8ms Database Read Latency
≤ 2.5ms Database Write Latency
≤ 0.4ms WebSocket Delta Latency

Live Simulator / Console

omni-ai-workstation_preview.sh
$ node run_rag_simulator.js
Loaded gemini-embedding-2 (Dimensions: 768)
Vector database initialized with 4 document chunks.
$ query --text "How much is the security deposit?"
#3
#4

Interactive terminal rendering dynamic vector states, debug feedback, and remote sandbox telemetry under resource isolation.

Environment & Runtime

Host Platform Local Host (macOS Sandbox)
Orchestrator Bun.js Native WebSockets
Engine / Language Drizzle ORM & SQLite Client
Context / Isolation Local Database Security Model

Key Features

  • Offline-First local database (workstation.db) running on Bun & Drizzle ORM.
  • Granular WebSocket sync bus using 'document_change' event payloads.
  • Unified CRM timeline consolidating WhatsApp logs, Apple Notes, and task histories.
  • Life Planning module with an interactive SVG wireframe silhouette showing body metrics.

Core Hypothesis & Outcomes

Demonstrates that local SQLite transactions with Drizzle ORM resolve in <= 2.5ms (a 99% latency reduction vs Firestore), while granular WebSocket delta broadcasts reduce message payload size by 99.7%.

Engineering Documentation

Technical Report: Project Omni-AI

Detailed analysis of the Intelligent and Decoupled Personal Workstation (Offline-First) architecture, its reactive synchronization buses, and the local micro-automation network.

1. Introduction & System Philosophy

Omni-AI is a private, self-hosted digital workstation designed to consolidate productivity, habit tracking ("Life"), client relationship management ("CRM"), and scheduled task execution in a high-performance environment.

Unlike cloud-based solutions, Omni-AI adopts an Offline-First & Local-First philosophy. The system completely decouples real-time storage and computation from external proprietary services, running natively on a local SQLite database engine and maintaining a reactive, bidirectional synchronization bus via WebSockets.

  • Absolute Privacy: Local data stored in a relational SQLite database.
  • Zero Latency: Queries resolved in microseconds or a few milliseconds.
  • Intelligent Modularity: Autonomous, isolated agents with scoped permissions.
  • Functional Aesthetics: Immersive, high-end Warm Bronze & Solar user interface.

2. Ecosystem Architecture

The system is structured into three decoupled layers that communicate asynchronously in real-time:

Client (React SPA)
React UI (Dashboard / Tabs)
localDb.jsx (Mock Firestore SDK)
↓ WebSocket / REST
Backend Server (Bun.js)
REST Endpoints & WebSocket Server
Stateful Scheduler (Cron Timers)
↓ Drizzle ORM
Local Storage
workstation.db (SQLite)
26 Relational Tables

Backend (Bun + SQLite + Drizzle ORM): The server runs on Bun.js to leverage execution speed and its ultra-fast native database client (bun:sqlite). It maps the 26 tables of the system with strict typing using Drizzle ORM, reducing data translation overhead to zero.

Frontend (React + Firestore compatibility): To maintain compatibility with components originally designed for Firebase, a compatibility layer was implemented in localDb.jsx. It exposes the exact same API as @firebase/firestore. Under the hood, mutations trigger REST calls, and reads are fed from the reactive WebSocket cache.

3. Delta Synchronization

The mass reload problem (Full Broadcast)

Initially, upon any insertion or minor change in the backend (e.g., marking a habit in the daily routine), the server broadcast the full array of the table to all clients via WebSockets. This caused redundant bandwidth consumption and performance degradation (INP).

The solution: Granular `document_change` events

We implemented an event-driven architecture where every change in SQLite via the REST API or agent scripts emits a granular WebSocket message. The client intercepts the change, locates the corresponding element in the dynamic cache memory, and updates only that specific node, forcing a re-render only on components subscribed to that record's ID.

4. Data Structure (Drizzle ORM)

The local relational database (workstation.db) features a robust relational schema of 26 tables:

settings: Key-value store for global configurations structured in JSON (alert thresholds, rate limits, system parameters).
system_telemetry: Periodic recording of telemetry and resource performance (bandwidth, latency, CPU usage, memory paging).
batch_jobs: Daily execution tracker for automated tasks and microservices with their field types and associated values.
scheduled_tasks & general_tasks: Decoupled tables to prevent overlap between internal automation tasks and general logs.

5. Core Functional Modules

5.1 CRM Module and Unified Timeline

The Omni-AI CRM is designed around the concept of a single integrated timeline. It gathers all events associated with the client into a single chronological ascending/descending feed:

  • Event logs in chat channels and notifications.
  • Handwritten notes or notes imported from local text editors.
  • History of tasks created, in progress, and completed by agents.
  • Automatic corrections and AI system interventions.

5.2 The Task Scheduler (Stateful Scheduler)

The server runs an internal scheduler upon startup that asynchronously queries the local database. It uses efficient asynchronous timers that dynamically recalibrate if a task is rescheduled or completed via the frontend UI, allowing recurrent workflows (weekly patterns) without external daemons.

5.3 Resource Telemetry and Load Balancing Module

The Resource Telemetry section features a cutting-edge visualization distributed across three functional panels. It dynamically calculates load balancing based on computational power using mathematical formulas:

CPU Load = (Active Threads × Clock Speed) / Total Capacity
Memory Usage = (Allocated Pages × Page Size) + Overhead
Bandwidth = Network Throughput / Total Traffic

Reactively extracts the latest system_telemetry record and maps cluster load and speed metrics onto the lower pedestal of the virtual SVG schematic.

6. Ecosystem Automations

Productivity in Omni-AI lies in its network of background micro-automations that eliminate operational friction from manual data entry and output:

  • System Log Ingestion: A daemon monitors local server log files, processes events using an agent that identifies critical issues, and automatically generates corrective tasks.
  • Chat Channel Analysis: Through the Synthetix agent, the system analyzes chat threads from corporate communication channels, extracts progress states, and logs them as structured entries in the CRM timeline.
  • Messaging Alerts: A bidirectional connection that autonomously reports to the chat when a critical task is completed, when there are anomalies in server metrics, or upon system status changes.

7. Performance Metrics

During local stress and compilation testing, we recorded operational metrics supporting the technical viability of the Offline-First architecture:

≤ 1.8ms SQLite Read
≤ 2.5ms Drizzle Write
≤ 0.4ms WebSocket Delta

Cloud Comparison: Average Firestore latency ranges from 80ms to 250ms. The Omni-AI architecture represents a latency reduction of up to 99%.

Sync Efficiency: Sending deltas reduced the average payload from 120 KB (full broadcast) to just 350 bytes (change node), achieving a **transfer savings of up to 99.7%**.

8. Agent Orchestration and Permissions

To guarantee system integrity and stability during the execution of intelligent AI agents, the interface enforces a strict agent separation policy based on skills:

Assigned Agent Skill / Main Focus Database Write Permissions
Aegis Telemetry & Resource Monitoring (Core) system_telemetry, batch_jobs, general_tasks
Atlas Operations & Automations Management (Workstation) general_tasks, scheduled_tasks
Synthetix CRM & Channel Synchronization (Social) contacts, notes, scheduled_tasks