Skip to content

Database

ashim uses SQLite with Drizzle ORM for data persistence. The schema is defined in apps/api/src/db/schema.ts.

The database file lives at the path set by DB_PATH (defaults to ./data/ashim.db). In Docker, mount the /data volume to persist it across container restarts.

Tables

users

Stores user accounts. Created automatically on first run from DEFAULT_USERNAME and DEFAULT_PASSWORD.

ColumnTypeNotes
idintegerPrimary key, auto-increment
usernametextUnique, required
passwordHashtextbcrypt hash
roletextadmin or user
mustChangePasswordintegerBoolean flag for forced password reset
createdAttextISO timestamp
updatedAttextISO timestamp

sessions

Active login sessions. Each row ties a session token to a user.

ColumnTypeNotes
idtextPrimary key (session token)
userIdintegerForeign key to users.id
expiresAttextISO timestamp
createdAttextISO timestamp

teams

Groups for organizing users. Admins can assign users to teams.

ColumnTypeDescription
idtext UUIDPrimary key
nametext (unique, max 50 chars)Team name
createdAtintegerUnix timestamp

api_keys

API keys for programmatic access. The raw key is shown once on creation; only the hash is stored.

ColumnTypeNotes
idintegerPrimary key, auto-increment
userIdintegerForeign key to users.id
keyHashtextSHA-256 hash of the key
nametextUser-provided label
createdAttextISO timestamp
lastUsedAttextUpdated on each authenticated request

Keys are prefixed with si_ followed by 96 hex characters (48 random bytes).

pipelines

Saved tool chains that users create in the UI.

ColumnTypeNotes
idintegerPrimary key, auto-increment
nametextPipeline name
descriptiontextOptional description
stepstextJSON array of { toolId, settings } objects
createdAttextISO timestamp

user_files

Persistent file library with version chain tracking. Each processing step that saves a result creates a new row linked to its parent via parentId, forming a version tree.

ColumnTypeDescription
idtext UUIDPrimary key
userIdtext UUIDFK → users (CASCADE DELETE)
originalNametextOriginal upload filename
storedNametextFilename on disk
mimeTypetextMIME type
sizeintegerFile size in bytes
widthintegerImage width in px
heightintegerImage height in px
versionintegerVersion number (1 = original)
parentIdtext UUID | nullFK → user_files (parent version)
toolChaintext (JSON array)Tool IDs applied in order to produce this version
createdAtintegerUnix timestamp

jobs

Tracks processing jobs for progress reporting and cleanup.

ColumnTypeNotes
idtextPrimary key (UUID)
typetextTool or pipeline identifier
statustextqueued, processing, completed, or failed
progressreal0.0–1.0 fraction
inputFilestextJSON array of input file paths
outputPathtextPath to the result file
settingstextJSON of the tool settings used
errortextError message if failed
createdAttextISO timestamp
completedAttextISO timestamp

settings

Key-value store for server-wide settings that admins can change from the UI.

ColumnTypeNotes
keytextPrimary key
valuetextSetting value
updatedAttextISO timestamp

Migrations

Drizzle handles schema migrations. The config is in apps/api/drizzle.config.ts. During development, run:

bash
pnpm --filter @ashim/api drizzle-kit push

In production, the schema is applied automatically on startup.