Skip to documentation

Get started

Architecture

The current system design. Each diagram is sourced from the same reviewed constants that are mirrored into the internal architecture set and checked for documentation drift.

What eli.ai is

A self-hostable, knowledge-graph-grounded assistant and durable agent platform: a markdown knowledge base, an LLM-extracted entity graph with provenance, GraphRAG chat with citations, a provider-agnostic agent harness with guardrails and human-in-the-loop, evals with golden sets and drift detection, coverage and gap analysis, and client-facing graph/coverage visualizations — all multi-tenant and runnable on a laptop or a single VPS.

Process topology

Two long-lived Node processes over one Postgres (Supabase in production); local dev runs both plus a Postgres container or cluster. Not serverless.

Application process topology

One host, two processes, one database, and outbound-only provider calls.

Rendering diagram

Downloads

Concepts

  • Process topology
  • Public overview diagrams
  • Topology
  • Single host — docker compose / VPS

Keywords

  • UI + BFF · REST · MCP
  • pg-boss: queued
  • External system / MCP client
  • RLS on every tenant table
  • remote MCP · webhooks · mail
  • Browser (Next.js UI)
  • pgvector + pg_trgm
  • Bearer key
  • web process
  • worker process
  • APIs · live databases
  • validated egress
  • chat + run-reattach streams
  • connectors · enrichment · work
  • vault markdown · exports · report PDFs
  • Postgres
  • DATA_DIR
  • /api/mcp
  • starts/resumes
  • eval/report
  • 17/18
  • AI/content
  • HTTPS
Source and generation provenance

Status: current

Generated at: 2026-08-12T23:36:44.885Z

Source hash: 8143926b2d5ad8b4516e963c3801bcf78b00dcd744ab2799f5cdbb385e5efcc1

Metadata payload hash: f0506a80984eff6b1b06faea459a89004ce9c816c8d7d35779f19f6022ec97c1

Canonical appearance

src/components/docs/diagrams.ts:9 route /docs/architecture

All appearances

  • mirrordocs/architecture/public-overview-diagrams.md:27
  • canonicalsrc/components/docs/diagrams.ts:9 route /docs/architecture

Generation versions

App: eli-ai 0.1.0

Mermaid: 11.16.0 · Mermaid CLI: 11.16.0

Node: v26.3.1 · Yarn: 4.17.1

Renderer config hash: 68c10966fe84406ee626034d58bfabd555df9f65f691204b7c46db24038da101

Renderer theme hash: c80287a78d80ad63d27bd5ca348b2ef9a7e2f44da289e436be6484ea28a1b033

Adapter versions: diagramGenerator=2, drawioFlowchart=1, drawioGantt=1, drawioSequence=1, drawioState=1

Full sidecar JSON: application-process-topology-8143926b.json

  • web serves the UI, session BFF, REST and MCP routes, streams chat, queues durable agent work, and exposes database-backed run reattachment.
  • worker runs queued starts and approval continuations plus connector, enrichment, eval, drift, report, cache, and reaper jobs through pg-boss.
  • Invariant: no LLM/network/file I/O inside a database transaction — retrieve → commit → stream → short write transaction.

Tenancy & security

All 79 tenant tables carry workspace_id and are protected by Postgres FORCE ROW LEVEL SECURITY (the app role owns the tables, so plain RLS would be bypassed without FORCE). All tenant access flows through withWorkspace(), which sets a transaction-local app.workspace_id GUC; policies compare against it and fail closed (zero rows) when unset. Session routes derive workspace identity from the URL; workspace keys bind it to the key; user keys require an allowed workspace selection. Mutations additionally require a named role capability.

Tenancy and RLS

Membership check → withWorkspace → transaction-local GUC → RLS policy. Unset or mismatched context returns zero rows.

Rendering diagram

Downloads

Concepts

  • Tenancy and RLS
  • Public overview diagrams
  • Tenancy & security (load-bearing)
  • Architecture
  • Tenancy

Keywords

  • queries run under RLS
  • workspace_id = app.workspace_id?
  • membership check (role)
  • zero rows (fail closed)
  • unset / mismatch
  • Request /w/:workspaceId/…
  • withWorkspace(workspaceId, fn)
  • transaction-local
  • policy
  • rows
  • match
  • requireWorkspaceAccess(workspaceId)
Source and generation provenance

Status: current

