← All selected work

Case study 03 / Applied AI · personal study tool

Study Brain

AI answers you can check against the source.

Personal tool · used daily · being rebuilt

My contribution

Designed, built and used daily: document ingestion, retrieval, model integration and the Tutor interface, all running on my own hardware.

Core stack

  • Python / FastAPI
  • Qdrant / Neo4j
  • Ollama
  • Next.js / TypeScript

The problem

I was preparing for tax exams from a large, growing library of PDFs. General-purpose chatbots gave fluent answers I couldn’t check. I built Study Brain so that every answer points back to the exact source text and page, which is what makes an AI answer usable for serious study.

System structure

A boundary worth making explicit.

FastAPI queues ingestion work. A separate worker extracts and chunks PDFs, writes their structure to Neo4j, and embeds full chunk text in Qdrant. Tutor retrieves evidence, passes it to a model and returns the answer with source metadata. The recorded REST demo was configured for local Ollama with qwen3:8b. Its two evidence items are labeled vector. Neo4j full-text search and graph enrichment exist in code, but their contribution to this answer was not separately measured.

  1. PDF → worker

    Queued job · extraction · page-aware chunks

  2. Index → retrieve

    Qdrant vectors · source text and pages

  3. Tutor → evidence

    Model response · inspectable sources

Demonstrated answer path. The worker also indexes Neo4j; this diagram does not attribute the answer to graph reasoning.

Engineering decisions

01

Move ingestion outside the request lifecycle

The API accepts a job and exposes its status; a separate worker owns extraction and index writes. PDF processing can continue independently of the initiating HTTP request. The worker writes chunk structure to Neo4j and embedded text to Qdrant; these are separate stores, not one atomic transaction.

02

Keep provenance attached to the evidence

Retrieved items retain source text, path, page range, retrieval method and score. The REST response and saved assistant history preserve that metadata for the evidence panel. Scores rank retrieval results: vector similarity can be boosted by a full-text match, so the displayed value is not an answer-confidence probability.

03

Choose models by role, with explicit fallback

A provider abstraction separates model integration from tutoring. Reasoning and extraction can select different configured model roles, with deterministic fallback to the provider default. Local Ollama is supported. The golden demo exercises one local configuration; it is not a benchmark across providers or hardware.

Verification & current state

A recorded golden-path run used a two-page synthetic PDF with deliberately unique fictional facts. The real ingestion job completed with two chunks and zero recorded errors. A REST Tutor response returned an answer and two vector evidence items. During this portfolio audit, both returned texts were independently matched verbatim to their stated PDF pages. The screenshots show the saved response and its evidence in the real browser interface.

Running it locally was the real engineering challenge. Qdrant, Neo4j and the models all compete for one machine, so I split inference between local models and cloud providers, and kept the study library in Google Drive. The verification above uses a synthetic document because the real study material stays private.

Verified on a synthetic document

An answer with evidence you can inspect.

The demo document is labeled “SYNTHETIC TEST CONTENT — NOT REAL BRAZILIAN LAW.” Every tax rule, amount and deadline in these captures is fictional. They test ingestion and provenance. The product interface is in Portuguese. The captures are from the earlier build, then named Fiscal Brain.

Recorded Tutor answer showing the fictional 17-day appeal period beside two PDF sources, pages 1 and 2, vector retrieval labels and ranking scores.
The saved answer, scrolled to the appeal passage, alongside both evidence items. Cropped from the real 1366 px browser capture; output is unchanged. Scores rank retrieved material, not answer confidence. Open the image to read it at full size.

Inspect the synthetic source PDF ↗
Inspect the recorded evidence JSON ↗