HomeCase studiesBlueprint-Constrained AI Question Paper Generator with Syllabus...

Case study · Dubai, United Arab Emirates

Blueprint-Constrained AI Question Paper Generator with Syllabus Grounding

Curriculum Assessment Authoring

Constructing balanced exam papers manually—honoring syllabus coverage, Bloom's taxonomy cognitive levels, mark totals, and parallel-set uniqueness—consumes days of faculty effort every term. We built a blueprint-constrained AI question paper generator using Python, FastAPI, React, and PostgreSQL with pgvector. Faculty define formal exam blueprints, generate rubric-backed candidate items grounded in approved textbook chapters, verify mathematical notation in a live React editor, and export print-ready assessments alongside marking schemes.

Industry
Curriculum Assessment Authoring
Solution
A web and API curriculum assessment authoring platform built with Python, FastAPI, React, and pgvector that turns formal exam blueprints and indexed syllabus materials into moderated, print-ready question papers and answer keys.
Platforms
Web & API
Stack
Python · FastAPI · React · TypeScript · PostgreSQL · pgvector
Location
Dubai, United Arab Emirates · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Dubai, United Arab Emirates. Names withheld by agreement.

Project Overview

Academic assessment authoring operates under unforgiving structural constraints. An exam paper cannot simply contain "ten good questions"; it must satisfy exact mark distributions, cover prescribed syllabus chapters proportionally, span recall through analytical synthesis on Bloom's taxonomy, avoid repeating recent past papers, and include an unambiguous marking scheme for graders. Generic prompt boxes fail immediately on this workload because unconstrained language models invent out-of-syllabus facts, miscount marks, and repeat textbook clichés across parallel exam variants.

We engineered an AI question paper generator on Python, FastAPI, React, and PostgreSQL with pgvector. The platform pairs deterministic curriculum blueprint planning with syllabus-grounded item generation, inline LaTeX review tools, and automated assembly of print-ready papers and teacher answer keys.

Business Bottleneck

Academic departments drafting midterms, standardized mocks, and multi-set final exams faced chronic bottlenecks:

  • Manual blueprint balancing: Teachers spent hours juggling spreadsheets to ensure every unit weight, difficulty tier, and cognitive skill quota summed to exact exam totals.
  • Out-of-syllabus hallucinations: Unanchored AI drafts routinely tested notation, formulas, or theorems absent from the institution's adopted curriculum edition.
  • Parallel-set leakage and repetition: Creating Set A, Set B, and makeup exams with equivalent difficulty but distinct question stems often devolved into trivial number swaps.
  • Broken formatting before print: Copying equations and multi-part sub-questions between chat tools and word processors mangled LaTeX notation and pagination.

Architectural Strategy

We designed the system as a blueprint-first constraint pipeline wrapped around pgvector syllabus retrieval and human moderation. Rather than asking an LLM to write an entire exam paper in one shot, faculty configure a formal blueprint object in React—specifying sections, mark weights, question formats (MCQ, short structured, long analytical), chapter scopes, and Bloom levels.

FastAPI validates blueprint arithmetic deterministically, breaks the specification into discrete item slots, and queues parallel generation jobs onto Redis. Each slot worker queries PostgreSQL/pgvector for relevant approved curriculum excerpts, invokes structured JSON generation validated via Pydantic, checks semantic novelty against past-paper embeddings, and streams ready items back to the React workspace for teacher refinement and moderator lock.

Core Capabilities

  • Syllabus Ingestion & Unit Tagging: Parses PDFs and structured curriculum guides into hierarchy-aware chunks preserving headings, formulas, and learning objectives in pgvector.
  • Formal Blueprint & Parallel-Set Planner: Enforces exact mark sums, section choices, difficulty ratios, and multi-variant parity before generation starts.
  • Grounded Item & Rubric Synthesis: Produces question stems, plausible distractors with misconception notes, step-by-step worked solutions, and point-by-point marking keys simultaneously.
  • Semantic Novelty & Past-Paper Guard: Flags or regenerates candidate questions that closely resemble prior terms or sibling exam sets.
  • Dual Print Assembly: Compiles locked drafts into clean, institution-branded student question papers alongside separate moderator-only marking guides.

Technical Architecture

Uploaded syllabus documents flow through Python extraction workers that preserve mathematical blocks and section metadata before computing embeddings stored in PostgreSQL via pgvector. When an educator launches a blueprint job, FastAPI stores the immutable blueprint specification, reserves slot records, and dispatches parallel tasks to Redis-backed ARQ workers.

Flow: React Blueprint Editor → FastAPI Validator & Slot Planner → PostgreSQL + pgvector (Syllabus Chunks & History) → Redis / ARQ Workers → Structured LLM + Similarity Guard → React Moderation Studio → PDF / Answer Key Compiler

Each worker retrieves top matching curriculum chunks scoped strictly to the blueprint's unit filters, constructs a slot prompt enforcing exact mark counts and Bloom taxonomy verbs, parses the JSON response through strict Pydantic validators, and verifies that LaTeX delimiters compile cleanly. React subscribes via SSE/polling to display candidate items progressively inside a split-pane editor with instant KaTeX rendering.

