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.

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
- A reader’s question to Validate, screen for injection, rate-limit
- Validate, screen for injection, rate-limit to Postgres + pgvector on Supabase: “full-text + vector, fused”
- Postgres + pgvector on Supabase to Reranker service (Python): “candidates”
- Reranker service (Python) to OpenAI, streamed: “reordered passages”
- Postgres + pgvector on Supabase to OpenAI, streamed: “fused order on timeout”
- OpenAI, streamed to Answer in the Next.js app: “SSE, numbered citations”
- OpenAI, streamed to Trace table
- Trace table to Faithfulness check, claim by claim: “a sample, after sending”
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.
Written about it
- Defend where data changes roleI review my agents for security where data changes role. Reviews found a NaN that became LIMIT NULL and a swapped path check. Boundary-specific checks held where tested—four layers for SQL, with other boundaries still needing attack suites.12 min read
- A real mechanism is not a faster pageSix web-performance changes with real mechanisms that did not make LCP faster, one rejected wrongly, the three that worked, and an A/B protocol that can say no.16 min read
- Fallbacks that fail loudlyFallbacks should fail loudly. Five, each written for a real failure, made outages look like success. Three questions for code that answers when it can’t know.15 min read
- Grounding is a supply chainWhy my RAG system’s wrong citations started upstream of the model, in a book list, a parser, a cleaner and a request, and how I audited each.13 min read
- Memory that can’t launder a rumourFor multi-turn assistants with shared world knowledge, memory needs provenance, separate personal and world stores, and code write gates—smaller than a prompt’s promise, and only as strict as the code actually enforces.10 min read
- Localise the data layer with the UILocalisation checks the screen while the components under it still assume English. Hindi got zero passages. Why that stays quiet, and the fix measurement chose.12 min read
Built with
- TypeScript
- Next.js
- PostgreSQL
- pgvector
- Supabase
- Python
- OpenAI
- Stripe