AgentSkillsCN

data-schemas

为UniPortal正式定义MongoDB集合、字段约束、枚举类型以及实体关系。

SKILL.md
--- frontmatter
name: data-schemas
description: Formal definition of MongoDB collections, field constraints, enums, and entity relationships for UniPortal.

Data Schemas: UniPortal

This skill defines the source-of-truth for the MongoDB database layer. All frontend types and API endpoints must adhere strictly to these schema definitions.

1. User & Authentication

User Collection

The User collection is polymorphic. Depending on the role, it requires either student_profile or admin_profile.

Common Fields:

FieldTypeDescription
_idObjectIdSystem ID
user_idStringUnique Identifier (e.g., TNT-8801, ADM-001)
nameStringFull Name
emailStringContact Email
avatarStringURL to profile image
roleEnum'student', 'admin'
created_atDateAccount creation timestamp

Role-Specific: Student Profile Required if role is 'student'

FieldTypeConstraints/Enums
major_idStringReference to Majors collection
academic_statusEnum'Active', 'Probation', 'Suspended', 'Graduated', 'majorChange'
total_creditsIntMin: 0
advisor_idStringUser ID (Admin)
is_major_studentBooleanTrue if officially declared
gpaDoubleMin: 0, Max: 4
cgpaDoubleMin: 0, Max: 4
current_sem_earned_creditsIntCredits this semester
total_credits_completedIntAll-time earned credits
current_yearEnumSee Year Enum Dictionary below

Role-Specific: Admin Profile Required if role is 'admin'

FieldTypeConstraints/Enums
departmentStringAdministrative department
access_levelEnum'super_admin', 'registrar', 'instructor'
permissionsArray['manage_courses', 'grade_students', 'approve_enrollment']

Embedded Histories:

  • Academic History: Array of { course_id, course_code, course_title, semester, credits, grade, status }.
  • Major History: Array of { major_name, status, start_term, end_term, major_id }.

UserAuth Collection

Separated for security.

FieldTypeNotes
user_idStringLinks to User.user_id
password_hashStringArgon2id hash
must_reset_passwordBooleantrue for initial default passwords

2. Academic Core

Majors Collection

FieldTypeNotes
_idStringManual Code ID (e.g., "SE", "CS")
major_nameStringFull Name
departmentStringOwning department
requirementsArrayList of required course_id strings

Course Collection

FieldTypeDescription
course_codeStringe.g., "CST-1010"
titleStringCourse Name
creditsNumberMin: 0.5, Max: 6.0
typeEnum'Core', 'Elective', 'Prerequisite', 'Major'
semesterArrayArray of objects: [{ semester: "String" }]
major_specificBooleanIf true, restricted to declared majors
prerequisitesArrayList of course_code strings
scheduleArray["Mon 10:00-11:30"]
syllabusArray[{ week: Int, topic: String }]

3. Enrollment & Grading

Enrollment Collection

Tracks a student's relationship with a course for a specific term.

FieldTypeDescription
student_idStringRef to User
course_idStringRef to Course
semesterAttendStringe.g., "First Year, First Sem(old)"
is_retakeBooleanFlag for repeat attempts
statusEnum'Enrolled', 'Pending', 'Conflict', 'Waitlisted', 'Completed', 'Dropped', 'Withdrawn', 'Failed', 'Passed'
gradeEnum'A+', 'A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'D', 'F', 'W', 'I', 'U', 'Abs'
pointsNumberGrade points for GPA (e.g., 4.0, 2.33)
scoresNumberRaw numeric score (e.g., 85.5)

4. Communication

Announcements Collection

FieldTypeConstraints
typeEnum'General', 'Urgent', 'Event', 'Academic'
target_audienceEnum'All', 'Students', 'Faculty', 'Computer Science Dept', 'Seniors'
expiry_dateDateNullable. If null, never expires.
posted_byStringAdmin ID

Messages Collection

FieldTypeConstraints
categoryEnum'General', 'Warning', 'Advisor Note', 'Enrollment Issue'
is_readBooleanFor UI badges
sender_idStringAdmin ID
receiver_idStringStudent ID

Reference Dictionaries

Year & Semester Enum (Crucial)

This specific format must be used for current_year and semesterAttend.

typescript
type AcademicYear = 
  | '1st Year, First Sem(new)' | '1st Year, Second Sem(new)'
  | '2nd Year, First Sem(new)' | '2nd Year, Second Sem(new)'
  | '3rd Year, First Sem(new)' | '3rd Year, Second Sem(new)'
  | '4th Year, First Sem(new)' | '4th Year, Second Sem(new)'
  | '1st Year, First Sem(old)' | '1st Year, Second Sem(old)'
  | '2nd Year, First Sem(old)' | '2nd Year, Second Sem(old)'
  | '3rd Year, First Sem(old)' | '3rd Year, Second Sem(old)'
  | '4th Year, First Sem(old)' | '4th Year, Second Sem(old)'
  | '5th Year, First Sem(old)' | '5th Year, Second Sem(old)';