Generated at: 2026-08-12T23:42:46.846Z

Source hash: 7eec09d714e2b4ff19bb93e99366904e9936f44b18dd2d17c224c0aba6710521

Metadata payload hash: da2480e4d98f4fa5d25c26125f94409e5db4b424d0a522a524c6351f676e9bb4

Canonical appearance

src/components/docs/diagrams.ts:25 route /docs/architecture

All appearances

  • mirrordocs/architecture/public-overview-diagrams.md:65
  • mirrordocs/architecture/README.md:109
  • canonicalsrc/components/docs/diagrams.ts:25 route /docs/architecture
  • mirrorsrc/app/(docs)/docs/concepts/tenancy/page.tsx:25 route /docs/concepts/tenancy

Generation versions

App: eli-ai 0.1.0

Mermaid: 11.16.0 · Mermaid CLI: 11.16.0

Node: v26.3.1 · Yarn: 4.17.1

Renderer config hash: 68c10966fe84406ee626034d58bfabd555df9f65f691204b7c46db24038da101

Renderer theme hash: c80287a78d80ad63d27bd5ca348b2ef9a7e2f44da289e436be6484ea28a1b033

Adapter versions: diagramGenerator=2, drawioFlowchart=1, drawioGantt=1, drawioSequence=1, drawioState=1

Full sidecar JSON: tenancy-and-rls-7eec09d7.json

A permanent CI canary seeds two workspaces and proves cross-tenant reads/writes are impossible; its catalog check asserts every workspace_id table is FORCE-RLS, so a new table cannot ship without it.

Ingestion → knowledge graph

A manual vault save is synchronous and local; its caller dispatches graph, embedding, and extraction enrichment. Connector crawls normalize and ingest each document before advancing their durable checkpoint.

Ingestion to graph

Callers commit a vault save or connector upsert, then dispatch deterministic and model-assisted enrichment; every edge converges on canonical_relations.

Rendering diagram

Downloads

Concepts

  • Ingestion to graph
  • Public overview diagrams
  • Ingestion

Keywords

  • Postgres FTS (tsvector)
  • Output.object → fallback
  • non-destructive merges → canonical_relations
  • chunk (heading-aware)
  • deterministic edges
  • embedChunks() (vector)
  • LLM per chunk
  • vault save or connector upsert
  • binary → installed extractors → markdown
  • zero-LLM entities + mentions
  • extractDocument() (worker)
  • schema-in-prompt + repair
  • typed entities + relations + evidence
  • the serve-time edge table
  • UI / API / import (text + binary) / connector
  • resolveWikilinks()
  • deriveCooccurrenceRelations()
Source and generation provenance

Status: current

Generated at: 2026-08-12T23:39:26.611Z

Source hash: f653cc712759ab5cc0c683725f9f57b99bb7d66a80802dfd9c1b0ff78d3edebf

Metadata payload hash: 66bc3c4bc3d9085fb212ef955c3330c4a4c3be306b2a112089438769e34df86f

Canonical appearance

src/components/docs/diagrams.ts:34 route /docs/architecture

All appearances

  • mirrordocs/architecture/public-overview-diagrams.md:96
  • canonicalsrc/components/docs/diagrams.ts:34 route /docs/architecture

Generation versions

App: eli-ai 0.1.0

Mermaid: 11.16.0 · Mermaid CLI: 11.16.0

Node: v26.3.1 · Yarn: 4.17.1

Renderer config hash: 68c10966fe84406ee626034d58bfabd555df9f65f691204b7c46db24038da101

Renderer theme hash: c80287a78d80ad63d27bd5ca348b2ef9a7e2f44da289e436be6484ea28a1b033

Adapter versions: diagramGenerator=2, drawioFlowchart=1, drawioGantt=1, drawioSequence=1, drawioState=1

Full sidecar JSON: ingestion-to-graph-f653cc71.json

  • Wikilinks and co-occurrence build useful model-free nodes and edges with a weak or absent LLM; they do not guarantee one connected component.
  • Extraction degrades gracefully: frontier models use native structured output; OpenAI-compatible/local models fall back to schema-in-prompt with a repair round and ontology type-normalization.
  • Merges are non-destructive pointers; canonical_relations is the only edge table read at serve time.

Retrieval & grounded chat (GraphRAG)

