> ## Documentation Index
> Fetch the complete documentation index at: https://docs.screenpipe.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Screenpipe architecture: event-driven capture and storage

> How Screenpipe uses event-driven capture, accessibility tree extraction, OCR fallback, and SQLite storage to build a searchable local memory of your screen.

## Overview

Screenpipe is a Rust application that captures your screen and audio using an event-driven architecture, processes them locally, and stores everything in a SQLite database. Instead of recording every second, it listens for meaningful OS events and captures only when something actually changes — pairing each screenshot with accessibility tree data for maximum quality at minimal cost.

```mermaid theme={"system"}
graph LR
    subgraph trigger["event triggers"]
        E1[app switch]
        E2[click / scroll]
        E3[typing pause]
        E4[idle timer]
    end

    subgraph capture["paired capture"]
        SS[screenshot]
        A11Y[accessibility tree]
        OCR[OCR fallback]
    end

    subgraph audio["audio"]
        MIC[microphone]
        SYS[system audio]
        STT[speech-to-text]
    end

    subgraph store["storage"]
        DB[(SQLite)]
        FS[JPEG files]
    end

    subgraph serve["API · localhost:3030"]
        REST[REST API]
        MCP[MCP server]
    end

    E1 & E2 & E3 & E4 --> SS
    SS --> A11Y
    A11Y -->|empty?| OCR
    A11Y --> DB
    OCR --> DB
    SS --> FS

    MIC & SYS --> STT --> DB

    DB --> REST
    DB --> MCP
    FS --> REST

    REST --> P[scheduled tasks / AI agents]
    MCP --> AI[Claude · Cursor · etc.]
```

## Data flow

```mermaid theme={"system"}
sequenceDiagram
    participant OS as OS Events
    participant Capture
    participant A11Y as Accessibility
    participant OCR as OCR (fallback)
    participant Audio
    participant SQLite
    participant API
    participant AI

    OS->>Capture: meaningful event (click, app switch, typing pause...)
    Capture->>Capture: screenshot
    Capture->>A11Y: walk accessibility tree
    alt accessibility data available
        A11Y->>SQLite: structured text + metadata
    else accessibility empty (remote desktop, games)
        A11Y->>OCR: fallback
        OCR->>SQLite: extracted text + metadata
    end
    Capture->>SQLite: JPEG frame

    loop every 30s chunk
        Audio->>SQLite: transcription + speaker
        Audio->>SQLite: audio file
    end

    AI->>API: search query
    API->>SQLite: SQL lookup
    SQLite-->>API: results
    API-->>AI: JSON response
```

## Crates

Screenpipe is a Rust workspace with specialized crates:

```mermaid theme={"system"}
graph TD
    APP[screenpipe-app-tauri<br/><i>desktop app</i>]
    SERVER[screenpipe-server<br/><i>REST API · routes</i>]
    DB[screenpipe-db<br/><i>SQLite · types</i>]
    VISION[screenpipe-vision<br/><i>screen capture · OCR fallback</i>]
    AUDIO[screenpipe-audio<br/><i>audio capture · STT</i>]
    CORE[screenpipe-core<br/><i>scheduled tasks · config</i>]
    EVENTS[screenpipe-events<br/><i>event system</i>]
    A11Y[screenpipe-accessibility<br/><i>UI events · accessibility tree</i>]
    INT[screenpipe-integrations<br/><i>MCP · reminders</i>]

    APP --> SERVER
    SERVER --> DB
    SERVER --> VISION
    SERVER --> AUDIO
    SERVER --> CORE
    SERVER --> EVENTS
    AUDIO --> DB
    VISION --> DB
    CORE --> DB
    A11Y --> DB
    INT --> SERVER
```

## Layers

### 1. event-driven capture

Screenpipe listens for meaningful OS events instead of polling at a fixed FPS. When an event fires, it captures a screenshot and walks the accessibility tree together — same timestamp, same frame.

| Trigger | Description |
| - | - |
| **App switch** | User switched to a different application |
| **Window focus** | A new window gained focus |
| **Click / scroll** | User interacted with the UI |
| **Typing pause** | User stopped typing (debounced) |
| **Clipboard copy** | Content copied to clipboard |
| **Idle fallback** | Periodic capture every \~5s when nothing is happening |

| What | How | Crate |
| - | - | - |
| **Screen** | event-triggered screenshot of the active monitor | `screenpipe-vision` |
| **Text extraction** | Accessibility tree walk (structured text: buttons, labels, fields) | `screenpipe-accessibility` |
| **OCR fallback** | When accessibility data is empty (remote desktops, games, some Linux apps) | `screenpipe-vision` |
| **Audio** | Multiple input/output devices in configurable chunks (default 30s) | `screenpipe-audio` |

