Docs / Reference12 min readEdit on GitHub

Data model#

Illume stores everything in one Postgres database with the pgvector and pg_trgm extensions: 17 tables, defined as SQLAlchemy models in server/app/models/ and created by 37 Alembic revisions in server/alembic/versions/. This page lists every table with its columns, keys, indexes and cascades, explains the few columns whose meaning is not obvious, and lists every migration in order. It is a reference: the pages linked from each table explain how the data is produced and read.

Terms used on this page#

  • Model: a SQLAlchemy class mapped to one table.
  • Cascade: ON DELETE CASCADE on a foreign key, so deleting the parent deletes the child rows in the database itself, without the ORM loading them.
  • JSONB: Postgres's binary JSON column type.
  • Revision: one Alembic migration file. The revisions form a single linear chain; the head is e4f5a6b7c8d9.

The tables at a glance#

TableModelOne row isParentExplained in
usersUseran accountAuthentication, BYOK
repositoriesRepositoryone ingested repository of one userusersIngestion, sync
filesFilea source filerepositoriesParsing
ast_symbolsAstSymbola function, class, method, import, variable or modulefilesParsing
dependenciesDependencyan import edge between two symbolsast_symbolsThe dependency graph
commitsCommita commit from the analysed historyrepositoriesGit intelligence
pull_requestsPullRequesta merged pull requestrepositoriesGit intelligence
code_ownersCodeOwnerownership of one filefilesGit intelligence
file_cochangeFileCochangea pair of files that change togetherfilesGit intelligence
glossary_entriesGlossaryEntrya glossary termrepositoriesGeneration
onboarding_guidesOnboardingGuidethe reading order and brief of one repositoryrepositoriesGeneration
embeddingsEmbeddingone retrievable chunk and its vectorrepositoriesIndex and embeddings
conversationsConversationa chat threadusers, repositoriesChat
chat_messagesChatMessageone question and its answerconversationsChat
agent_runsAgentRunone answer run of any presetusers, repositoriesThe agent
agent_stepsAgentStepone step of a runagent_runsThe agent
mcp_tokensMcpTokena personal access token for MCP clientsusersAuthentication
push_tokensPushTokenone mobile device's push tokenusersMobile

encrypted.py is not a table: it defines EncryptedString, the column type that encrypts users.github_access_token and users.ai_api_key at rest.

Relationships#

Repository data#