Query understanding feeds FTS and vector retrieval. Reciprocal-rank fusion produces visible seed concepts for graph expansion, then optional reranking and token-budgeted context assembly. The answer policy can answer, caveat, request clarification, or abstain with pointers; generated answers carry [Sn] sources.

Retrieval and grounded generation

Actor principals constrain FTS, vector, and graph candidates before ranking and context assembly; policy controls whether generation, clarification, or abstention ships.

Rendering diagram

Downloads

Concepts

  • Public overview diagrams
  • Retrieval and grounded generation
  • Retrieval

Keywords

  • query understanding
  • rewrite + constraints
  • FTS channel
  • reciprocal-rank fusion
  • graph expansion
  • optional rerank
  • answer policy
  • answer / caveat
  • clarify / abstain
  • question + actor principals
  • retrieve() with ACL predicates
  • vector channel (pgvector)
  • from visible seed concepts
  • grounded generation + citations
  • clarification or pointers
  • groundedness + conflict checks
  • Sn
Source and generation provenance

Status: current

Generated at: 2026-08-12T23:41:19.419Z

Source hash: 0c2d598391dbbb05557c4e32c1f7143c349dbc9a88193ab022041c4097e64fd5

Metadata payload hash: dba0807943492bed88bf04609f8cbfd8cd0984edbc6ea4c23e3ecbd3fb48d04a

Canonical appearance

src/components/docs/diagrams.ts:47 route /docs/architecture

All appearances

  • mirrordocs/architecture/public-overview-diagrams.md:129
  • canonicalsrc/components/docs/diagrams.ts:47 route /docs/architecture

Generation versions

App: eli-ai 0.1.0

Mermaid: 11.16.0 · Mermaid CLI: 11.16.0

Node: v26.3.1 · Yarn: 4.17.1

Renderer config hash: 68c10966fe84406ee626034d58bfabd555df9f65f691204b7c46db24038da101

Renderer theme hash: c80287a78d80ad63d27bd5ca348b2ef9a7e2f44da289e436be6484ea28a1b033

Adapter versions: diagramGenerator=2, drawioFlowchart=1, drawioGantt=1, drawioSequence=1, drawioState=1

Full sidecar JSON: retrieval-and-grounded-generation-0c2d5983.json

Semantic layer ↔ data layer

The knowledge graph extracted from documents is the semantic layer (what things mean). It binds to a data layer — scoped external data sources queried through governed, read-shaped named queries — so structured queries and explicit agent data-tool calls resolve against live data. Answers are structured and dual-cited: [Sn] document sources plus [Dn] data-call citations, each backed by a persisted data_calls provenance row.

Semantic layer to live data

Entities bind to human-governed domain components on scoped connectors; every live lookup writes provenance; structured dual-cited answers flow to the UI, /api/v1/query, and MCP clients.

Rendering diagram

Downloads

Concepts

  • Semantic data
  • Public overview diagrams
  • Semantic layer to live data

Keywords

  • structured query · MCP eli_query
  • parameterized, read-shaped SQL
  • Postgres · MySQL · Snowflake
  • explicit agent kb_data
  • documents → chunks
  • entities & concepts
  • semantic layer
  • knowledge graph
  • → named query
  • parameter map
  • external systems
  • append-only provenance
  • value snapshot + hash
  • optional per-user entitlement param
  • encrypted credentials · caps
  • entity_bindings
  • data_queries
  • data_connectors
  • data_calls
  • entity/type
  • row/time
  • /api/v1/query
  • /api/mcp
  • Sn
  • Dn
Source and generation provenance

Status: current

Generated at: 2026-08-12T23:42:12.826Z

Source hash: 5fff2e80f4ff11bf5cd12be78dbd17c174cfbe166d517224040223e53ad3fecc

Metadata payload hash: f9c4165e5b1ad0cb69efc9e4c50daecf6a76275657123874cecebabc7effe45d

Canonical appearance

src/components/docs/diagrams.ts:80 route /docs/architecture

All appearances

  • mirrordocs/architecture/public-overview-diagrams.md:164
  • canonicalsrc/components/docs/diagrams.ts:80 route /docs/architecture

Generation versions

App: eli-ai 0.1.0

Mermaid: 11.16.0 · Mermaid CLI: 11.16.0

Node: v26.3.1 · Yarn: 4.17.1

Renderer config hash: 68c10966fe84406ee626034d58bfabd555df9f65f691204b7c46db24038da101

