shlogg · Early preview
Ramu Narasinga @karthik-m22

Dexie Usage In Lobechat: A Singleton Instance

Lobechat uses Dexie for client-side database, a minimalistic wrapper for IndexedDB. A singleton instance of BrowserDB is created with tables for files, sessions, messages, and more.

In this article, we analyze Dexie usage in Lobechat.
If you check [database folder in lobechat, it has 2 folders:

client
server

In this Lobechat’s self-host docs, it is mentioned that LobeChat
defaults to using a client-side database (IndexedDB). That is why you have two folders, one for client and one for server.


database/client/core/db.ts imports Dexie.
Dexie is a minimalistic wrapper for indexedDB. Let’s look at a simple dexie example provided in the Getting Started tutorial.

// db.ts
import Dexie, { type EntityTable } from 'dexie';
interface Friend {
 id: number;
 name: string;
 age:...