⚠️ This documentation is a work in progress and subject to frequent changes ⚠️
DatabaseSchema

Database Schema Documentation

Overview

EDURange Cloud uses a PostgreSQL database with Prisma ORM to manage data. The schema is designed to support the platform’s core functionalities, including user management, competition organization, challenge tracking, and activity logging.

Entity Relationship Diagram

This diagram shows the main entities and their primary relationships. For a more detailed view of all relationships, see the comprehensive diagram.

How to Read This Diagram

The diagram uses standard Entity-Relationship (ER) notation with the following symbols:

  • Entities: Rectangles representing database tables (e.g., User, Challenge)
  • Relationships: Lines connecting entities with symbols at each end indicating the type of relationship
  • Relationship Text: Describes the nature of the relationship (e.g., “has”, “belongs to”)

Relationship Symbols:

  • ||--o{ : One-to-many relationship (e.g., one User has many ChallengeInstances)
  • }o--o{ : Many-to-many relationship (e.g., Users can be members of many CompetitionGroups)
  • }|--|| : Many-to-one relationship (e.g., many ChallengeInstances belong to one User)
  • }o--o| : Many-to-optional one relationship (e.g., Challenges may belong to a ChallengePack)

Cardinality Notation:

  • || : Exactly one
  • }| : Many (one or more)
  • o{ : Zero or many
  • o| : Zero or one

Core Entities

User

The User model represents users of the platform with different roles.

FieldTypeDescription
idStringUnique identifier (CUID)
nameString?User’s display name
emailStringUser’s email address (unique)
emailVerifiedDateTime?When the email was verified
imageString?Profile image URL
roleUserRoleUser’s role (ADMIN, INSTRUCTOR, STUDENT)
createdAtDateTimeWhen the user was created
updatedAtDateTimeWhen the user was last updated

Relationships:

  • Has many Account records (for OAuth providers)
  • Has many Session records
  • Has many ActivityLog records
  • Has many ChallengeInstance records
  • Has many GroupPoints records
  • Can be an instructor in many CompetitionGroup records
  • Can be a member of many CompetitionGroup records
  • Has many ChallengeCompletion records
  • Has many QuestionCompletion records
  • Has many QuestionAttempt records

CompetitionGroup

Represents a group or class for competitions and challenges.

FieldTypeDescription
idStringUnique identifier (CUID)
nameStringGroup name
descriptionString?Group description
startDateDateTimeWhen the competition starts
endDateDateTime?When the competition ends
createdAtDateTimeWhen the group was created
updatedAtDateTimeWhen the group was last updated

Relationships:

  • Has many CompetitionAccessCode records
  • Has many GroupChallenge records
  • Has many ChallengeInstance records
  • Has many ActivityLog records
  • Has many GroupPoints records
  • Has many instructors (Users with INSTRUCTOR role)
  • Has many members (Users with any role)

Challenge

Represents a challenge template that can be added to competition groups.

FieldTypeDescription
idStringUnique identifier (CUID)
nameStringChallenge name
descriptionString?Challenge description
difficultyChallengeDifficulty?Difficulty level (EASY, MEDIUM, HARD, VERY_HARD)
challengeTypeIdStringReference to challenge type
createdAtDateTimeWhen the challenge was created
updatedAtDateTimeWhen the challenge was last updated
cdf_versionString?Version of the Challenge Definition Format
cdf_contentJson?Full CDF definition as JSON
pack_idString?Reference to the challenge pack
pack_challenge_idString?Identifier within the challenge pack

Relationships:

  • Has many ChallengeQuestion records
  • Has many ChallengeAppConfig records
  • Has many GroupChallenge records
  • Has many ActivityLog records
  • Belongs to a ChallengeType
  • May belong to a ChallengePack

ChallengePack

Represents a collection of related challenges packaged together.

FieldTypeDescription
idStringUnique identifier (CUID)
nameStringHuman-readable name of the pack
descriptionString?Description of the challenge pack
versionStringVersion of the challenge pack
authorString?Author of the challenge pack
licenseString?License information
websiteString?Website URL for the pack
installed_dateDateTimeWhen the pack was installed
updatedAtDateTimeWhen the pack was last updated

Relationships:

  • Has many Challenge records

ChallengeInstance

Represents a running instance of a challenge for a specific user.

FieldTypeDescription
idStringUnique identifier (UUID)
challengeIdStringChallenge identifier
userIdStringUser identifier
challengeUrlStringURL to access the challenge
creationTimeDateTimeWhen the instance was created
statusChallengeStatusCurrent status (CREATING, ACTIVE, TERMINATING, TERMINATED, ERROR)
terminationAttemptsIntNumber of termination attempts
lastStatusChangeDateTimeWhen the status last changed
flagSecretNameString?Name of the secret containing the flag
flagString?The challenge flag
competitionIdStringCompetition group identifier
k8s_instance_nameString?Kubernetes instance name

Relationships:

  • Belongs to a User
  • Belongs to a CompetitionGroup
  • Has many ActivityLog records

Supporting Entities

GroupChallenge

Links challenges to competition groups with specific point values.

FieldTypeDescription
idStringUnique identifier (CUID)
pointsIntPoints awarded for completion
challengeIdStringChallenge identifier
groupIdStringCompetition group identifier
createdAtDateTimeWhen the record was created
updatedAtDateTimeWhen the record was last updated

Relationships:

  • Belongs to a Challenge
  • Belongs to a CompetitionGroup
  • Has many ChallengeCompletion records
  • Has many QuestionAttempt records
  • Has many QuestionCompletion records

ChallengeQuestion

Represents questions within a challenge.

FieldTypeDescription
idStringUnique identifier (CUID)
challengeIdStringChallenge identifier
contentStringQuestion content
typeStringQuestion type
pointsIntPoints awarded for correct answer
answerString?Correct answer
orderIntDisplay order
titleString?Question title
formatString?Format of the question
hintString?Hint for the question
requiredBooleanWhether the question is required
cdf_question_idString?ID of the question in the CDF
cdf_payloadJson?Additional CDF data for the question
createdAtDateTimeWhen the question was created
updatedAtDateTimeWhen the question was last updated

Relationships:

  • Belongs to a Challenge
  • Has many QuestionAttempt records
  • Has many QuestionCompletion records

ChallengeAppConfig

Configures applications available within a challenge’s WebOS environment.

FieldTypeDescription
idStringUnique identifier (CUID)
challengeIdStringChallenge identifier
appIdStringApplication identifier
titleStringApplication title
iconStringIcon path
widthIntWindow width
heightIntWindow height
screenStringScreen identifier
disabledBooleanWhether the app is disabled
favouriteBooleanWhether the app is favorited
desktop_shortcutBooleanWhether to show on desktop
launch_on_startupBooleanWhether to launch on startup
additional_configJson?Additional configuration
createdAtDateTimeWhen the record was created
updatedAtDateTimeWhen the record was last updated

Relationships:

  • Belongs to a Challenge

CompetitionAccessCode

Represents access codes for joining competition groups.

FieldTypeDescription
idStringUnique identifier (CUID)
codeStringUnique access code
expiresAtDateTime?When the code expires
maxUsesInt?Maximum number of uses
usedCountIntCurrent use count
groupIdStringCompetition group identifier
createdAtDateTimeWhen the code was created
createdByStringUser who created the code

Relationships:

  • Belongs to a CompetitionGroup
  • Has many ActivityLog records

GroupPoints

Tracks points earned by users within a specific competition group.

FieldTypeDescription
idStringUnique identifier (CUID)
userIdStringUser identifier
groupIdStringCompetition group identifier
pointsIntTotal points earned
createdAtDateTimeWhen the record was created
updatedAtDateTimeWhen the record was last updated

Relationships:

  • Belongs to a User
  • Belongs to a CompetitionGroup

Tracking Entities

ChallengeCompletion

Tracks when users complete challenges.

FieldTypeDescription
idStringUnique identifier (CUID)
userIdStringUser identifier
groupChallengeIdStringGroup challenge identifier
pointsEarnedIntPoints earned
completedAtDateTimeWhen the challenge was completed

Relationships:

  • Belongs to a User
  • Belongs to a GroupChallenge

QuestionCompletion

Tracks when users complete questions.

FieldTypeDescription
idStringUnique identifier (CUID)
questionIdStringQuestion identifier
userIdStringUser identifier
groupChallengeIdStringGroup challenge identifier
completedAtDateTimeWhen the question was completed
pointsEarnedIntPoints earned

Relationships:

  • Belongs to a User
  • Belongs to a GroupChallenge
  • Belongs to a ChallengeQuestion

QuestionAttempt

Tracks attempts made by users to answer questions.

FieldTypeDescription
idStringUnique identifier (CUID)
questionIdStringQuestion identifier
userIdStringUser identifier
groupChallengeIdStringGroup challenge identifier
attemptedAtDateTimeWhen the attempt was made
answerStringThe submitted answer
correctBooleanWhether the answer was correct

Relationships:

  • Belongs to a User
  • Belongs to a GroupChallenge
  • Belongs to a ChallengeQuestion

ActivityLog

Tracks important events in the system.

FieldTypeDescription
idStringUnique identifier (CUID)
eventTypeActivityEventTypeType of activity event
userIdStringUser identifier
challengeIdString?Challenge identifier
groupIdString?Competition group identifier
metadataJsonAdditional event data
timestampDateTimeWhen the event occurred
accessCodeIdString?Access code identifier
challengeInstanceIdString?Challenge instance identifier
severityLogSeveritySeverity level (DEBUG, INFO, WARNING, ERROR, CRITICAL)

Relationships:

  • Belongs to a User
  • May belong to a Challenge
  • May belong to a CompetitionGroup
  • May belong to a CompetitionAccessCode
  • May belong to a ChallengeInstance

Enumerations

UserRole

  • ADMIN: System administrator with full access
  • INSTRUCTOR: Can create and manage competition groups and challenges
  • STUDENT: Can join competition groups and participate in challenges

ChallengeStatus

  • CREATING: Challenge instance is being created
  • ACTIVE: Challenge instance is running
  • TERMINATING: Challenge instance is being terminated
  • TERMINATED: Challenge instance has been terminated
  • ERROR: An error occurred with the challenge instance

ChallengeDifficulty

  • EASY: Beginner-level challenge
  • MEDIUM: Intermediate-level challenge
  • HARD: Advanced-level challenge
  • VERY_HARD: Expert-level challenge

LogSeverity

  • DEBUG: Detailed information for debugging
  • INFO: General information about system operation
  • WARNING: Potential issues that don’t affect system operation
  • ERROR: Errors that affect specific operations
  • CRITICAL: Critical errors that affect system operation

ActivityEventType

Various event types including user registration, login, challenge starts, completions, etc.