Renderer theme hash: c80287a78d80ad63d27bd5ca348b2ef9a7e2f44da289e436be6484ea28a1b033

Adapter versions: diagramGenerator=2, drawioFlowchart=1, drawioGantt=1, drawioSequence=1, drawioState=1

Full sidecar JSON: semantic-layer-to-live-data-5fff2e80.json

  • Multi-engine via adapters: connectors speak Postgres, MySQL, and Snowflake through one adapter contract — schema discovery snapshots information_schema, previews validate identifiers against the snapshot, and an LLM can draft component SQL from it, saved only after human review through the same read-only validation.
  • Governed named queries over model-written SQL: humans author and gate the SQL templates; the model supplies validated parameters only (per-connector allowRawSql is an owner opt-in escape hatch under the same guards).
  • Read-only by construction: single-statement SELECT/WITH enforced at save and execution time; every call bounded by maxRows + timeoutMs; credentials encrypted, decrypted only at execution.
  • Natively consumable: the kb_data agent tool, POST /api/v1/query for third-party systems, and the MCP server at /api/mcp for external agents. See Semantic ↔ data layer.

Agent platform

The harness is a hand-owned loop on the Vercel AI SDK. KB tools execute in-process under RLS — the registry injects workspaceId/kbScope; the model never supplies scope, which is the tenant-isolation guarantee.

Durable agents and approvals

A single-step generateText loop: RLS-scoped tool calls, HITL suspend/resume for approvals, budget-aware graceful stop, and a deterministic citation guardrail before persisting the trace.

Rendering diagram

Downloads

Concepts

  • Public overview diagrams
  • Durable agents and approvals
  • Agent

Keywords

  • persist queued run + pg-boss job
  • execute under withWorkspace (RLS)
  • human decides via UI / API
  • worker pins agent_version + config snapshot
  • kb_search / kb_graph_query / kb_doc_read
  • SUSPEND → run_approvals (persisted)
  • UI / REST / schedule
  • tool call?
  • step loop (single-step generateText)
  • allow · deny · edit (SLA-tracked)
  • atomic decision + queued continuation
  • budget / wall-clock / cancel?
  • graceful stop: partial answer
  • deterministic citation guardrail
  • persist run + steps + output + trace
  • requiresApproval?
  • mcp:server:tool
  • yes
  • no
  • exceeded
Source and generation provenance

Status: current

Generated at: 2026-08-12T23:38:09.191Z

Source hash: 4842730b597d5f7c45229345261d6e4870836faf075d9b70110dfd957bade963

Metadata payload hash: c9037b45859a9159ab9f2e8e114fe8cc14e8f438f8c8acc960925db8592744d1

Canonical appearance

src/components/docs/diagrams.ts:62 route /docs/architecture

All appearances

  • mirrordocs/architecture/public-overview-diagrams.md:200
  • canonicalsrc/components/docs/diagrams.ts:62 route /docs/architecture

Generation versions

App: eli-ai 0.1.0

Mermaid: 11.16.0 · Mermaid CLI: 11.16.0

Node: v26.3.1 · Yarn: 4.17.1

Renderer config hash: 68c10966fe84406ee626034d58bfabd555df9f65f691204b7c46db24038da101

Renderer theme hash: c80287a78d80ad63d27bd5ca348b2ef9a7e2f44da289e436be6484ea28a1b033

Adapter versions: diagramGenerator=2, drawioFlowchart=1, drawioGantt=1, drawioSequence=1, drawioState=1

Full sidecar JSON: durable-agents-and-approvals-4842730b.json

  • Runtime: the selectable runtime is the portable, provider-agnostic harness. Anthropic model calls may use supported prompt-caching/adaptive-thinking options, but there is no separate Tier-1 or managed Tier-2 executor.
  • Durability: run state persists at every step; the worker reaper marks crash-orphaned runs interrupted; HITL suspend/resume survives restarts.
  • Exposure: the UI and the authenticated /api/v1 both drive the same harness (hashed, workspace-scoped API keys); the MCP server at /api/mcp additionally exposes the KB/graph/data tools to external agents.

Evals, coverage, and the feedback loop

Chat and agent answers collect feedback; human-approved answers are promoted into golden sets. The eval runner replays the real pipeline with deterministic checks and an LLM judge, producing per-tag metrics that overlay the coverage dashboard and drive A/B regression diffs. Scheduled drift snapshots raise alerts on orphan and churn thresholds.

