API & Background Jobs
Overviewβ
The EduVision ITS backend is built on FastAPI, providing high-performance, asynchronous endpoints for both real-time interaction (Chat) and administrative tasks (Course Management).
β‘ Core API Endpoints (main.py)β
1. Course Management (/courses)β
POST /- Create a new course (Teacher Only).GET /{id}- Retrieve course details and structure.POST /{id}/upload- Upload PDFs or text for ingestion. This triggers a background vectorization job.
2. Interaction Layer (/chat, /attempt)β
POST /chat/- The main interface for the Tutor Engine.- Input: User message, Session ID.
- Process: RAG retrieval (pgvector) -> Pedagogy check -> Together AI (Llama 3) generation.
- Output: Streaming response.
POST /attempt/- Submits a student's answer for grading.- Input: Question ID, Answer.
- Process: Assessment Engine grades -> Learner Engine updates BKT.
3. Analytics (/analytics)β
GET /student/{id}/progress- Returns mastery over time.GET /course/{id}/heatmap- Returns class-wide performance.
β³ Asynchronous Background Jobsβ
Heavy computational tasks are offloaded to a background worker system to keep the API responsive.
Job Model (models_prod.py)β
Tracks the status of long-running operations.
id(UUID)type(Enum:embedding_generation,course_ingest,analytics_refresh)status(Enum:pending,processing,completed,failed)result(JSON) - Stores output or error messages.
Key Workersβ
1. Embedding Generator (JobType.EMBEDDING_GENERATION)β
Triggered when a teacher uploads a document.
- Task: Uses
sentence-transformersto compute vectors for all text chunks. - Storage: Saves vectors directly to PostgreSQL using
pgvector. - Performance: Batched processing.
2. Knowledge Graph Builder (JobType.COURSE_INGEST)β
Triggered after embeddings are ready.
- Task: Identifies key concepts and relationships (e.g., "Loop" requires "Variable").
- Output: Creates edges in the graph database tables (
KnowledgeEdge).
3. Analytics Refresh (JobType.ANALYTICS_REFRESH)β
Scheduled nightly.
- Task: Aggregates student data to update class-wide metrics and difficulty parameters (IRT calibration).