Uh oh!
There was an error while loading. Please reload this page.
Refactor: Migrate from course_name strings to course_id FKs - #51
Refactor: Migrate from course_name strings to course_id FKs#51Jose-Gael-Cruz-Lopez wants to merge 1 commit into
Conversation
This is a major schema refactoring to support canonical courses: Backend Changes: - course_context_service.py: Complete rewrite to use new course_concept_stats and course_summary tables with Gemini-powered summary generation - graph_service.py: Updated to join user_courses->courses, use course_id FK - routes/graph.py: Endpoints now accept course_id instead of course_name - routes/learn.py: Sessions store course_id, pass through to graph updates - routes/calendar.py: Assignments use course_id, join with courses for display - calendar_service.py: Updated to use course_id instead of course_name - models/__init__.py: Added course_id fields to Pydantic models Frontend Changes: - api.ts: Updated all API functions to use course_id instead of course_name - getCourses returns enriched data: course_code, course_name, school, dept - addCourse, updateCourseColor, deleteCourse all use course_id - startSession accepts optional course_id parameter - saveAssignments uses course_id Database Schema Migration (already applied in Supabase): - courses table is now canonical (no user_id) - user_courses is the enrollment join table - All dependent tables use course_id FK: assignments, sessions, graph_nodes, documents, study_guides - New tables: course_concept_stats, course_summary - Removed: course_context table
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Jose-Gael-Cruz-Lopez
commented
Apr 14, 2026
Superseded by combined PR #53 (course_id migration + calendar normalization). All migration changes are included there. |
Summary
This PR refactors the backend and frontend to use the new database schema where courses are canonical (no user_id) and user_courses is the enrollment join table.
Database Changes (already applied in Supabase)
coursesis now canonical (no user_id): id, course_code, course_name, department, school, etc.user_coursesis the enrollment join tablecourse_idFK tocourses.id:course_concept_stats,course_summarycourse_contexttableBackend Changes
services/course_context_service.py (COMPLETE REWRITE)
services/graph_service.py
get_graph: builds subject_root hubs from canonical courses (course_code + course_name)apply_graph_update: now acceptscourse_idparameter for all node inserts/updatesget_courses: returns enriched data: course_code, course_name, school, department, color, nicknameroutes/graph.py
course_idinstead ofcourse_nameroutes/learn.py
course_idinstead of resolving from topic stringsstart-sessionaccepts optionalcourse_idparametercourse_idthrough toapply_graph_updateroutes/calendar.py
saveendpoint usescourse_idinstead ofcourse_nameupcoming/allendpoints join with courses to return course_code and course_namemodels/init.py
course_idfields toStartSessionBody,AssignmentItem,AddCourseBodyFrontend Changes
src/lib/api.ts
getCourses: returnsEnrolledCoursewith course_code, course_name, school, department, etc.addCourse: takescourseIdinstead ofcourseNameupdateCourseColor,deleteCourse: usecourseIdstartSession: accepts optionalcourseIdparametersaveAssignments: usescourse_idinSaveAssignmentItemTesting
course_idfieldsMigration Notes
addCourse(userId, courseName)need to now calladdCourse(userId, courseId)where courseId is from the canonical courses catalogCommit:25dedba
Branch: refactor/course-id-schema