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