Jeremy
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.

Authentication Tables

These tables are managed by Better Auth and handle user accounts, sessions, and OAuth providers.

user

ColumnTypeDescription
idTEXTPrimary key
nameTEXTDisplay name
emailTEXTEmail address (unique)
emailVerifiedINTEGERWhether the email is verified
imageTEXTProfile image URL
createdAtTEXTAccount creation timestamp
updatedAtTEXTLast update timestamp

session

ColumnTypeDescription
idTEXTPrimary key
userIdTEXTForeign key to user.id
tokenTEXTSession token (unique)
expiresAtTEXTExpiration timestamp
ipAddressTEXTClient IP address
userAgentTEXTClient user agent string

account

ColumnTypeDescription
idTEXTPrimary key
userIdTEXTForeign key to user.id
accountIdTEXTProvider-specific account ID
providerIdTEXTAuth provider (e.g. github, google)
accessTokenTEXTOAuth access token
refreshTokenTEXTOAuth refresh token
accessTokenExpiresAtTEXTToken expiration
scopeTEXTOAuth scopes

verification

ColumnTypeDescription
idTEXTPrimary key
identifierTEXTThe identifier being verified (e.g. email)
valueTEXTVerification token
expiresAtTEXTExpiration timestamp

Application Tables

libraries

ColumnTypeDescription
idTEXTPrimary key (user-defined ID)
nameTEXTDisplay name
descriptionTEXTLibrary description
sourceUrlTEXTOriginal documentation URL
sourceTypeTEXTIngestion type (llms-txt or url)
versionTEXTLibrary version
chunkCountINTEGERNumber of documentation chunks
ownerIdTEXTForeign key to user.id
isPublicINTEGERWhether the library is publicly queryable

chunks

ColumnTypeDescription
idTEXTPrimary key
libraryIdTEXTForeign key to libraries.id
titleTEXTChunk title or heading
contentTEXTDocumentation text content
urlTEXTSource URL for this chunk
tokenCountINTEGERApproximate token count

apiKeys

ColumnTypeDescription
idTEXTPrimary key
userIdTEXTForeign key to user.id
nameTEXTUser-defined key name
keyHashTEXTSHA-256 hash of the API key
keyPrefixTEXTFirst characters of the key (e.g. jrmy_abc)
permissionsTEXTJSON permissions object
lastUsedAtTEXTLast usage timestamp

Indexes

IndexTableColumnsPurpose
idx_libraries_namelibrariesnameFast library name lookups
idx_chunks_librarychunkslibraryIdFast chunk retrieval by library
idx_api_keys_hashapiKeyskeyHashFast API key authentication
idx_api_keys_userapiKeysuserIdList keys by user