Database and Storage - Incomplete-Infinity/eve-companion GitHub Wiki

🗄 Database and Storage

This page explains how local storage is managed in the EVE Companion App using Dexie.js for IndexedDB and electron-store for user settings and persistent config.


💾 electron-store

electron-store is a simple key-value database used for:

  • User settings and preferences
  • Auth tokens
  • Theme/mode selection
  • Recently used characters or fits

Usage

import Store from 'electron-store';

const store = new Store();
store.set('auth.token', 'abc123');
const token = store.get('auth.token');

Values are stored in JSON format under a secure app-specific path.

🔐 Avoid storing sensitive information without encryption.


🧠 Dexie.js (IndexedDB)

We use Dexie.js for structured, local database storage in the renderer process. Dexie wraps IndexedDB with a friendly async/await API.

What we store:

  • Character data (fetched from ESI)
  • Cached item and type info
  • Window positions or layouts (planned)

Example Setup

import Dexie from 'dexie';

export const db = new Dexie('EveCompanionDB');
db.version(1).stores({
  characters: 'id, name',
  inventoryTypes: 'typeId, name',
  corporations: 'id, name'
});

Usage

await db.characters.put({ id: 12345, name: 'Capsuleer One' });
const char = await db.characters.get(12345);

🧩 Integration Strategy

Layer Used For
electron-store Settings, preferences, auth data
Dexie.js Cached API responses, structured data
Zustand In-memory UI state

♻️ Caching Patterns

  • ESI responses are cached in Dexie with the ID as primary key
  • Lazy-loaded classes (like InventoryType) write to Dexie on first load
  • Cache freshness may be checked with timestamps (planned)
  • Cached items should not block re-fetching if forceReload is requested

🛑 Limitations

  • IndexedDB is not available in the main process
  • electron-store is synchronous (keep out of render-heavy paths)
  • No built-in sync with EVE — cache must be managed explicitly

📌 Summary

  • Use electron-store for settings and flags
  • Use Dexie.js for large structured game data
  • Design around lazy loading and progressive enrichment