Technology Stack

Category Technology detail
Authoring Frontend React + TypeScript with live KaTeX preview and blueprint builder
Backend Orchestrator Python + FastAPI with Pydantic structured output validation
Database & Vector Store PostgreSQL + pgvector indexing syllabus chunks and historical item embeddings
Async Job Queue Redis + ARQ workers running batch item generation and PDF compilation
Document Ingestion Python syllabus parser preserving chapter hierarchy, diagrams, and equations
Print & Typesetting Engine WeasyPrint / LaTeX compilation pipeline generating locked paper & key PDFs
Deduplication Guard Cosine-similarity checks against pgvector history to prevent repeat questions
Access & Exam Security Role-isolated draft vaults with watermarking and audit trails

Engineering Trade-offs & Solutions

Engineering Challenge Solution & Trade-off
Preventing whole-paper generation from dropping marks or ignoring sections Decomposed blueprints into per-slot FastAPI/ARQ jobs with Pydantic mark-sum verification; increases total LLM calls per paper slightly while guaranteeing structural accuracy.
Stopping repeat questions across Set A/B and previous semesters Ran pgvector cosine-similarity checks on candidate stems before persistence; adds minor embedding latency per item in exchange for genuine variant diversity.
Rendering complex STEM equations reliably in both browser and PDF Standardized internal item storage on Markdown + LaTeX, previewing via KaTeX in React and typesetting server-side for print; constrains arbitrary freeform layout tweaks while eliminating broken math exports.
Managing slow document parsing and PDF compilation bursts Isolated heavy PDF ingestion and WeasyPrint/LaTeX builds onto dedicated ARQ workers queued in Redis so interactive React authoring stays responsive.

Security & Reliability

Unpublished exam papers require strict pre-test confidentiality. Draft papers, blueprint allocations, and answer keys are scoped by department and exam-cycle permissions inside FastAPI so teachers outside an assigned subject team cannot view upcoming assessments. Approved final PDFs carry optional user/batch watermarks and download audit logs stored in PostgreSQL.

To protect upstream model reliability, worker jobs apply strict JSON schema retries, bounded token budgets per slot, and deterministic fallback prompts if an initial draft fails mark-count or LaTeX syntax checks—ensuring incomplete slots surface clearly for manual authoring rather than corrupting an entire exam draft.

Performance & Scale

Splitting exam generation into concurrent slot tasks over Redis/ARQ drastically cuts wall-clock wait times during peak pre-exam weeks when multiple departments assemble papers simultaneously. HNSW indexes on pgvector keep syllabus retrieval and cross-term duplicate checks fast even as institutional question banks grow across years.

In the browser, React caches parsed KaTeX fragments per item card so dragging questions between sections, swapping alternatives, or toggling answer-key previews feels instantaneous without re-typesetting unchanged blocks.

Operational Outcomes

Combining formal blueprint validation, pgvector curriculum grounding, and React moderation tooling turned exam authoring into a repeatable institutional workflow:

  • Strict syllabus fidelity: Every generated question traces back to indexed textbook sections and explicit learning objectives reviewed by subject faculty.
  • Consistent assessment balance: Automated mark arithmetic and Bloom taxonomy quotas ensure multi-section papers and parallel variants maintain comparable rigor.
  • Faster moderation cycles: Side-by-side stems, distractors, and step-by-step marking keys let department heads review and approve papers cleanly before print lock.
  • Print-ready accuracy: Standardized LaTeX-to-PDF compilation removed last-minute equation formatting defects across exam papers and grading guides.

01 — Questions

asked about this kind of project

How do you prevent generated questions from drifting outside the institution's approved syllabus?

Authors first ingest approved textbooks, lecture notes, and learning outcomes into PostgreSQL with pgvector embeddings tagged by grade, unit, and topic. Every generation prompt retrieves only matching syllabus passages and requires the model to cite source chunk IDs alongside each draft item.

How does the system guarantee an exam matches exact mark totals and Bloom's taxonomy quotas?

Before touching an LLM, a deterministic Python blueprint planner validates that section marks, question counts, and cognitive-level allocations sum cleanly. FastAPI then dispatches slot-specific generation requests and validates returned Pydantic schemas—rejecting items whose mark breakdown or question type violates the blueprint.

How do you avoid producing near-duplicate questions across Set A and Set B exam papers?

Both existing question banks and newly drafted items are embedded into pgvector. Before accepting a candidate question for a parallel exam set, the worker compares cosine similarity against prior terms and sibling sets, triggering automatic regeneration with negative examples when overlap exceeds threshold.

How are mathematical formulas, chemical equations, and structured tables rendered cleanly for print?

Candidate items store stems and solution steps in structured Markdown + LaTeX delimiters rather than raw HTML. React previews equations instantaneously via KaTeX during faculty review, while backend print workers render deterministic typographic layouts into locked PDF/DOCX bundles.

What human oversight exists before a generated question paper reaches students?

Generated drafts remain strictly in an unapproved state until a subject teacher reviews every stem, distractor, and marking rubric, makes inline edits if needed, and a department moderator signs off to lock the final version.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.