How to Sync and Search Local Files, Databases, and Chat History

The most useful data on your computer is the hardest to search.

Your notes are in markdown files scattered across folders. Your browser history is in a SQLite database you’ve never opened. Your iMessage conversations contain decisions and links you can never find again. Your Telegram chats have technical discussions buried months deep.

macOS Spotlight doesn’t do semantic search. grep requires knowing what you’re looking for. And most search tools require uploading your data to someone else’s server.

We built a local sync tool for Nia that watches your files in real time, extracts text from databases and chat apps, and makes everything searchable - semantically and by keyword - directly from your terminal.

What Gets Indexed

The sync daemon can index several types of local data:

Files and Folders

Any folder you add gets watched for changes. Text-based files are indexed automatically:

  • Code files (all common languages)
  • Markdown, plain text, and documentation
  • Config files (YAML, JSON, TOML)
  • CSVs, TSVs, and other delimited files

Binary files are skipped.

Databases

Add a SQLite, PostgreSQL, or MySQL database and the system extracts text content from it automatically. This is how the more interesting data sources work:

iMessage - your Mac stores all iMessages in a SQLite database at ~/Library/Messages/chat.db. The sync tool reads conversations and indexes them as virtual files:

messages/John Smith/2026-03-08_12345_received.txt
messages/Jane Doe/2026-03-07_12346_sent.txt

Browser History - Safari, Chrome, and Firefox all store history in local databases. Indexed as:

history/github.com/2026-03-08_001.txt
history/stackoverflow.com/2026-03-07_002.txt

Telegram - if you use Telegram Desktop, your local database contains message history that can be indexed:

telegram/Engineering Chat/2026-03-08_msg001.txt

Any SQLite Database

Beyond the auto-detected sources, you can point it at any SQLite database. The tool extracts rows from tables and indexes them as searchable text.

How It Works

Installation

curl -fsSL https://app.trynia.ai/install-sync | bash
# or
pip install nia-sync

Adding Sources

# Add a folder
nia add ~/Documents/notes

# Add iMessage database
nia add ~/Library/Messages/chat.db

# Add a project folder
nia add ~/Projects/my-app

Real-Time Watching

Once started, the daemon watches all added sources for changes using native filesystem events (not polling). When a file changes:

  1. The daemon detects the modification within seconds
  2. Text is extracted from the changed file
  3. The file is re-chunked and re-embedded
  4. The index is updated

New files are picked up automatically. Deleted files are removed from the index.

A fallback sync runs every 10 minutes to catch anything the filesystem watcher might have missed.

Searching

Search directly from your terminal:

# Semantic search across everything
nia search "that architecture discussion from last week"

# Search only a specific folder
nia search "database migration plan" --local-folder my-notes

# Get raw results as JSON
nia search "API design patterns" --json

Results include the source file path, relevant text snippets, and enough context to find what you need.

Security: What Never Gets Indexed

This is the part that matters most for local data. The sync tool has 350+ built-in exclusion patterns that prevent sensitive files from ever being indexed:

Credentials and secrets:

  • .env, .env.local, .env.production
  • SSH keys (id_rsa, id_ed25519, *.pem, *.key)
  • Token files, credential stores, keychain exports
  • *secrets*, *credentials*, *token*

Development artifacts:

  • .git directories
  • node_modules, venv, __pycache__
  • dist/, build/, .next/
  • Lock files, compiled outputs

System files:

  • OS-level caches and temp directories
  • Application data stores
  • Binary executables

You can add custom exclusions:

# Exclude a directory pattern
nia ignore add --dir vendor

# Exclude a file extension
nia ignore add --ext .log

Credentials are stored locally with user-only permissions (mode 0600). API keys are never logged or transmitted in plaintext.

Sync Limits

To prevent runaway indexing:

LimitValue
Max files per folder5,000
Max upload per folder100 MB
Max individual file5 MB
Max database size1 GB
Max rows per table100,000

These limits exist to keep syncing fast and predictable. Most personal knowledge bases fall well within them.

Use Cases

”What was that thing I read last week?”

You read an article, discussed it in a message, and took some notes. A week later you remember the concept but not where you saw it. Search across your browser history, messages, and notes simultaneously:

nia search "that article about vector databases and hybrid search"

Searching Conversations

iMessage and Telegram don’t have good search. You know you discussed a technical decision with someone but can’t find the thread:

nia search "what did Alex say about switching to Postgres"

Code + Notes Together

Your project folder has code, your notes folder has architecture docs. Search across both:

nia search "how does the authentication middleware work"

Results come from both your source code and your notes about the source code.

AI Agent Context

If you use the Nia MCP server with Claude Code or Cursor, your AI agent can search your local files for context. Ask it to “check my notes about the API design” and it can pull from your synced folders.

Architecture

The sync daemon runs as a background process:

nia (daemon)
├── File watcher - native filesystem events
├── Source manager - 30-second refresh for new sources
├── Sync engine - extract, chunk, embed, upload
├── Heartbeat - marks daemon as online
└── Fallback sync - 10-minute full check

Each source syncs independently. A slow database extraction doesn’t block file sync.

Text extraction produces virtual files with consistent paths, so the same iMessage conversation always maps to the same searchable location. Updates are incremental - only changed or new content gets re-processed.

Getting Started

# Install
curl -fsSL https://app.trynia.ai/install-sync | bash

# Add your first source
nia add ~/Documents/notes

# Start the daemon
nia

# Search
nia search "meeting notes from Monday"

The daemon runs in the background. Add more sources as needed. Everything stays in sync automatically.

Full documentation: docs.trynia.ai


Built by Nia - a search and indexing API for AI agents.