Architecture

A deep dive into how Kairos manages state, synchronization, and agentic decision making.

Local-First Logic

The frontend (Prism) always reads from the local Appwrite database first for instant load times, then syncs in the background.

Two-Way Sync

Cortex acts as the bridge. It pulls from Google, normalizes to our schema, and pushes updates back up.

Unified Schema

Regardless of the source (Google, Outlook, etc.), all events are stored in a normalized Appwrite collection.

Data Flow

Phase 1: Read
Prism queries Appwrite DB. If data is stale, it triggers a background sync job via Cortex.
Phase 2: Sync
Cortex fetches the latest delta from Google Calendar APIs, updates the Appwrite DB, and emits a Realtime event.
Phase 3: React
Prism receives the Realtime event and instantly updates the UI without a page reload.