Evaluation, drift, and coverage

Feedback → golden sets → eval runner → metrics, feeding both the coverage overlay and regression diffs; a document/entity signal drives the interview-next matrix.

Rendering diagram

Downloads

Concepts

  • Public overview diagrams
  • Evaluation, drift, and coverage
  • Evals

Keywords

  • chat / agent answer
  • golden sets
  • acceptance gates
  • documents + entities
  • BU × topic matrix
  • feedback (thumb/rating/correction)
  • promote → golden item (human-approved)
  • bulk catalog import (forced draft)
  • eval runner: real pipeline
  • deterministic checks + LLM judge
  • per-tag + overall metrics
  • accuracy, groundedness, citations
  • fail-closed · rollout veto
  • coverage dashboard overlay (n≥5)
  • regression diff (A/B by config)
  • interview-next (transparent)
  • scheduled drift snapshots
  • alerts (orphan/churn thresholds)
  • pass/fail
Source and generation provenance

Status: current

Generated at: 2026-08-12T23:38:35.204Z

Source hash: 56b76cf9c79d5469e2172b928435f36eb7cdc59e00d3edb88a0fe6a5e5207ce6

Metadata payload hash: 6e0df9060d338c0a88258d01ce399e759186a037f8637ab98f3e81a6f5f2fb64

Canonical appearance

src/components/docs/diagrams.ts:93 route /docs/architecture

All appearances

  • mirrordocs/architecture/public-overview-diagrams.md:241
  • canonicalsrc/components/docs/diagrams.ts:93 route /docs/architecture

Generation versions

App: eli-ai 0.1.0

Mermaid: 11.16.0 · Mermaid CLI: 11.16.0

Node: v26.3.1 · Yarn: 4.17.1

Renderer config hash: 68c10966fe84406ee626034d58bfabd555df9f65f691204b7c46db24038da101

Renderer theme hash: c80287a78d80ad63d27bd5ca348b2ef9a7e2f44da289e436be6484ea28a1b033

Adapter versions: diagramGenerator=2, drawioFlowchart=1, drawioGantt=1, drawioSequence=1, drawioState=1

Full sidecar JSON: evaluation-drift-and-coverage-56b76cf9.json

Data model

90 physical tables: 79 tenant tables under FORCE-RLS and 11 control-plane tables. The major groups:

  • Content: documents, chunks, embedding_spaces, chunk_embeddings.
  • Graph: entities, entity_aliases, relations, mentions, relation_evidence, canonical_relations, merge_log, entity_types/relation_types, extraction_runs, rejection_tombstones.
  • Conversations: conversations, messages.
  • Agents: agents, agent_versions, agent_runs, run_steps, run_approvals, guardrail_verdicts, feedback, api_keys, agent_memory, agent_proposals.
  • AI layer: ai_providers, model_slots, provider_credentials, config_snapshots, llm_calls, spend_counters, prices.
  • MCP & prompts: mcp_servers, mcp_tools, prompt_templates, fewshot_examples.
  • Evals & QA: golden_items, golden_assertions, golden_citations, golden_item_tags, eval_configs, eval_runs, eval_results, judgments, run_metrics, drift_snapshots, alerts, judge_calibration, judge_runs, qa_samples.
  • Data layer: data_connectors, data_queries, entity_bindings, data_calls — the semantic↔data layer: scoped connectors, domain components, bindings, and the append-only [Dn] provenance trail.
  • Scheduling & delivery: scheduled_jobs, webhook_endpoints, webhook_deliveries, report_snapshots, sso_providers.
  • Viz & lifecycle: graph_layout, workspace_meta, coverage_stats, workspace_exports, destruction_records.
  • Control plane (non-tenant): user, session, account, verification, organization (=workspace), member, invitation, workspace_roles, user_api_keys, sso_providers, and worker_heartbeats.

Stack

Next.js (App Router) + React + TypeScript · Postgres + pgvector + pg_trgm via Drizzle · pg-boss · Vercel AI SDK (OpenAI/Anthropic/Google/OpenAI-compatible) · Better Auth (organizations = workspaces) · shadcn/ui + Tailwind · sigma.js + graphology (WebGL graph) · shiki + mermaid (docs).

Go deeper

The concept guides break each subsystem down further — start with Tenancy & security, the load-bearing invariant, or Agents & the harness.