Database Schema & Data Flow
Relevant source files
The following files were used as context for generating this wiki page:
Omi utilizes a hybrid data architecture consisting of local persistence on desktop clients and cloud-based storage via Google Firebase. The system is designed to capture, process, and retrieve user context—including screenshots, audio transcriptions, and personal memories—to power a personalized AI assistant. Data flows between local SQLite databases for immediate desktop needs and cloud-hosted Firestore and Redis instances for cross-platform synchronization and rapid caching.
Sources: desktop/macos/AGENTS.md, desktop/macos/Desktop/Sources/Providers/ChatProvider.swift:1015-1030
Local Desktop Database (SQLite)
The desktop application uses a local SQLite database (omi.db) for high-frequency data capture and offline accessibility. This database stores raw screen context, transcription segments, and proactive extractions.
Primary Local Tables
The local schema is structured to support semantic search and RAG (Retrieval-Augmented Generation) workflows directly on the client.
| Table Name | Description | Key Fields |
|---|---|---|
screenshots | Captured screen frames with OCR text | timestamp, appName, windowTitle, ocrText |
transcription_sessions | Metadata for voice recordings/conversations | startedAt, finishedAt, title, overview, emoji |
transcription_segments | Individual lines of text from recordings | sessionId, speaker, text, startTime, endTime |
memories | User facts and preferences (Primary personal source) | content, category, confidence, reasoning |
action_items | Tasks synced with backend | description, priority, completed, dueDate |
indexed_files | Metadata index of local files (~/Documents, etc.) | path, filename, fileType, modifiedAt |
Sources: desktop/macos/Desktop/Sources/Chat/ChatPrompts.swift:345-470, desktop/macos/Desktop/Sources/Providers/ChatProvider.swift:1032-1130
Local Data Relationships
The following diagram illustrates how local entities relate to provide contextual history.
Cloud Architecture & Synchronization
The Omi backend coordinates cross-platform data flow using Firestore for persistent storage and Redis for ephemeral caching.
Cloud Components
- Firestore: Serves as the primary source of truth for user profiles, synchronized conversations, and long-term memories.
- Redis: Used for rapid filtering and caching of categories (people, topics, entities) to speed up UI operations.
- Typesense: Integrated for high-performance semantic and full-text search across cloud-synced data.
Sources: desktop/macos/AGENTS.md, backend/utils/llm/chat.py:1170-1185
Data Flow: Message Persistence & Polling
Omi implements a specialized synchronization logic to prevent duplicate messages between local and remote sources.
The application uses a PendingSaveCounter to suppress polling while a local message is being persisted. This ensures that the polling loop does not fetch a "new" message that the local client just sent before the ID has been reconciled.
Sources: desktop/macos/Desktop/Sources/Providers/ChatProvider.swift:1455-1480, desktop/macos/Desktop/Sources/Providers/ChatProvider.swift:2140-2210
Memory & Context Extraction Flow
A core feature of the Omi data flow is the extraction of structured data from unstructured inputs (transcripts/text).
Extraction Pipeline
- Input: Raw transcription segments or text content.
- Normalization: Text is cleaned, and filler words are removed via
normalize_filter. - LLM Processing: The system uses prompts like
extract_memories_promptandExtractedInformationmodels to identify entities. - Storage: Extracted metadata is categorized into
people,topics,entities, anddates.
Extraction Categories
| Category | Purpose | Example |
|---|---|---|
| INTERESTING | External wisdom/advice with attribution | "Rockwell: talk to paying customers" |
| SYSTEM | Facts about the user's life/preferences | "{user_name} prefers dark roast coffee" |
| ENTITIES | Products, technologies, or locations | "OpenAI", "New York", "SwiftUI" |
Sources: backend/utils/prompts.py:102-150, backend/utils/llm/chat.py:1085-1100
User Profile Schema (Cloud)
In Firestore, data is organized under user subcollections to maintain isolation and security.
users/{uid}/conversations: Stores session data with asourcefield identifying the device (Omi, Desktop, Phone).users/{uid}/action_items: Tracks tasks across platforms.users/{uid}/memories: Stores the high-quality extracted facts mentioned in the sections above.users/{uid}/fcm_tokens: Manages notification tokens with platform prefixes (macos_,ios_).
Sources: desktop/macos/AGENTS.md
Summary
The Omi database and data flow system is designed for resilience and personalization. By maintaining a detailed local SQLite database on the desktop for intensive context capture (screenshots and voice) and syncing processed insights to the cloud, Omi provides a "second brain" that is both fast and accessible across multiple platforms. The synchronization logic meticulously manages the transition from local UUIDs to cloud server IDs to ensure a seamless chat history for the user.
Sources: desktop/macos/Desktop/Sources/Providers/ChatProvider.swift:13-50, README.md