Self-Hosting
Database Schema
D1 database tables and indexes used by Jeremy.
Jeremy uses Cloudflare D1 (SQLite) for all persistent storage. The schema consists of authentication tables managed by Better Auth and application tables for libraries, chunks, and API keys.
These tables are managed by Better Auth and handle user accounts, sessions, and OAuth providers.
| Column | Type | Description |
|---|
id | TEXT | Primary key |
name | TEXT | Display name |
email | TEXT | Email address (unique) |
emailVerified | INTEGER | Whether the email is verified |
image | TEXT | Profile image URL |
createdAt | TEXT | Account creation timestamp |
updatedAt | TEXT | Last update timestamp |
| Column | Type | Description |
|---|
id | TEXT | Primary key |
userId | TEXT | Foreign key to user.id |
token | TEXT | Session token (unique) |
expiresAt | TEXT | Expiration timestamp |
ipAddress | TEXT | Client IP address |
userAgent | TEXT | Client user agent string |
| Column | Type | Description |
|---|
id | TEXT | Primary key |
userId | TEXT | Foreign key to user.id |
accountId | TEXT | Provider-specific account ID |
providerId | TEXT | Auth provider (e.g. github, google) |
accessToken | TEXT | OAuth access token |
refreshToken | TEXT | OAuth refresh token |
accessTokenExpiresAt | TEXT | Token expiration |
scope | TEXT | OAuth scopes |
| Column | Type | Description |
|---|
id | TEXT | Primary key |
identifier | TEXT | The identifier being verified (e.g. email) |
value | TEXT | Verification token |
expiresAt | TEXT | Expiration timestamp |
| Column | Type | Description |
|---|
id | TEXT | Primary key (user-defined ID) |
name | TEXT | Display name |
description | TEXT | Library description |
sourceUrl | TEXT | Original documentation URL |
sourceType | TEXT | Ingestion type (llms-txt or url) |
version | TEXT | Library version |
chunkCount | INTEGER | Number of documentation chunks |
ownerId | TEXT | Foreign key to user.id |
isPublic | INTEGER | Whether the library is publicly queryable |
| Column | Type | Description |
|---|
id | TEXT | Primary key |
libraryId | TEXT | Foreign key to libraries.id |
title | TEXT | Chunk title or heading |
content | TEXT | Documentation text content |
url | TEXT | Source URL for this chunk |
tokenCount | INTEGER | Approximate token count |
| Column | Type | Description |
|---|
id | TEXT | Primary key |
userId | TEXT | Foreign key to user.id |
name | TEXT | User-defined key name |
keyHash | TEXT | SHA-256 hash of the API key |
keyPrefix | TEXT | First characters of the key (e.g. jrmy_abc) |
permissions | TEXT | JSON permissions object |
lastUsedAt | TEXT | Last usage timestamp |
| Index | Table | Columns | Purpose |
|---|
idx_libraries_name | libraries | name | Fast library name lookups |
idx_chunks_library | chunks | libraryId | Fast chunk retrieval by library |
idx_api_keys_hash | apiKeys | keyHash | Fast API key authentication |
idx_api_keys_user | apiKeys | userId | List keys by user |