PESU Curriculum Automation is a FastAPI and static frontend application for collecting course submissions, refining them into curriculum-ready records, previewing PDF output, staging reviewable edits, and preserving curriculum snapshots.
| Layer | Location | Responsibility |
|---|---|---|
| Static frontend | frontend/ |
Course entry, course management, PDF preview, live editor, and version history |
| API backend | backend/app/ |
FastAPI routes, validation, refinement, previews, drafts, chat, and snapshots |
| Persistence | Supabase | Raw submissions, refined courses, agent drafts, chat history, attachments, and curriculum versions |
| Rendering | Jinja2 and WeasyPrint | Curriculum summary pages, course detail pages, and PDF exports |
| Model provider | OpenRouter | Submission refinement and live editor chat with tool calls |
frontend/form/.POST /api/submissions validates the payload and stores it in submissions.refined_submissions./api/courses and /api/preview/*.| Route | Purpose |
|---|---|
/ |
Dashboard for the available application surfaces |
/form/ |
Raw course submission form |
/courses/ |
Refined course list with filtering and soft delete |
/preview/ |
Overall or semester PDF preview and download |
/live-editor/ |
Course preview, chat assistant, JSON editor, draft review, and version restore |
/versions/ |
Snapshot list, snapshot preview, and editor handoff |
The frontend is plain HTML, CSS, and JavaScript. There is no Node build step.
| Endpoint | Method | Purpose |
|---|---|---|
/api/submissions |
POST |
Store a raw submission and queue refinement |
/api/submissions/{id}/refine |
POST |
Manually refine a submission |
/api/refined/{refined_id} |
GET |
Read template-ready course fields |
/api/refined/{refined_id} |
PATCH |
Update editable refined fields |
/api/courses |
GET |
List active refined courses |
/api/courses/{refined_id} |
DELETE |
Archive a refined course |
/api/preview/course/{refined_id} |
GET |
Render one course as HTML |
/api/preview/pdf |
GET |
Render the full curriculum as PDF |
/api/preview/semester/{sem}/pdf |
GET |
Render one semester as PDF |
/api/versions |
GET, POST |
List or create curriculum snapshots |
/api/versions/{version_id}/restore |
POST |
Restore a saved curriculum snapshot |
/api/agent/drafts |
GET, POST |
List or create reviewable course drafts |
/api/agent/drafts/{draft_id}/apply |
POST |
Apply a proposed draft after review |
/api/agent/document-drafts |
GET, POST |
List or create multi-course drafts |
/api/chat/sessions |
GET, POST |
Manage live editor chat sessions |
/api/chat/sessions/{session_id}/messages |
GET, POST |
Read or stream chat messages |
/api/chat/sessions/{session_id}/attachments |
POST |
Upload document context for chat |
/api/health/schema |
GET |
Check required Supabase tables |
CourseSubmission is defined in backend/app/models/submission.py.
Required fields:
faculty_emailcourse_titleoffering_department: MA, CS, or UZtarget_department: CSE, ECE, ME, BT, EEE, or AIMLsemester: string value from 1 to 8credit_category: 0, 2, 4, or 5raw_course_content: at least 50 characterstext_books: at least 5 charactersOptional fields:
reference_bookspreferred_toolsSuccessful submissions return message and the inserted submission row.
Validation errors use FastAPI’s standard 422 response with a detail array.
The backend computes these fields in backend/app/services/deterministic.py:
| Credit category | L | T | P | S | C | Course type |
|---|---|---|---|---|---|---|
5 |
4 | 0 | 2 | 5 | 5 | Core Course-Lab Integrated |
4 |
4 | 0 | 0 | 4 | 4 | Core Course |
2 |
2 | 0 | 0 | 2 | 2 | Core Theory |
0 |
0 | 0 | 0 | 0 | 0 | Foundation Course |
All configured target departments currently map to B. TECH.
Agent drafts are not allowed to change deterministic fields such as program, hours, credits, or course type. Drafts that attempt these changes are blocked.
Run docs/schema.sql in the Supabase SQL editor before using the application. The schema creates:
submissionsrefined_submissionscurriculum_versionsfinalized_submissionsagent_document_draftsagent_draftscourse_revision_historychat_sessionschat_messageschat_attachmentsUse GET /api/health/schema to verify that the required tables exist.
Required backend variables:
SUPABASE_URLSUPABASE_KEYOPENROUTER_URLOPENROUTER_API_KEYOPENROUTER_MODELOptional backend variables:
CURRICULUM_YEARSENTRY_DSNSENTRY_ENVIRONMENTSENTRY_RELEASEKeep environment values in .env or platform secrets. Do not expose backend credentials in frontend code.
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cd backend
fastapi dev app/main.py
The backend serves the static frontend at http://127.0.0.1:8000/ and mounts the API under /api.
Run checks from the repository root:
source .venv/bin/activate
pytest
python3 -m compileall backend/app
The Docker image installs the Python dependencies, copies backend/ and frontend/, and runs:
uvicorn app.main:app --host 0.0.0.0 --port 7860
The included GitHub Actions workflow syncs main to the Hugging Face Space configured in .github/workflows/sync-to-hub.yml.
The static frontend can also be deployed from frontend/. The included frontend/vercel.json rewrites /api/* requests to the deployed backend.
The test suite covers: