Skip to main content

Overview

Airi uses a multi-tier storage system for persisting conversation history, user preferences, and application data. The system leverages browser storage APIs including IndexedDB for structured data and localStorage for simple key-value pairs.

Storage Architecture

Airi’s storage system is built on unstorage, a universal storage layer that supports multiple drivers:
  • Memory: Fast in-memory cache (default)
  • IndexedDB: Browser-based structured storage for conversations and data
  • LocalStorage: Key-value pairs for settings and preferences

Storage Configuration

The storage system is pre-configured with multiple mount points:

Using Storage

Basic Operations

List Keys

Batch Operations

LocalStorage Management

For reactive localStorage with automatic serialization:

Versioned Storage

Conversation Storage

While Airi doesn’t use DuckDB WASM for conversation storage (that dependency is listed but not actively used), conversations are stored in IndexedDB through the storage layer.

Storing Conversations

Retrieving Conversations

Searching Conversations

Deleting Conversations

Sync Queue (Outbox Pattern)

The outbox mount point is used for queuing operations that need to sync:

Data Export/Import

Export All Data

Import Data

Storage Monitoring

Check Storage Usage

Storage Events

Data Maintenance

Cleanup Old Data

Vacuum/Optimize

Best Practices

  1. Use Appropriate Storage: Use IndexedDB for large/structured data, localStorage for simple settings
  2. Namespace Keys: Always prefix keys with a namespace (e.g., ‘conversation:’, ‘settings:’)
  3. Handle Errors: Storage operations can fail (quota exceeded, permissions, etc.)
  4. Implement Versioning: Use versioned storage for data that may need migration
  5. Regular Cleanup: Implement periodic cleanup of old/unused data
  6. Batch Operations: Group multiple operations to reduce IndexedDB transactions
  7. Cache Strategically: Use memory cache for frequently-accessed data
  8. Monitor Quota: Check storage usage and warn users when approaching limits

Troubleshooting

Storage Quota Exceeded

IndexedDB Blocked

Data Corruption