Skip to main content
MongoDB database name comes from MONGODB_URI (typically d79-directory). Collections are Mongoose models in src/models. Field-level tables live on Database models.

Ownership vs collaboration

A plan has one owner (FormSubmission.userId) and a principal of record (principalEmail / principalName). Those are often the same person. Super Admin can transfer ownership; the previous owner is appended to transferHistory[]. Collaboration is not a join collection. It is stored in two places: Assistant Principals (level 3) need one of those records to edit. Same-school is not enough. See Roles and access.

Year and question bank pins

Existing answers stay keyed by formData[stepKey].data[question.id]. Publishing a new bank does not rewrite old formData.

Comments and audit

  • FormComment.formIdFormSubmission. Optional stepKey / stepNumber. General comments (no step) can move form status to under_review / approved / rejected.
  • AuditLog is append-only. Many user mutations also push onto User.activityLog[].
  • Indexes of note: users.email unique; formsubmissions partial unique { schoolName, schoolYear } as schoolName_schoolYear_unique; formtemplates.version unique; schoolyearsettings.schoolYear unique.
Super Admin System health reports whether schoolName_schoolYear_unique exists. Create and duplicate routes return 409 when a school already has a plan for that year.