Skip to content
Nelson D’SouzaEmail me

Bible study product, live

Theo Scriptura

A Bible study app whose AI answers cite the scripture and commentary they rest on, so a reader can open each passage and judge it.

what it does

  • Cites only the passages it retrieved

    Numbered markers point at the scripture and commentary found for that question.

  • Unsupported sentences land in the trace

    A sampled answer is judged sentence by sentence against the passages it cites.

  • Two searches, then a reranker

    Keyword and vector search fused in Postgres, then reordered by a cross-encoder.

  • A failed release undoes itself

    If the live domain does not serve the new build, the previous one comes back.

an answer from Ask, and its trace

Explain Romans 4

Paul explains that Abraham was counted righteous by faith1. He adds that this happened after Abraham was circumcised2.

  • Source 1ScriptureRomans 4:3

    “And Abraham believed God, and it was counted unto him for righteousness.”

  • Source 2ScriptureRomans 4:10

    “How was it then reckoned? when he was in circumcision, or in uncircumcision? Not in circumcision, but in uncircumcision.”

later, in the trace ↓

faithfulness: {
  score: 0.5,
  totalClaims: 2,
  supportedClaims: 1,
  unsupportedClaims: [
    "He adds that this happened after
     Abraham was circumcised [S2]."
  ]
}

The reader saw both sentences. The trace records which one its source does not support.

Redrawn from the answer component and the faithfulness check’s tests. The second sentence is an example of what the check flags.
Engraving of a vaulted printing shop: compositors set type from slanted cases at the left, a pressman pulls the bar of a wooden screw press at the right, printed sheets hang drying from lines overhead, and a bearded master in a long robe looks on
Its ancestor: Impressio librorum, the printing of books, Nova Reperta, c. 1600. After Jan van der Straet, published by Joannes Galle; Museum Plantin-Moretus, Public domain

The problem

People ask a Bible app the questions they would ask a pastor, and they take the answer on trust. A plain chat model invents citations with full confidence. An answer is only useful if each claim points at a passage the reader can open and judge for themselves, and if someone notices when the answers drift.

How it fits together

One question through AskArchitecture diagram with 8 nodes, 8 connections. Each step is listed as text below.A reader’s questionValidate, screen forinjection, rate-limitPostgres + pgvectoron SupabaseReranker service(Python)OpenAI, streamedAnswer in theNext.js appTrace tableFaithfulness check,claim by claimfull-text + vector,fusedcandidatesreordered passagesfused order on timeoutSSE, numberedcitationsa sample, aftersending
  1. A reader’s question to Validate, screen for injection, rate-limit
  2. Validate, screen for injection, rate-limit to Postgres + pgvector on Supabase: “full-text + vector, fused”
  3. Postgres + pgvector on Supabase to Reranker service (Python): “candidates”
  4. Reranker service (Python) to OpenAI, streamed: “reordered passages”
  5. Postgres + pgvector on Supabase to OpenAI, streamed: “fused order on timeout”
  6. OpenAI, streamed to Answer in the Next.js app: “SSE, numbered citations”
  7. OpenAI, streamed to Trace table
  8. Trace table to Faithfulness check, claim by claim: “a sample, after sending”
One question through Ask If the reranker times out, the answer goes out in fused order. The faithfulness check runs later on a sample, so a slow or failed judge never holds up a reader.

What I built

I built Ask as a retrieval system with a model at the end of it. A question is validated and screened for injection, then answered from scripture and commentary that two searches find at once, full-text and vector search in Postgres, fused with reciprocal rank fusion. A cross-encoder in a separate Python service reorders the candidates, and the answer streams to the browser over SSE with numbered citations to exactly those passages.

The reranker runs as its own service so it can scale and fail apart from the web app. That puts one more network hop on every question, and I accepted it for the better ordering.

I check answers after they are sent. Holding the stream for a full check would make every answer slow, so a tenth of live answers are sampled afterwards. Each sentence is paired with the passage it cites, a judge model says whether the passage supports it, and the score and the unsupported sentences go into that answer’s trace. The reader never sees the verdict. The check compares a sentence with the text it cites, so it cannot tell when that text was filed under the wrong label further upstream.

Around Ask is an ordinary product: a reader with cross-references, reading plans, notes, groups and Stripe billing, on Postgres in Supabase with Upstash Redis for rate limits and caching. Releases go through one script that promotes the build, smoke-tests the live domain, confirms it serves the new build, and puts the previous one back if any check fails.

How it turned out

Live at theoscriptura.com, with an Expo mobile app in development on the same backend.

80 of 80
books in the recommendation catalogue now resolve to the book they name. An audit against Open Library had found 27 of 80 pointing at the wrong one.
4,717 of 5,075
commentary passages labelled with the book and chapter they discuss, across all 66 books. Passages the parser is unsure of stay unlabelled.
Visit theoscriptura.com

Written about it

Built with

  • TypeScript
  • Next.js
  • PostgreSQL
  • pgvector
  • Supabase
  • Python
  • OpenAI
  • Stripe