### 2. Processing

| Engine | Type | Platform | When used |
| - | - | - | - |
| Accessibility tree | Text extraction | macOS, Windows | Primary — used for every capture |
| Apple Vision | OCR | macOS | Fallback when accessibility is empty |
| Windows native | OCR | Windows | Fallback when accessibility is empty |
| Tesseract | OCR | Linux | Primary (accessibility support varies) |
| Whisper | speech-to-text | Local, all platforms | Audio transcription |
| Deepgram | speech-to-text | Cloud API | Optional cloud audio |

Additional processing: speaker identification, PII redaction, frame deduplication (skips identical frames).

### 3. Storage

All data stays local on your machine:

* **SQLite** at `~/.screenpipe/db.sqlite` — metadata, accessibility text, OCR fallback text, transcriptions, speakers, tags, UI elements
* **Media** at `~/.screenpipe/data/` — JPEG screenshots (event-driven frames), audio chunks

### 4. API

REST API on `localhost:3030`:

| Endpoint | Description |
| - | - |
| `/search` | Filtered content retrieval (accessibility, OCR fallback, audio, input) |
| `/search/keyword` | Keyword search with text positions |
| `/elements` | Lightweight UI element search (accessibility tree data) |
| `/frames/{id}` | Access captured frames |
| `/frames/{id}/context` | Accessibility text + URLs + OCR fallback for a frame |
| `/health` | System status and metrics |
| `/raw_sql` | Direct database queries |

See [API reference](/cli-reference) for the full endpoint list.

### 5. Scheduled tasks

[Scheduled tasks](/scheduled-tasks) are AI agents (`.md` prompt files) that run on your screen data. They're executed by an AI agent that reads the prompt, queries the Screenpipe API, and takes action.

Scheduled tasks live in `~/.screenpipe/pipes/{name}/` and run on cron-like schedules.

### 6. Desktop app

The desktop app is built with **Tauri** (Rust backend) + **Next.js** (React frontend):

```mermaid theme={"system"}
graph LR
    subgraph tauri["Tauri shell"]
        RS[Rust backend<br/>commands · permissions · tray]
        WV[WebView]
    end

    subgraph frontend["Next.js frontend"]
        PAGES[pages<br/>chat · timeline · settings]
        STORE[Zustand stores]
        UI[shadcn/ui components]
    end

    subgraph backend["screenpipe-server"]
        API[REST API :3030]
    end

    RS --> WV
    WV --> PAGES
    PAGES --> STORE
    STORE --> UI
    PAGES --> API
```

## Database schema

Key tables:

| Table | Stores |
| - | - |
| `frames` | Captured screen frame metadata (includes `snapshot_path`, `accessibility_text`, `capture_trigger`) plus screen text on `full_text` (accessibility text, with OCR as fallback) |
| `elements` | UI elements from accessibility tree (buttons, labels, text fields) with FTS5 search |
| `audio_chunks` | Audio recording metadata |
| `audio_transcriptions` | Text from audio |
| `speakers` | Identified speakers |
| `ui_events` | Keyboard, mouse, clipboard events |
| `tags` | user-applied tags on content |

Inspect directly:

```bash theme={"system"}
sqlite3 ~/.screenpipe/db.sqlite .schema
```

## Resource usage

Runs 24/7 on a MacBook Pro M3 (32 GB) or a \$400 Windows laptop:

| Metric | Typical value |
| - | - |
| RAM | \~600 MB |
| CPU | \~5-10% |
| Storage | \~5-10 GB/month (event-driven capture only stores frames when something changes) |

## Source code

| Component | Path |
| - | - |
| API server | [screenpipe-server/src/](https://github.com/screenpipe/screenpipe/tree/main/crates/screenpipe-server/src) |
| Screen capture | [screenpipe-vision/src/core.rs](https://github.com/screenpipe/screenpipe/blob/main/crates/screenpipe-vision/src/core.rs) |
| Audio capture | [screenpipe-audio/src/](https://github.com/screenpipe/screenpipe/tree/main/crates/screenpipe-audio/src) |
| Database | [screenpipe-db/src/db.rs](https://github.com/screenpipe/screenpipe/blob/main/crates/screenpipe-db/src/db.rs) |
| Scheduled tasks | [screenpipe-core/src/pipes/](https://github.com/screenpipe/screenpipe/tree/main/crates/screenpipe-core/src/pipes) |
| MCP server | [screenpipe-mcp/src/index.ts](https://github.com/screenpipe/screenpipe/blob/main/packages/screenpipe-mcp/src/index.ts) |
| Desktop app | [screenpipe-app-tauri/](https://github.com/screenpipe/screenpipe/tree/main/apps/screenpipe-app-tauri) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.