Skip to content

Model Reference ​

Every model from prisma/schema.prisma. IDs are CUIDs (@default(cuid())) unless noted. "UK" = unique.

Enums ​

prisma
enum UserRole        { ADMIN  TEACHER  STUDENT }
enum AttendanceStatus { PRESENT  ABSENT  LATE }

Appeal status is a plain String ("PENDING", "APPROVED", "REJECTED"), not a Prisma enum, defaulting to "PENDING".

User ​

The base account for every person in the system.

FieldTypeNotes
idString PK
nameString?Display name.
emailString? UKLogin identifier.
passwordString?bcrypt hash (cost 10).
roleUserRoleDefaults to STUDENT.
image, emailVerifiedNextAuth adapter fields.
relationsstudent?, teacher?, accounts[], sessions[], activityLogs[].

Teacher ​

Teacher profile, 1:1 with a User.

FieldTypeNotes
idString PK
userIdString UK, FK → User
relationssections[] (as adviser), subjects[] (as instructor).

Student ​

Student profile, 1:1 with a User.

FieldTypeNotes
idString PKInternal DB id.
studentIdString UKSchool ID, e.g. 2022-0001. Also the initial password.
qrTokenString UKUUID (@default(uuid())) encoded in the QR code.
userIdString UK, FK → User
sectionIdString? FK → SectionNullable.
relationsattendances[], appeals[], enrolledSubjects[].

Section ​

A class/homeroom grouping.

FieldTypeNotes
idString PK
nameString UKe.g. BSCS 3rd Year.
teacherIdString? FK → TeacherAdviser; nullable.
relationsstudents[].

Subject ​

A course. Attendance is recorded per subject.

FieldTypeNotes
idString PK
codeString UKe.g. OS101.
nameStringe.g. Operating Systems.
unitsInt?
scheduleDayString?e.g. Mon,Wed,Fri.
scheduleTimeString?e.g. 08:00-09:30.
teacherIdString? FK → TeacherInstructor; nullable.
relationsenrollments[], attendances[].

StudentSubject ​

Enrollment join table (many-to-many between Student and Subject).

FieldTypeNotes
idString PK
studentIdString FK
subjectIdString FK
constraint@@unique([studentId, subjectId]).

Attendance ​

One attendance record per student, per subject, per day.

FieldTypeNotes
idString PK
dateDateTimeNormalised to UTC midnight.
statusAttendanceStatusPRESENT / ABSENT / LATE.
studentIdString FK
subjectIdString FK
updatedAtDateTime@updatedAt.
constraint@@unique([studentId, date, subjectId]).

AttendanceAudit ​

Append-only history of attendance changes. Never updated or deleted in normal operation (only wiped by a full data reset).

FieldTypeNotes
idString PK
attendanceIdStringThe record that changed.
changedByStringUser id who made the change.
oldStatusAttendanceStatus?Null if newly created.
newStatusAttendanceStatus
timestampDateTime
reasonString?e.g. "QR Scan".

Appeal ​

A student's request to correct/contest attendance.

FieldTypeNotes
idString PK
studentIdString FK
imageUrlString?Optional proof image (schema supports it).
descriptionStringThe written appeal.
statusStringPENDING (default) / APPROVED / REJECTED.
reviewedByString?Reviewer's user id.
reviewedAtDateTime?
createdAtDateTime

SystemSetting ​

Key–value configuration store.

FieldTypeNotes
idString PK
keyString UKe.g. attendance_lock_hours.
valueStringStored as text.
descriptionString?
updatedAtDateTime@updatedAt.

ActivityLog ​

System-wide activity feed written by logActivity().

FieldTypeNotes
idString PK
typeStringOne of the ActivityType values — see Audit Logging.
descriptionStringHuman-readable summary.
userIdString FK → UserActor.
metadataJson?Structured context.
createdAtDateTime

NextAuth adapter tables ​

Account, Session, and VerificationToken are standard NextAuth/Prisma adapter tables. With the JWT session strategy, Session is largely unused for auth; VerificationToken backs password-reset tokens.

Documentation for the Secure QR Attendance System.