Overview
ondoki uses PostgreSQL 16 with the pgvector extension for vector similarity search. The database is managed via SQLAlchemy 2 (async) with Alembic for migrations.Docker Setup
The Docker Compose files use thepgvector/pgvector:pg16 image, which includes PostgreSQL 16 with pgvector pre-installed.
Connection String
The backend connects using an async connection string:asyncpg driver provides high-performance async database access.
Migrations
ondoki uses Alembic for database schema migrations.Running Migrations
Creating a New Migration
api/alembic/versions/ before applying.
Migration History
pgvector Extension
pgvector enables vector similarity search for semantic search. It’s automatically available with thepgvector/pgvector:pg16 image.
The extension is created in migrations:
How It’s Used
Theembedding table stores 1536-dimensional vectors:
If pgvector is not available, ondoki gracefully falls back to full-text search only. Semantic search will be disabled but all other features work normally.
Full-Text Search
PostgreSQL’s built-in full-text search is used viatsvector columns on:
document.search_tsvprocessrecordingsession.search_tsvprocessrecordingstep.search_tsv
Schema Overview
ondoki has 24 tables. Key tables and their purposes:| Table | Records |
|---|---|
user | User accounts |
project / project_members | Teams and roles |
document / document_version | Documents and version history |
folder | Folder hierarchy |
processrecordingsession | Workflow recordings |
processrecordingstep | Workflow steps |
processrecordingfile | Uploaded screenshots |
embedding | Vector embeddings |
knowledgesource | Knowledge base files |
auditlog | Action audit trail |
session / refreshtoken | Auth sessions |
Backups
Volume Backup
pg_dump
Restore
Performance
ondoki creates indexes on:- All foreign key columns
search_tsvcolumns (GIN index for full-text search)embeddingcolumn (for vector similarity)created_at/updated_attimestamps on frequently queried tablesshare_tokencolumns (unique index)deleted_atfor soft delete queries
External PostgreSQL
To use an external PostgreSQL instance instead of the Docker container:- Ensure PostgreSQL 16+ is installed with pgvector
- Create the database:
CREATE DATABASE ondoki; - Enable pgvector:
CREATE EXTENSION vector; - Set
DATABASE_URLto your external connection string - Remove the
dbservice from your Docker Compose file - Run migrations:
alembic upgrade head