# Online Ai learning with Punjab Board (PCTB)

A kid-friendly AI tutor for Punjab Board (PCTB) Classes 4–10. Students pick a class, subject and chapter; the tutor explains in everyday Roman Urdu, grounded in the official textbook, reads answers aloud and solves a photographed homework question.

- **Built by:** Paraline Tech
- **Page:** https://paralinetech.com/work/pctb-ai-learning
- **Client:** Paraline Tech
- **Category:** AI & Automation
- **Status:** Not public
- **Topics:** EdTech, AI, RAG, React, Supabase, PWA
- **Stack:** React 18, TypeScript, Vite, Tailwind, shadcn/ui, TanStack Query, Supabase, Postgres + RLS, Edge Functions (Deno), Gemini, Tesseract OCR, KaTeX
- **Last updated:** 2026-10-10

## Challenge

Students in Punjab study from PCTB textbooks but often get stuck with no patient teacher at home. Generic AI chat invents chapter content that isn't in the book, and it answers in formal English when a child needs everyday Roman Urdu.

## Approach

Ground every answer in the official textbook. We OCR'd and indexed the PCTB books, and the tutor retrieves the relevant passages before it answers — then explains them in gentle Roman Urdu, aloud if the child wants, or from a photo of their homework.

## Outcome

Grew from a Class 7 prototype to Classes 4–10. Teaching is grounded in book excerpts rather than a generic prompt, the app installs as a PWA, and a usage dashboard shows API spend and errors.

## Results

- Classes covered: 4–10
- Textbooks indexed: 53
- Chapters: ~515
- Searchable text chunks: ~17k

## Context

The Punjab Curriculum and Textbook Board (PCTB) syllabus is large, and most help a child can find online is either in formal English or not about their book at all. This is a tutor built for one audience: Pakistani students in Classes 4–10 and the parents sitting next to them.

## How it teaches

A student signs in, picks their class from a switcher shared across the app, then a subject and a chapter. From there they chat with a gentle tutor persona that explains in everyday **Roman Urdu**.

- **Grounded answers.** Each question retrieves the relevant passages from the imported textbook (retrieval-augmented generation) before the tutor replies, so it teaches what the book says rather than inventing it.
- **Read aloud.** Answers can be spoken with neural text-to-speech — Gemini first, then xAI, then the browser's own voice.
- **Homework photos.** A child can photograph a question; the image goes to private storage and the tutor works through it.
- **Maths that renders.** Formulas are typeset with KaTeX in the streamed reply.
- **Feedback.** Thumbs up and down on each answer measure quality and collect rated examples for future fine-tuning.

A question answered from the textbook

- Student PWA → Supabase Auth
- Student PWA → Edge Functions
- Edge Functions → Postgres + RLS
- Edge Functions → LLM cascade
- Edge Functions → Photo storage
- OCR + index → Postgres + RLS

## Engineering

The front end is a Vite, React and TypeScript SPA with Tailwind, shadcn/Radix and TanStack Query, installable as a PWA. Supabase provides auth (email, with optional Google), Postgres with row-level security, private storage and Deno edge functions that stream the tutor's reply over server-sent events.

The model layer is a provider cascade — Gemini, OpenRouter, Groq, xAI, Cerebras and OpenAI — configured per user in Settings with their own API keys, plus an optional self-hosted Hugging Face model. Repeated lesson turns are served from an answer cache.

The textbook pipeline is operator-run: download, Tesseract OCR, chunking, and Gemini embeddings into a vector index. The books are used only as tutoring context and are never offered as public downloads; the textbooks remain PCTB's.

React 18, TypeScript, Vite, Supabase, Postgres + RLS, Edge Functions, SSE, Gemini embeddings, Tesseract OCR, KaTeX, PWA

## Next

With enough rated question-and-answer pairs, the next step is a fine-tuned model served from the Hugging Face endpoint the app already supports.
