Local Database & State Management
In Novyse, the local database is the absolute core of the application experience. The application is built from the ground up to be Offline-First, ensuring a seamless and responsive UI regardless of network availability.
Data Persistence & Single Source of Truth
While the UI is highly reactive, the Single Source of Truth for persistence is exclusively the local SQLite database.
- Persistent Home: Every piece of data received from the backend is persisted in SQLite before it is considered "received."
- No Direct API Reads: The application does not fetch data from REST APIs to render the interface; it reads from the local database or the reactive state.
Reactive UI & Zustand
To provide a "real-time" feel, Novyse does not rely solely on polling the database.
- Live Updates: When the app is in the foreground, it listens for events via Socket.io.
- Zustand Context: These incoming events are immediately processed by a Zustand store. The UI subscribes to this Zustand context for instantaneous updates without waiting for database I/O.
- Background Persistence: While Zustand handles the live UI, the Sync Engine ensures that every change is simultaneously written to the local SQLite database to guarantee data integrity.
What is Stored Locally?
The local SQLite database is organized to mirror the server's materialized state while providing additional structures for local queue management.
1. Identity & Social Graph
| Table | Description |
|---|---|
| user | Profiles for registered users including names, bios, and location. |
| bot | Automated entities with descriptions and profile picture references. |
| handle | Unique identifier lookup (e.g., @username) for users, bots, or chats. |
| member | Relational mapping of user-to-chat membership and join timestamps. |
2. Conversations & Structure
| Table | Description |
|---|---|
| chat | Core container for all conversations (DM, Group, Channel, Forum). |
| chat_type | Definition of supported conversation modes and their characteristics. |
| pinned_chat | User-specific persistent sorting and priority for the chat list. |
| chat_pin | Specific positioning data for pinned conversations. |
3. The Messaging Engine
| Table | Description |
|---|---|
| message | The primary store for all text-based and system-action content. |
| edited_message | Tracks which messages have been modified (maintains integrity). |
| deleted_message | Soft-deletion registry to synchronize removals across clients. |
| reaction_message | Stores emojis and metadata for message reactions per user. |
| pinned_message | Registry of specific messages highlighted within a chat. |
| message_reply | Handles complex threading and range-based text replies. |
| message_read | Real-time status of which users have seen specific messages. |
4. Media & Assets
| Table | Description |
|---|---|
| file | Central registry for metadata (size, mime-type, waveforms, duration). |
| message_files | Many-to-many mapping of files attached to specific messages. |
5. Persistence Queue (Offline-First Engine)
| Table | Description |
|---|---|
| pending_message | Local queue of messages waiting for network or upload completion. |
| pending_file | Temporary registry for file URIs and active S3 transfer states. |
By storing this entire relational structure locally, Novyse can recover from crashes, survive network loss, and provide a desktop-class snappy experience.