erDiagram
  users ||--o{ repositories : owns
  repositories ||--o{ files : contains
  files ||--o{ ast_symbols : defines
  ast_symbols ||--o{ dependencies : "source of"
  ast_symbols ||--o{ dependencies : "target of"
  repositories ||--o{ commits : has
  repositories ||--o{ pull_requests : has
  files ||--o| code_owners : "owned per"
  files ||--o{ file_cochange : "pairs with"
  repositories ||--o{ glossary_entries : has
  ast_symbols |o--o{ glossary_entries : defines
  repositories ||--o| onboarding_guides : has
  repositories ||--o{ embeddings : indexes
  files |o--o{ embeddings : "chunked from"

Accounts, chat and runs#

erDiagram
  users ||--o{ conversations : starts
  repositories ||--o{ conversations : about
  conversations ||--o{ chat_messages : holds
  users ||--o{ chat_messages : asks
  repositories ||--o{ chat_messages : about
  users ||--o{ agent_runs : runs
  repositories ||--o{ agent_runs : about
  agent_runs ||--o{ agent_steps : records
  agent_runs |o--o| chat_messages : "saved as"
  users ||--o{ mcp_tokens : holds
  users ||--o{ push_tokens : registers

Every foreign key cascades except two SET NULL links between a run and its chat turn. Deleting a user deletes everything they own; deleting a repository deletes every row derived from it. That is what makes re-ingest (delete the repository row, recreate it with the same id) a clean slate.

Table reference#

Columns are listed as the model declares them. "PK" is the primary key; UUID primary keys default to gen_random_uuid() or a Python uuid4.

users#

ColumnTypeNotes
idUUID PK
namestringrequired
emailstringunique, indexed
passwordstring, nullbcrypt over a SHA-256 pre-hash; null for GitHub-only accounts
avatar_urlstring, null
github_idstring, nullunique
github_access_tokenencrypted, nullused to clone private repositories and call the GitHub API
created_attimestamptznow()
ai_providerstring, nullthe user's own key's provider
ai_api_keyencrypted, nullthe user's own key
ai_modelstring, null
ai_key_validated_attimestamptz, nullwhen the save-time probe last succeeded
ai_supports_toolsbool, nullnull means "not measured", distinct from false
ai_tools_checked_attimestamptz, null
ai_context_windowint, nullnull means "use the default window"
free_ingestions_usedintdefault 0
free_chat_messages_usedintdefault 0

EncryptedString encrypts with a fresh IV on every write, so equality comparisons against an encrypted column never match; only IS NULL and IS NOT NULL work. A value without the envelope prefix is a row from before encryption and is returned as is. See BYOK and encryption.

repositories#

ColumnTypeNotes
idUUID PKkept across re-ingest
repo_numberintIdentity(), unique across the table; most list and get routes key on it
user_idUUID FK userscascade
github_url, namestringrequired
default_branch, primary_languagestring, null
statusenum repo_statusdefault pending; see below
detected_stackJSONB, nulllanguages, frameworks, databases, infrastructure, CI
entry_pointsJSONB, null
architecture_summarytext, nullthe brief's narrative
ingested_branchstring, nullwith the SHA below, the "snapshot"
ingested_commit_shastring, nullthe commit the deterministic data reflects
analysis_commit_shavarchar(40), nullthe commit the LLM artefacts reflect
created_at, updated_attimestamptz
auto_update_enabledbooldefault false
auto_update_interval_hoursintdefault 6
next_sync_at, last_synced_attimestamptz, null
sync_statusvarchar(32)default idle; idle, queued, checking, updating, failed
sync_lease_expires_attimestamptz, nullthe lease that stops a killed sync locking the row forever
sync_generationUUID, nullthe claim token a sweep writes
last_sync_errortext, null
consecutive_sync_failuresintdefault 0; drives back-off
last_sync_summaryJSONB, null
share_token_hashvarchar(64), nullSHA-256 of the read-only share token; NULL means sharing is off; kept across re-ingest
shared_attimestamptz, nullwhen the current share link was minted

Index: ix_repositories_next_sync_due on next_sync_at, partial WHERE auto_update_enabled, which is what the sweep scans. ix_repositories_share_token_hash is a unique index on share_token_hash, so a token resolves to at most one repository (any number of NULL rows is allowed). See read-only share links.

The status enum drifts. The model declares pending, cloning, parsing, embedding, analyzing, ready, failed; the database type was created with scoring where the model has analyzing. Nothing writes either value, so the drift is unreachable, but assigning analyzing would fail against the real column. The pipeline writes only pending, cloning, parsing, embedding, ready and failed.

repo_number is unique across all users, not per user, despite often being described as user-scoped; every route that takes it also filters by user_id.

files#

ColumnTypeNotes
idUUID PK
repository_idUUID FKcascade
pathstringrepository-relative
language, locstring, int, null
fan_in, fan_outintdefault 0, written by compute_fan_metrics
criticalitystring, nullcritical, caution or safe
criticality_reasonsJSONB, nullthe reasons behind the label
change_frequencyfloat, null
has_testsboolwritten by the git analyzer
git_last_modifiedtimestamptz, nullwritten by the git analyzer
created_attimestamptz

Constraint uq_file_repo_path (repository_id, path) backs the parse stage's ON CONFLICT DO NOTHING. Indexes ix_files_repository_id, ix_files_path.

ast_symbols#

ColumnTypeNotes
idUUID PK
file_idUUID FK filescascade
kindenum symbol_kindfunction, class, method, import, variable, module
namestring
start_line, end_lineint, null
source_codetext, nullthe symbol's full text
cyclomatic_complexityint, null
docstringtext, null
created_attimestamptz

Indexes:

  • ix_ast_symbols_file_id and ix_ast_symbols_file_id_kind;
  • ix_ast_symbols_name_trgm and ix_ast_symbols_source_trgm, GIN trigram indexes on name and source_code, partial on kind IN ('function', 'class', 'method'). They serve fuzzy symbol lookup and grep; a query uses them only if it repeats the same kind predicate.

dependencies#

ColumnTypeNotes
idUUID PK
source_symbol_idUUID FK ast_symbolscascade
target_symbol_idUUID FK ast_symbolscascade
dep_typeenum dep_typeimports, calls, inherits, instantiates; only imports is written

uq_dependency_edge (source_symbol_id, target_symbol_id), plus an index on each end.

commits#

id, repository_id (cascade), hash, author_name, author_email, message, files_changed (int, default 0), changed_files_list (JSONB list of paths), authored_at. Constraint uq_commit_repo_hash (repository_id, hash). An earlier global unique constraint on hash alone was dropped, because two users ingesting the same repository share commit hashes.

pull_requests#

id, repository_id (cascade), number, title, description (null), author, reviewers (JSONB), files_changed, merged_at. Constraint uq_pr_repo_number (repository_id, number).

code_owners#

id, file_id (cascade, unique: one row per file), primary_owner, contributors (JSONB), bus_factor (default 0), is_knowledge_silo (default false).

file_cochange#

ColumnTypeNotes
file_a_idUUID PK, FKcascade
file_b_idUUID PK, FKcascade
repository_idUUID FKcascade
togetherintcommits touching both
a_count, b_countintcommits touching each
jaccardfloattogether / (a_count + b_count - together)

ck_file_cochange_ordered_pair enforces file_a_id < file_b_id, so each unordered pair is stored once. Indexes on repository_id and file_b_id (the primary key already covers lookups by file_a_id).

glossary_entries#

id, repository_id (cascade), symbol_id (null, cascade), name, definition, file_path (null), line_number (null).

onboarding_guides#

id, repository_id (cascade, unique: one guide per repository), reading_order (JSONB list of entries with position, tier, path, annotation and fan-in), critical_files (JSONB), architecture_brief (JSONB), pdf_path (text, unused), created_at, updated_at.

embeddings#

ColumnTypeNotes
idUUID PK
source_idUUIDthe symbol, commit, PR or file id; not a foreign key
file_idUUID FK, nullcascade
repository_idUUID FKcascade
chunk_texttextthe rendered chunk
embeddingvector(1536)text-embedding-3-small; changing the model is a migration
source_typestring enumsymbol, commit, pull_request, document, file (native_enum=False, so a check, not a type)
chunk_hashvarchar(64), nullhash of chunk_text, used by incremental embedding
search_tsvtsvectorgenerated and stored from chunk_text; deferred, so never loaded by the ORM

Indexes: ix_embeddings_repository_id, ix_embeddings_embedding_hnsw (HNSW with vector_cosine_ops), ix_embeddings_search_tsv (GIN). Constraint uq_embedding_source (repository_id, source_type, source_id). The HNSW index is declared on the model so that autogenerate does not drop it again, which is what happened to the first one. Full detail: index and embeddings.

conversations#

id, user_id (cascade), repository_id (cascade), title (text), created_at, updated_at. Index ix_conversations_user_repo_updated (user_id, repository_id, updated_at DESC), the order the sidebar lists them in.

chat_messages#

ColumnTypeNotes
idUUID PK
repository_id, user_idUUID FKcascade
conversation_idUUID FKcascade, indexed, not null
question, answertext
sourcesJSONB, nullthe citation list, so history reloads with citations
agent_run_idUUID FK, nullSET NULL when the run is deleted
created_attimestamptz
answered_commit_shastring, nullthe snapshot the answer was given against
cited_pathsJSONB, nullfiles the answer cited
stale_at, stale_paths, stale_commit_shanullwritten by a sync when cited files change

See stale answers.

agent_runs#

ColumnTypeNotes
idUUID PK
user_id, repository_idUUID FKcascade
chat_message_idUUID FK, nullSET NULL; set when the turn is saved, use_alter because the two tables point at each other
questiontext
standalone_questiontext, nullthe question rewritten without its history
presettextthe resolved preset, never auto
configJSONBthe full resolved configuration
config_hashchar(64)
prompt_version, model, decider, ingested_commit_shatext, null
statustextdefault running
stop_reason, answer, errortext, null
citationsJSONB list, null
usageJSONB, nulltoken counts
tool_calls, iterations, latency_msint, null
created_at, finished_attimestamptz

Index ix_agent_runs_user_repo_created (user_id, repository_id, created_at).

agent_steps#

id, run_id (cascade), seq (int), worker_id (null; set for planner workers), kind (text), name (text), payload (JSONB), tokens_in, tokens_out (null), latency_ms (default 0), created_at. Constraint uq_agent_steps_run_seq (run_id, seq); index ix_agent_steps_created_at, used by retention pruning.

mcp_tokens#

id, user_id (cascade, indexed), name (varchar 60), token_prefix (varchar 16, shown in the UI), token_hash (varchar 64, unique and indexed: the SHA-256 digest and the lookup path), created_at, last_used_at, expires_at, revoked_at. The token itself is never stored.

push_tokens#

id, user_id (cascade, indexed), token (unique across the table, so a device can move between accounts), platform (varchar 16, ck_push_tokens_platform allows android and ios), created_at, updated_at.

Migrations#

alembic/env.py imports all 17 model modules explicitly. A new model module must be added there, or autogenerate will not see it.

Several later revisions are hand-written and idempotent (IF NOT EXISTS, checks against pg_constraint), because the test database is migrated once per pytest-xdist worker and several workers can reach an unmigrated database at the same moment. See backend testing.

#RevisionDateWhat it does
1ec40440330d32026-04-08creates users, repositories, files, ast_symbols, dependencies, embeddings and health_metrics, and the vector extension
28cffbb1cf7352026-04-09recreates foreign keys with ON DELETE CASCADE
32ffeeb4ce9482026-04-09more cascading foreign keys
43d6ee06b4ec62026-04-10auth: adds users.email, name, password; drops username and github_id
5aff92caa271e2026-04-15creates commits, pull_requests, code_owners, glossary_entries, onboarding_guides; adds fan metrics, criticality and has_tests to files, stack, entry points, summary and repo_number to repositories, docstring to ast_symbols, source_id and source_type to embeddings
6e5f221c31fc22026-04-15adds uq_commit_repo_hash and uq_pr_repo_number
7570a9dabb5472026-04-15unique code_owners.file_id and a global unique commits.hash
8e8dffd71f0da2026-04-15adds files.git_last_modified
9b90f023a99812026-04-15reshapes embeddings.source_id, drops source_type
101c993ad52c532026-04-15re-adds embeddings.source_type
11650508da16162026-04-16changes onboarding_guides.architecture_brief to JSONB
128d8c3934e9f42026-04-17drops health_metrics and repositories.summary
136a77061118252026-04-18more cascading foreign keys
14c64d0bfafa272026-05-14re-adds users.github_id (unique) and makes password nullable, for GitHub-only accounts
15005c608e801e2026-05-28creates chat_messages
164a3abf082a582026-05-31adds commits.changed_files_list
17b4e7be529e5b2026-06-23adds repositories.ingested_branch and ingested_commit_sha
18e934fbe8247e2026-09-12drops the global unique constraint on commits.hash
19a1b2c3d4e5f62026-09-20adds uq_file_repo_path, removing existing duplicates first
204b8d6e2a97f12026-09-20creates the foreign-key indexes on files, ast_symbols, dependencies and embeddings, one per autocommit block (CREATE INDEX CONCURRENTLY)
214c5d6e7f8a012026-09-21adds embeddings.chunk_hash
225d6e7f8a01b22026-09-22auto-update columns and analysis_commit_sha on repositories; uq_dependency_edge and uq_embedding_source
23c3d4e5f6a7b82026-09-26user-key columns and free-tier counters on users
24d4e5f6a7b8c92026-10-02gives repo_number an identity generator, unless it already has a default
25e5f6a7b8c9d02026-10-04replaces the boolean free-ingestion flag with free_ingestions_used
26f6a7b8c9d0e12026-10-21creates push_tokens
27a7b8c9d0e1f22026-11-02restores the HNSW index on embeddings.embedding
28b8c9d0e1f2a32026-11-02adds ai_supports_tools and ai_tools_checked_at
29c9d0e1f2a3b42026-11-02pg_trgm, embeddings.search_tsv with its GIN index, the trigram indexes on ast_symbols, and file_cochange
30d0e1f2a3b4c52026-11-06adds users.ai_context_window
31e1f2a3b4c5d62026-11-07creates agent_runs and agent_steps; adds chat_messages.agent_run_id (NOT VALID, then validated)
32f2a3b4c5d6e72026-11-11drops agent_runs.verification, which nothing read
33a3b4c5d6e7f82026-11-11adds the staleness columns to chat_messages
34b7c8d9e0f1a22026-11-14creates mcp_tokens
35c8d9e0f1a2b32026-11-16creates conversations and attaches every existing message to one per user and repository, titled from its first question
36d9e0f1a2b3c42026-11-25encrypts every stored GitHub token and AI key with CREDENTIAL_ENCRYPTION_KEY; already-encrypted values are skipped
37e4f5a6b7c8d92026-11-29adds repositories.share_token_hash (unique index) and shared_at for read-only share links; safe to run twice

Revisions 1 to 18 are autogenerated and have no upgrade docstrings; the summaries above are from their operations. Revisions 19 onward are documented in their own docstrings.

Notable migration hazards#

  • repo_number without a generator. Revision 5 added repo_number as a plain integer NOT NULL; the autoincrement=True it passed does nothing on a non-primary-key ADD COLUMN, so a database built from migrations alone could not create a repository until revision 24. Production had been fixed by hand with a sequence default, which revision 24 detects and leaves alone.
  • The dropped HNSW index. An autogenerated revision removed the vector index because the model did not declare it. Revision 27 restored it and the model now declares it.
  • A table rewrite. Revision 29 adds a stored generated column, which rewrites embeddings under an exclusive lock; on a large table that blocks reads and writes for the duration.
  • Running migrations points at production. alembic/env.py reads SYNC_DATABASE_URL from server/.env, which in a development checkout is the production database. See changing the schema.

Design trade-offs and limits#

  • Cascades everywhere. Deletion is simple and complete, but one mistaken repository delete removes every derived row with no soft-delete or undo.
  • Polymorphic source_id. embeddings.source_id points at different tables depending on source_type and has no foreign key, so orphaned rows are possible if a source is deleted without its embedding. Most sources cascade through file_id or repository_id anyway.
  • Unused columns and values. onboarding_guides.pdf_path, the calls, inherits and instantiates edge types, and the analyzing status are declared and never written.
  • Model and database drift. The repo_status enum differs between the model and the database.
  • JSONB for structure. Reading orders, briefs, citations and stacks are JSONB, which keeps writes simple but leaves their shape to the code, not the schema.