How vinayak28x/aqpg works
1. Overall shape
AQPG is a two-tier, fully local application: a React frontend for the workflow UI and a FastAPI backend that owns all document processing, semantic matching, and question generation. There is no separate cloud service layer; the backend is the system of record for the generated exam pipeline.
2. User workflow boundary
The architecture is organized around a linear exam-authoring flow: upload syllabus PDF, upload textbook PDF, run semantic mapping, configure exam pattern, then generate questions. Each step is exposed in the UI as a separate stage and in the backend as a separate API responsibility.
3. Frontend subsystem
The frontend lives in frontend/src and is composed of discrete UI components: SyllabusUpload, TextbookUpload, SemanticMapping, PatternConfig, GeneratedQuestions, and a Stepper for orchestration. This suggests a stateful wizard-style interface rather than a general-purpose single-page app.
4. Backend application structure
The backend is a modular FastAPI app under backend/app, with factory.py for app construction and main.py as the server entry point. The structure is split into API routers, services, models, core config, and utility modules, which keeps request handling separate from business logic.
5. API layer
The backend/app/api package contains endpoint groups for syllabus, textbook, mapping, and questions. This indicates four main API domains: ingest syllabus files, ingest textbook files, compute mappings, and generate the final question paper.
6. Ingestion and document preprocessing
The ingestion path is handled by ingestion_service.py plus PDF/image utilities. pdf_utils.py and image_utils.py imply the backend can extract text and likely handle scanned or image-based PDF content as part of preprocessing before any AI work begins.
7. Text normalization and chunking
chunking_service.py is a distinct layer between raw textbook extraction and semantic analysis. Its role is to break large textbook content into context-preserving chunks so downstream embedding and retrieval work on manageable units instead of whole documents.
8. Syllabus parsing and topic model
syllabus_service.py and the Pydantic schemas in models/schemas.py define the structured representation of syllabus modules, headings, or topics. This is the canonical syllabus object used later for mapping and question generation.
9. Semantic mapping subsystem
mapping_service.py uses local sentence embeddings via sentence-transformers/all-MiniLM-L6-v2 to compare syllabus topics against textbook chunks. The output is a relevance mapping that links each syllabus item to the most applicable textbook context, forming the bridge between curriculum and source material.
10. Question generation subsystem
question_service.py and bloom_service.py coordinate question synthesis using the mapped textbook context, the selected marks pattern, and a Bloom’s Taxonomy target level. The README indicates the generator is a local google/flan-t5-base model, so question creation is an offline LLM step constrained by exam structure.
11. Configuration and model boundaries
backend/app/core/config.py centralizes runtime settings such as model paths and environment-specific configuration. This is important because the system can run either with automatic Hugging Face downloads or with manually placed local model files for offline deployment.
12. Data flow end-to-end
The core backend flow is: PDF upload → extraction/chunking → syllabus structuring → semantic similarity mapping → exam pattern definition → prompt/context assembly → question generation → response back to the UI. The major architectural boundary is that all sensitive content stays inside the local backend and never leaves the machine.
13. Deployment/runtime profile
The backend runs as Uvicorn-hosted FastAPI on Python 3.9+, while the frontend runs with the React development server on Node 18+. Heavy ML dependencies are isolated in a Python virtual environment, reflecting that inference and document processing are intentionally separated from the browser layer.
14. Repository emphasis
The large documentation set under docs/ suggests the project is heavily oriented around explaining models, prompts, and generated outputs rather than integrating external systems. Architecturally, this is a local AI pipeline with a thin UI wrapper, not an enterprise multi-service platform.
Main entry points: Stepper.js Stepper · factory.py App factory · ingestion_service.py Ingestion · question_service.py Question service
Components 25
Frontend
React wizard UI for the linear exam-authoring flow
- Entry · Browser bootstrap for the frontend app
frontend/src/index.js - App shell · Top-level frontend container and state orchestration
frontend/src/App.js - Stepper · Drives the sequential exam-authoring stages
frontend/src/components/Stepper.js - Syllabus upload · Collects syllabus PDF input from the user
frontend/src/components/SyllabusUpload.js - Textbook upload · Collects textbook PDF input from the user
frontend/src/components/TextbookUpload.js - Semantic mapping · Displays syllabus-to-textbook relevance output
frontend/src/components/SemanticMapping.js - Pattern config · Configures marks distribution and exam structure
frontend/src/components/PatternConfig.js - Generated questions · Shows the final generated question paper
frontend/src/components/GeneratedQuestions.js
Backend
FastAPI application for ingestion, mapping, and question generation
- Server entry · Uvicorn-facing backend startup point
backend/main.py - App factory · Constructs and wires the FastAPI application
backend/app/factory.py - Config · Central runtime settings and model paths
backend/app/core/config.py - Syllabus API · Routes for syllabus upload and parsing
backend/app/api/syllabus.py - Textbook API · Routes for textbook upload and preprocessing
backend/app/api/textbook.py - Mapping API · Routes for semantic matching
backend/app/api/mapping.py - Questions API · Routes for exam generation
backend/app/api/questions.py - Ingestion · Coordinates document intake and extraction
backend/app/services/ingestion_service.py - PDF utils · Extracts text and structure from PDF content
backend/app/utils/pdf_utils.py - Image utils · Handles scanned or image-based content preprocessing
backend/app/utils/image_utils.py - Chunking · Breaks extracted textbook content into manageable chunks
backend/app/services/chunking_service.py - Syllabus service · Structures syllabus topics and headings
backend/app/services/syllabus_service.py - Schemas · Canonical data models for syllabus, mapping, and questions
backend/app/models/schemas.py - Mapping service · Computes syllabus-to-textbook relevance with local sentence embeddings
backend/app/services/mapping_service.py - Bloom service · Applies Bloom’s taxonomy level selection and alignment
backend/app/services/bloom_service.py - Question service · Assembles context and produces final exam questions
backend/app/services/question_service.py
Docs
Repository documentation and model guides
- Docs bundle · Guides, model notes, prompts, and reference material
docs/README_DOCUMENTATION_INDEX.md
Connections 31
- Entry → App shell: boots · Browser entry mounts the app shell
- App shell → Stepper: orchestrates · Main UI coordinates the wizard stages
- Stepper → Syllabus upload: stage 1 · Syllabus upload is the first step
- Stepper → Textbook upload: stage 2 · Textbook upload follows syllabus intake
- Stepper → Semantic mapping: stage 3 · Mapping results appear after backend matching
- Stepper → Pattern config: stage 4 · Pattern configuration sets the exam structure
- Stepper → Generated questions: stage 5 · Generated questions are the final output
- Server entry → App factory: boots · Server entry creates the FastAPI app
- App factory → Config: loads · Application wiring reads runtime configuration
- App factory → Syllabus API: mounts · Registers syllabus endpoints
- App factory → Textbook API: mounts · Registers textbook endpoints
- App factory → Mapping API: mounts · Registers mapping endpoints
- App factory → Questions API: mounts · Registers question-generation endpoints
- Syllabus API → Syllabus service: uses · Routes call syllabus parsing logic
- Textbook API → Ingestion: uses · Routes delegate upload and extraction work
- Ingestion → PDF utils: extracts · PDF utility handles document text extraction
- Ingestion → Image utils: handles · Image utility supports scanned content preprocessing
- Ingestion → Chunking: prepares · Extracted textbook content is normalized into chunks
- Syllabus service → Schemas: structures · Parsed syllabus uses canonical schema objects
- Mapping API → Mapping service: uses · Routes invoke semantic matching service
- Mapping service → Chunking: consumes · Mapping compares syllabus topics to text chunks
- Mapping service → Schemas: emits · Mapping results use shared response models
- Questions API → Question service: uses · Routes invoke exam generation service
- Question service → Bloom service: applies · Question generation constrains output by Bloom level
- Question service → Schemas: emits · Generated question payloads use shared schemas
- Syllabus upload → Syllabus API: uploads to · UI sends syllabus data to backend endpoints
- Textbook upload → Textbook API: uploads to · UI sends textbook data to backend endpoints
- Semantic mapping → Mapping API: requests · UI requests semantic mapping results
- Generated questions → Questions API: requests · UI requests generated questions
- Docs bundle → Config: documents · Docs describe model and runtime configuration
- Docs bundle → Question service: documents · Docs explain question-generation behavior