-
Notifications
You must be signed in to change notification settings - Fork 0
Database
Mingly uses sql.js (SQLite compiled to WebAssembly) for data persistence. This means no native modules, no compilation — it works identically on macOS and Windows.
| Mode | Location |
|---|---|
| Standalone (Electron) |
{userData}/mingly.db (OS-specific app data folder) |
| Server (Node.js) |
{MINGLY_DATA_DIR}/mingly.db (default: ./data/) |
| Column | Type | Description |
|---|---|---|
| id | TEXT PK | UUID |
| title | TEXT | Conversation title |
| provider | TEXT | LLM provider (anthropic, openai, etc.) |
| model | TEXT | Model name |
| created_at | DATETIME | Creation timestamp |
| updated_at | DATETIME | Last update timestamp |
| Column | Type | Description |
|---|---|---|
| id | TEXT PK | UUID |
| conversation_id | TEXT FK | References conversations.id |
| role | TEXT | user, assistant, system |
| content | TEXT | Message content |
| tokens | INTEGER | Token count |
| created_at | DATETIME | Timestamp |
Index: idx_messages_conversation on (conversation_id, created_at)
| Column | Type | Description |
|---|---|---|
| key | TEXT PK | Setting name |
| value | TEXT | JSON-encoded value |
| Column | Type | Description |
|---|---|---|
| id | INTEGER PK | Auto-increment |
| conversation_id | TEXT | References conversations.id |
| provider | TEXT | LLM provider |
| model | TEXT | Model name |
| input_tokens | INTEGER | Tokens sent |
| output_tokens | INTEGER | Tokens received |
| cost | REAL | Estimated cost (USD) |
| latency_ms | INTEGER | Response time |
| success | INTEGER | 1 = success, 0 = failure |
| error_message | TEXT | Error details (if failed) |
| rag_sources | TEXT | JSON array of RAG source paths |
| created_at | DATETIME | Event timestamp |
Indexes on: created_at, conversation_id, provider
Migrations are tracked via a _meta table:
CREATE TABLE IF NOT EXISTS _meta (
key TEXT PRIMARY KEY,
value TEXT
);The current migration version is stored under key schema_version. New migrations run automatically on startup when the stored version is behind the code version.
- Debounced saves: Database changes are buffered and written to disk every 100ms (configurable). This prevents excessive I/O during rapid operations like streaming token counts.
-
Auto-save on close:
closeDatabase()forces a final persist before shutdown. -
Foreign keys enabled:
PRAGMA foreign_keys = ON - Parameter binding: All queries use prepared statements to prevent SQL injection.
| Function | Purpose |
|---|---|
initializeDatabase(dataDir?) |
Load or create database, run migrations |
getDatabase() |
Get active instance (throws if not initialized) |
dbRun(sql, params) |
Execute SQL + auto-schedule save |
dbAll(sql, params) |
Query all matching rows |
dbGet(sql, params) |
Query first matching row |
closeDatabase() |
Persist and cleanup |
scheduleSave() |
Debounce disk write |
Users can export all their data via Settings > GDPR > Export. This produces a JSON file containing conversations, messages, settings, and tracking events.
Full data deletion (Settings > GDPR > Delete) removes all records and resets the database to a clean state. This is irreversible.
Back to: Home | Related: Architecture | Security
User Guide (EN)
Benutzerhandbuch (DE)
Developer