Project · Quintessence
MathStar
The fifth essence, distilled into a senior maths teacher.
Essence
For the students who use it
MathStar is an AI tutor built for high-school mathematics — South African matric, Cambridge IGCSE and A-level, IB Diploma and UK GCSE — designed to behave less like a chatbot and more like a senior teacher who happens to be available at eleven o'clock at night.
Two modes shape every interaction. In Answer mode, MathStar produces a complete worked solution, every step laid out and reasoned. In Guide mode, it refuses to give the answer at all and instead asks the questions a teacher would ask, walking the student through their own reasoning until they arrive at the answer themselves. The first mode is for checking work; the second is for actually learning.
Upload a textbook chapter or a past paper and the tutor knows your context. Submit a hand-written attempt at a past paper and the system marks it, returning an annotated image with marks awarded, deductions and corrections. A wallet/credit system keeps cost predictable for families. The goal is the quality of a senior tutor, available the moment a student is stuck.
- Answer & Guide modes — worked solutions, or Socratic questioning that walks the student through their own reasoning.
- Curriculum-aware — South African matric, Cambridge IGCSE / A-level, IB DP, UK GCSE / A-level.
- Document upload + RAG — textbook chapters and past papers are indexed automatically and used in context.
- Past-paper marking — upload a hand-written attempt, receive an annotated marked image.
- Clean mathematical typesetting — every formula rendered with KaTeX.
- Streaming responses — answers appear as they're generated; no spinner waits.
- Wallet & credit system — predictable cost per session, never a surprise bill.
- Content guardrails — topic classifiers and safety review on every interaction.
Construction
For the engineers
Stack
- Frontend
- Next.js 15 · React 19 · TypeScript · KaTeX
- API
- ASP.NET Core 10 minimal API on .NET 10
- Admin
- Blazor Server (16-page management dashboard)
- Database
- SQL Server 2025 — with the new
VECTORdata type for embeddings - AI
- Google Vertex AI · Cloud Vision · Document AI
- Imaging
- SkiaSharp for annotated marked-paper rendering
- Data access
- Dapper · resilience via Polly
- Testing
- xUnit integration tests via
WebApplicationFactory
Architecture
Clean, layered, interface-first. Domain → Application → Infrastructure → Data → API.
Every external boundary is behind an interface, so the test rig can substitute fakes for Vertex,
Cloud Vision, Document AI or SQL Server without ceremony. Public APIs return
Result<T> rather than throw; exceptions are reserved for genuine, exceptional failure.
No-magic configuration. Every behavioural setting — tutoring tone, model selection, safety thresholds, credit pricing — lives in the database and is editable at runtime through the Blazor admin. Changing how the tutor speaks does not require a redeploy. This is essential for a system whose quality has to be tuned daily.
Three-tier cache against Vertex spend. Each question is served by walking three caches
in order. First, a precomputed answer table — verified solutions for known past-paper questions.
Second, a fuzzy semantic match against previously answered, near-equivalent questions using the
SQL Server 2025 VECTOR column. Third, Vertex CachedContent for prompt-prefix
reuse, so generation calls only carry the delta. Together these reduce per-question Vertex cost
dramatically and tighten latency for the most common queries.
Safety-first content path. A topic classifier and content guardrails filter both inbound queries and generated output. A sampled human-review queue inspects a slice of each day's traffic so quality drift is caught before students see it. A nightly evaluation harness runs a fixed corpus against the current configuration and reports regressions against the baseline.
Notable details
- SQL Server 2025
VECTORcolumn stores question embeddings for fuzzy match without a sidecar vector store. - Document AI extracts text and structure from uploaded textbook chapters and past-paper PDFs.
- Cloud Vision parses hand-written student work as the input to the marking flow.
- SkiaSharp renders the marked paper server-side and returns an annotated image.
- Polly retries Vertex calls with exponential back-off; circuit breaker isolates a degraded model.
- Server-Sent Events stream tokens for sub-second time-to-first-glyph.
- Nightly evaluation harness runs a fixed test corpus and reports against the previous baseline.
- Wallet / credits model meters API spend per student; never surprises a parent.