Skip to main content

Databases

Overview

Prisma ORM is used to manipulate the data and the database schema in both the development and production environments that each link a seperate PostgreSQL instance.

Setup

The entry point to the schema is available at functions/prisma/prisma.schema.

Repository

URL: https://github.com/theananta/chitti-server

Steps to run

To run the client application:

  1. Clone the repository.
  2. Run docker run --name chitti -e POSTGRES_PASSWORD=robo -d -p 5432:5432 postgres in your preferred terminal.
  3. Append the following line to the .env (development environment) : DATABASE_URL="postgresql://postgres:robo@localhost:5432/chitti?schema=public"
  4. Run npx prisma migrate dev --name {name_of_migration} to build the database schema in the postgreSQL instance running on docker.
  5. Run npx prisma generate to generate the prisma client locally.

Models

Visual Representation

Student

└─── Auth

Student
└─── (enrolls in) Courses

Course
└─── Units
├─── Roadmap
├─── Notes
├─── Cheatsheet
├─── ImportantQuestions
└─── Video

Student

Represents a student enrolled in the system.

FieldTypeDescription
rollNoStringGITAM roll number for the student (Primary Key).
nameStringFull name of the student.
semesterIntCurrent semester number the student is in.
coursesString[]List of course IDs the student is enrolled in.
scheduleStringStudent's exams schedule in a serialized format (e.g., JSON).
completedString[]List of completed resource IDs by the student.

Auth

Handles authentication details separately from student profile.

FieldTypeDescription
rollNoStringRoll number (Primary Key), linked to Student.
passStringPassword for login.
subId0|1|2|3|4Subscription or authentication identifier.
courseIdsString[]Courses the user has paid for.
deviceIdStringDevice identifier used for secure login.

Subscription Types:

0 - Freemium user
1 - User with access to notes, cheatsheets, important questions and roadmap
2- User with subscription access to videos
3 - User with completete subscription of the couse/subject
4 - Admin access


Course

Represents a course offered in the system.

FieldTypeDescription
courseIdStringUnique course ID based on GITAM mapping (Primary Key).
courseCategoryStringHyphen seperated category of the course (e.g., program-core).
titleStringTitle or name of the course.
descriptionStringBrief description of the course content.
imageStringCover URL for the course image or thumbnail.
iconIntIcon code for UI display (Default: 61239).

Unit

Represents a unit/module inside a course.

FieldTypeDescription
courseIdStringID of the course this unit belongs to.
unitIdStringUnique unit ID (Primary Key, auto-generated UUID).
unitNoIntUnit number/order inside the course.
unitNameStringName/title of the unit.
descriptionStringSummary or introduction to the unit.
difficultyStringDifficulty level (e.g., Beginner, Intermediate, Advanced).
totalResourcesIntTotal number of learning resources linked to this unit.

Roadmap

Represents a learning roadmap item or topic for a unit.

FieldTypeDescription
roadIdStringUnique ID for the topic (Primary Key, auto-generated UUID).
courseIdStringID of the course this topic is linked to.
unitIdStringID of the unit this topic is linked to.
difficultyStringPriority level of the topic targeted by the roadmap.
nameStringTitle/name of the topic.

Index: Composite index on courseId and unitId for faster lookups.


Notes

Represents a set of notes for a particular topic inside a unit.

FieldTypeDescription
notesIdStringUnique notes ID (Primary Key, auto-generated UUID).
courseIdStringID of the course.
unitIdStringID of the unit.
topicIdStringSpecific topic ID within the unit.
urlStringURL where the notes are hosted/downloadable.
nameStringTitle of the notes.

Index: Composite index on courseId, unitId, and topicId.


Cheatsheet

Represents a cheatsheet — quick revision material — for a topic.

FieldTypeDescription
cheatIdStringUnique cheatsheet ID (Primary Key, auto-generated UUID).
courseIdStringID of the course.
unitIdStringID of the unit.
topicIdStringTopic ID inside the unit.
urlStringURL where the cheatsheet is accessible.
nameStringTitle/name of the cheatsheet.

Index: Composite index on courseId, unitId, and topicId.


ImportantQuestions

Represents important questions for exam preparation for a unit.

FieldTypeDescription
iqIdStringUnique ID for important questions (Primary Key, auto-generated UUID).
courseIdStringCourse ID.
unitIdStringUnit ID.
urlStringURL to the PDF or resource for important questions.

Index: Composite index on courseId and unitId.


Video

Represents a video resource for a specific topic inside a unit.

FieldTypeDescription
videoIdStringUnique video ID (Primary Key, auto-generated UUID).
courseIdStringID of the course.
unitIdStringID of the unit.
topicIdStringTopic ID within the unit.
urlStringURL where the video is hosted.
thumbnailStringURL of the thumbnail image for the video.
nameStringTitle of the video.

Index: Composite index on courseId, unitId, and topicId.


Quick Notes

  • UUIDs (@default(uuid())) are used for most resource IDs for uniqueness.
  • Multiple composite indexes (@@index) optimize frequent queries based on courseId, unitId, and topicId.
  • Authentication (Auth) and profile (Student) are separated for modular design.
  • schedule is saved as a String, suggesting it's a serialized (JSON) structure.

Relationships Between Models

  • Student
    ↳ Has authentication information linked by rollNo in the Auth table.
    ↳ Enrolled in multiple Courses (by storing courseIds in courses array).

  • Auth
    ↳ Authenticates a Student via rollNo.
    ↳ Contains a list of enrolled courseIds separately (for security/permissions).

  • Course
    ↳ One Course can have multiple Units.
    ↳ One Course can have multiple Roadmaps, Notes, Cheatsheets, ImportantQuestions, and Videos.

  • Unit
    ↳ Belongs to exactly one Course (courseId).
    ↳ Contains multiple Roadmaps, Notes, Cheatsheets, Videos, and ImportantQuestions.

  • Roadmap
    ↳ Belongs to a Unit and a Course (unitId, courseId).
    ↳ Defines the learning roadmap for that unit.

  • Notes
    ↳ Linked to a Unit, Course, and a specific Topic (unitId, courseId, topicId).
    ↳ Provides detailed study material.

  • Cheatsheet
    ↳ Linked to a Unit, Course, and a specific Topic (unitId, courseId, topicId).
    ↳ Provides quick revision material.

  • ImportantQuestions
    ↳ Linked to a Unit and Course (unitId, courseId).
    ↳ Provides important exam questions for that unit.

  • Video
    ↳ Linked to a Unit, Course, and a specific Topic (unitId, courseId, topicId).
    ↳ Provides video learning material.