โšก Offline-First ยท Voice-First ยท Zero Cloud ยท POPIA-Compliant

An AI tutor built for
the South African reality

Runs on a Raspberry Pi 5 in a township classroom. Survives load shedding. Teaches fractions in isiZulu. Reaches parents on WhatsApp and USSD feature phones. No student devices required. No data leaves the school.

System Architecture

INPUT CHANNELS
โ”œโ”€ ๐ŸŽค Voice (Whisper.cpp) โ†’ STREAM_STT โ†’ SpeechAgent <500ms capture
โ”œโ”€ โ†’ HMAC-SHA256 verify โ†’ bus POPIA T0 gate
โ””โ”€ ๐Ÿ“ฑ USSD (Africa's Talking) โ†’ stateless *-delimited 160-char limit
 
CORE BUS
โ”œโ”€ PiBus asyncio STREAM_STT ยท STREAM_WA_INBOUND ยท STREAM_EGRA <3ms/hop
โ”‚ โ†“
โ”œโ”€ TutorAgent Qwen3 1.7B + Z3 SMT Solver + Qdrant RAG
โ”œโ”€(Ollama OK)โ”€โ”€โ†’ LLM Phrasing structured output
โ””โ”€(Ollama FAIL)โ†’ Z3 Fallback Hints โšก circuit breaker
 
MEMORY LAYER
โ”œโ”€ StudentLedger hash-chained SQLite event log tamper-evident
โ”œโ”€ pyBKT p_mastery per (student, template) Bayesian KT
โ””โ”€ EGRA Scorer Words Correct Per Minute Whisper + difflib
 
INTELLIGENCE LAYER
โ”œโ”€ Shadow Detector cosine cluster vs CAPS topics โ†’ gap report zero PII
โ””โ”€ District Dashboard Health Index ยท EGRA avg ยท mastery dist. aggregate only
 
OUTPUT
โ””โ”€ ๐Ÿ”Š Piper TTS ๐Ÿ“Š Teacher PWA ๐Ÿซ District View ๐Ÿ’พ Offline Mesh
<3s
Response Budget
0
Cloud Dependencies
141
Tests Passing
3
Input Channels
โœ“ Phase 1 โ€” Complete

Core OS โ€” The Foundation

A single Python/FastAPI process running on a Raspberry Pi 5 that orchestrates voice capture, AI tutoring, hash-chained academic records, and POPIA compliance โ€” with a Service Worker PWA for teachers, no internet required.

๐ŸšŒ

PiBus

Asyncio event bus routing messages between agents in <3ms per hop. Latency tracking enforces the 3-second end-to-end response budget.

asyncio<3ms latency
๐Ÿ›ก๏ธ

Circuit Breaker

If Ollama crashes during load shedding, the tutor instantly falls back to deterministic Z3 SMT hints. The lesson never stops.

failoverzero-downtime
๐Ÿ”‹

PiHealth Watchdog

Monitors UPS HAT and EskomSePush API. Executes SQLite WAL checkpoint and graceful shutdown before data corrupts under power failure.

UPS-awaredata-safe
๐Ÿ”’

POPIA Consent Gate

Enforces T0 / T1 / T2 data tiers at every API endpoint. Misconfigured access hits a hard 403. POPIA deletion drill completes in 0.01s.

3-tiercompliant
๐Ÿ“–

Student Ledger

Hash-chained, append-only SQLite event log. The permanent record of every tutoring session โ€” tamper-evident and fully replayable.

immutablereplayable
๐Ÿ“

OMR Grading Pipeline

OpenCV bubble-sheet grader with QR anchors and perspective warp. Teacher photographs paper; system grades instantly at 100% accuracy.

100% accuratecamera-ready
๐Ÿ“Š

Teacher PWA Dashboard

Offline-capable PicoCSS Service Worker app. Class mastery heat maps, circuit breaker status, POPIA tools, and EWS early-warning flags.

offline PWAheat map
๐Ÿ“ฅ

SA-SAMS Importer

Ingests messy SA-SAMS CSV exports, validates against the LURITS schema, and populates the school roster in seconds.

CSVLURITS-aligned
โœ“ Phase 2 โ€” Complete

Learning Engine โ€” Real Curriculum Intelligence

The tutor now reads actual DBE curriculum documents, tracks whether a student has truly mastered a concept or is still guessing, and auto-measures reading fluency to address the 81% Grade 4 reading crisis head-on.

๐Ÿง 

Qdrant RAG + Ingestor

Local vector database on the Pi. Ingests DBE Rainbow Workbooks and Siyavula textbooks via multilingual MiniLM embeddings. The tutor retrieves real curriculum paragraphs before generating any response.

vector DBcurriculum-alignedoffline
๐Ÿ“ˆ

pyBKT Mastery Tracking

Bayesian Knowledge Tracing computes p_mastery โ€” the probability a student genuinely understands a concept vs. is still guessing. Drives adaptive question selection and parent briefings.

Bayesianpredictiveadaptive
๐Ÿ“–

EGRA Auto-Measurement

Wires Whisper STT to calculate Words Correct Per Minute (WCPM) against a reference passage using difflib alignment. Automates what previously required trained assessors for every learner.

fluencyWhisperWCPM
๐Ÿšจ

Early Warning System

Flags learners showing BKT stagnation, WCPM decline, or attendance gaps. Integrates with the Teacher PWA dashboard as amber/red EWS chips โ€” visible at a glance across the entire class.

at-riskreal-timedashboard
โœ“ Phase 3 โ€” Complete

Community Channels โ€” Reaching Every Family

Three new channels extend SchoolOS beyond the classroom โ€” a WhatsApp gateway that briefs parents daily in isiZulu, a USSD menu that works on the cheapest feature phone with no data, and an offline mesh that syncs content between schools without any internet connection.

๐Ÿ” Non-Negotiable Security Constraints

Every inbound message is verified with HMAC-SHA256 before a single byte is processed. Phone numbers never appear in log files. Every outbound message to a parent first checks POPIA T0 consent is on file.

X-Turn-Signature HMAC-SHA256 hmac.compare_digest POPIA T0 gate on every send [PHONE_REDACTED] in all logs

WhatsApp Gateway

Turn.io inbound webhook with raw-body HMAC-SHA256 verification before any JSON parsing. Parents text "Report" or "Umbiko" to get their child's latest mastery and EGRA scores in isiZulu or English.

Turn.ioHMAC-SHA256bilingual
โฐ

Daily isiZulu Briefings

An asyncio scheduler fires at 17:00 every school day, generates a 2-sentence isiZulu teaching tip via Qwen3 (with a rotating static fallback pool for Ollama-down nights), and pushes it to every T0-consented parent.

17:00 dailyQwen3circuit-broken
๐Ÿ“ฑ

USSD Gateway

Stateless Africa's Talking integration. The entire session history lives in AT's accumulated text field โ€” no server memory needed. Menus: Mastery ยท Hint (Z3-first) ยท EGRA WCPM ยท isiZulu help.

Africa's Talking160-charstateless
๐Ÿ’พ

Offline Mesh โ€” Syncthing

Generates a Syncthing config.xml with global announce, relay, and cloud upgrade all disabled. Two school Pis on the same WiFi sync their curriculum folders peer-to-peer without a single packet leaving the LAN.

LAN-onlyno cloudP2P
๐Ÿ”Œ

USB Sneakernet

A teacher inserts a USB drive containing schoolos_pack.zip. The Pi verifies every file against a SHA-256 manifest before extraction, rejects zip-traversal attacks, then re-ingests curriculum into Qdrant.

SHA-256traversal-safere-ingest
๐Ÿ“ฆ

Content Packager

Exports a school's locally-created curriculum, Z3 templates, and anonymized aggregate telemetry into a signed zip for USB transfer or Syncthing distribution. No student SIDs, names, or timestamps included.

POPIA-safesignedportable
โœ“ Phase 4 โ€” Complete

Intelligence & Policy โ€” The Disruption Layer

The system now goes beyond tutoring individual students. It anonymizes and clusters everything children have asked across all channels to surface the gap between what CAPS says they should learn and what they actually need to know. Principals and DBE officials see a real-time traffic-light health index โ€” zero PII, pure policy signal.

๐Ÿ”

Shadow Curriculum Detector

Two-layer PII redaction (SA ID, cells, "igama lami ngu X") then greedy cosine centroid clustering against CAPS topic embeddings. Queries with similarity < 0.45 to any CAPS topic are shadow curriculum โ€” things learners need that the system was never designed to teach.

cosine clusteringzero PIICAPS-aligned
๐Ÿซ

District Dashboard

A read-only aggregated view for principals and DBE officials. EGRA WCPM averages, BKT mastery distributions with per-template breakdowns, weekly engagement rates, and the top shadow curriculum gap clusters โ€” all fetched live from the Pi, zero PII in any response.

aggregate onlylive dataDBE-ready
๐Ÿšฆ

School Health Index

A composite Green / Amber / Red traffic light combining EGRA WCPM (target โ‰ฅ 45), BKT mastery rate (target โ‰ฅ 70%), and weekly engagement (target โ‰ฅ 60%) using a worst-of-three policy โ€” the most conservative signal for a system built to flag problems early.

worst-of-threeDBE benchmarkspolicy-grade
Build Log

From Zero to Policy Disruption

Phase 0 โ€” Scaffold & Eval Gates

Repository structure, CI hooks, eval harness, and deployment scripts. All phase-gate tests written before any implementation.

โœ“ Complete

Phase 1 โ€” Core OS

PiBus event bus, SpeechAgent (Whisper.cpp), TutorAgent (Qwen3 + Z3), Piper TTS, POPIA 3-tier consent gate, hash-chained StudentLedger, OMR bubble-sheet grader, Teacher PWA, SA-SAMS importer, UPS watchdog.

โœ“ Complete

Phase 2 โ€” Learning Engine

Qdrant local vector DB with curriculum ingestion, multilingual MiniLM embeddings, pyBKT mastery tracking, EGRA WCPM auto-scoring via Whisper, Early Warning System flags in the Teacher PWA.

โœ“ Complete

Phase 3 โ€” Community Channels

Turn.io WhatsApp gateway (HMAC-SHA256, daily isiZulu briefings), Africa's Talking USSD (stateless, 160-char, Z3 hints on feature phones), Syncthing offline mesh (LAN-only P2P), USB sneakernet with SHA-256 manifest verification and zip-traversal protection.

โœ“ Complete

Phase 4 โ€” Intelligence & Policy

Shadow Curriculum Detector (greedy cosine clustering vs. CAPS topics, two-layer PII redaction, gap reports), District Dashboard (health index, mastery distribution, EGRA stats, shadow panel โ€” zero PII throughout), School Health Index (Green / Amber / Red, worst-of-three composite).

โœ“ Complete โ€” 141 Tests Passing

Next โ€” School Network Deployment

Multi-school Syncthing mesh with district aggregation. Federated shadow curriculum analysis across schools. One-click Windows/Linux installer for schools without Linux expertise. DBE integration pilot.

Horizon